Skip to content

Commit

Permalink
Merge pull request #13 from fleetbase/dev-v0.3.0
Browse files Browse the repository at this point in the history
v0.3.0
  • Loading branch information
roncodes authored Feb 13, 2024
2 parents 9096a19 + 36ef89d commit b5776ac
Show file tree
Hide file tree
Showing 40 changed files with 238 additions and 78 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/storefront-api",
"version": "0.2.11",
"version": "0.3.0",
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
Expand All @@ -22,8 +22,8 @@
],
"require": {
"php": "^8.0",
"fleetbase/core-api": "^1.4.0",
"fleetbase/fleetops-api": "^0.4.6",
"fleetbase/core-api": "^1.4.3",
"fleetbase/fleetops-api": "^0.4.9",
"geocoder-php/google-maps-places-provider": "^1.4",
"laravel-notification-channels/apn": "^5.0",
"laravel-notification-channels/fcm": "^4.1",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Storefront",
"version": "0.2.11",
"version": "0.3.0",
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
"repository": "https://github.com/fleetbase/storefront",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/storefront-engine",
"version": "0.2.11",
"version": "0.3.0",
"description": "Headless Commerce & Marketplace Extension for Fleetbase",
"fleetbase": {
"route": "storefront",
Expand Down
3 changes: 1 addition & 2 deletions server/src/Http/Controllers/MetricsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
class MetricsController extends Controller
{
/**
* Get all key metrics for a companies storefront
* Get all key metrics for a companies storefront.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function all(Request $request)
Expand Down
2 changes: 1 addition & 1 deletion server/src/Http/Controllers/v1/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CartController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function retrieve(string $uniqueId = null, Request $request)
public function retrieve(?string $uniqueId = null, Request $request)
{
$cart = Cart::retrieve($uniqueId, true);

Expand Down
30 changes: 19 additions & 11 deletions server/src/Http/Controllers/v1/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Fleetbase\FleetOps\Models\Contact;
use Fleetbase\FleetOps\Models\Order;
use Fleetbase\FleetOps\Models\Place;
use Fleetbase\FleetOps\Support\Utils;
use Fleetbase\Http\Controllers\Controller;
use Fleetbase\Models\User;
use Fleetbase\Models\UserDevice;
Expand All @@ -18,6 +17,7 @@
use Fleetbase\Storefront\Http\Requests\VerifyCreateCustomerRequest;
use Fleetbase\Storefront\Http\Resources\Customer;
use Fleetbase\Storefront\Support\Storefront;
use Fleetbase\Support\Utils;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
Expand Down Expand Up @@ -136,13 +136,19 @@ public function requestCustomerCreationCode(VerifyCreateCustomerRequest $request
$meta = ['identity' => $identity];

if ($isEmail) {
VerificationCode::generateEmailVerificationFor($customer, 'storefront_create_customer', function ($verification) use ($about) {
return "Your {$about->name} verification code is {$verification->code}";
}, $meta);
VerificationCode::generateEmailVerificationFor($customer, 'storefront_create_customer', [
'messageCallback' => function ($verification) use ($about) {
return "Your {$about->name} verification code is {$verification->code}";
},
'meta' => $meta,
]);
} else {
VerificationCode::generateSmsVerificationFor($customer, 'storefront_create_customer', function ($verification) use ($about) {
return "Your {$about->name} verification code is {$verification->code}";
}, $meta);
VerificationCode::generateSmsVerificationFor($customer, 'storefront_create_customer', [
'messageCallback' => function ($verification) use ($about) {
return "Your {$about->name} verification code is {$verification->code}";
},
'meta' => $meta,
]);
}

return response()->json(['status' => 'ok']);
Expand Down Expand Up @@ -382,9 +388,11 @@ public function loginWithPhone()
$about = Storefront::about();

// generate verification token
VerificationCode::generateSmsVerificationFor($user, 'storefront_login', function ($verification) use ($about) {
return "Your {$about->name} verification code is {$verification->code}";
});
VerificationCode::generateSmsVerificationFor($user, 'storefront_login', [
'messageCallback' => function ($verification) use ($about) {
return "Your {$about->name} verification code is {$verification->code}";
},
]);

return response()->json(['status' => 'OK']);
}
Expand Down Expand Up @@ -454,7 +462,7 @@ public function verifyCode(Request $request)
/**
* Patches phone number with international code.
*/
public static function phone(string $phone = null): string
public static function phone(?string $phone = null): string
{
if ($phone === null) {
$phone = request()->input('phone');
Expand Down
2 changes: 1 addition & 1 deletion server/src/Http/Controllers/v1/NetworkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use Fleetbase\FleetOps\Support\Utils;
use Fleetbase\Http\Controllers\Controller;
use Fleetbase\LaravelMysqlSpatial\Types\Point;
use Fleetbase\Models\Category;
use Fleetbase\Storefront\Http\Resources\Store as StorefrontStore;
use Fleetbase\Storefront\Http\Resources\StoreLocation as StorefrontStoreLocation;
use Fleetbase\Storefront\Models\Store;
use Fleetbase\Storefront\Models\StoreLocation;
use Fleetbase\LaravelMysqlSpatial\Types\Point;
use Illuminate\Http\Request;

class NetworkController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion server/src/Http/Controllers/v1/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function find($id)
/**
* Deletes a Storefront Product resources.
*
* @return \Fleetbase\Http\Resources\v1\DeletedResource
* @return DeletedResource
*/
public function delete($id)
{
Expand Down
5 changes: 3 additions & 2 deletions server/src/Http/Controllers/v1/ServiceQuoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Fleetbase\Storefront\Models\Product;
use Fleetbase\Storefront\Models\Store;
use Fleetbase\Storefront\Models\StoreLocation;
use Fleetbase\Support\Utils as CoreUtils;
use Illuminate\Support\Str;

class ServiceQuoteController extends Controller
Expand All @@ -30,7 +31,7 @@ class ServiceQuoteController extends Controller
*/
public function fromCart(GetServiceQuoteFromCart $request)
{
$requestId = ServiceQuote::generatePublicId('request');
$requestId = CoreUtils::generatePublicId('request');
$origin = $this->getPlaceFromId($request->input('origin'));
$destination = $this->getPlaceFromId($request->input('destination'));
$facilitator = $request->input('facilitator');
Expand Down Expand Up @@ -302,7 +303,7 @@ public function fromCartForNetwork(GetServiceQuoteFromCart $request)

if ($integratedVendor) {
try {
/** @var \Fleetbase\FleetOps\Models\ServiceQuote $serviceQuote */
/** @var ServiceQuote $serviceQuote */
$serviceQuote = $integratedVendor->api()->setRequestId($requestId)->getQuoteFromPreliminaryPayload([...$origins, $destination], [], $serviceType, $scheduledAt, $isRouteOptimized);
} catch (\Exception $e) {
return response()->error($e->getMessage());
Expand Down
2 changes: 1 addition & 1 deletion server/src/Http/Requests/GetServiceQuoteFromCart.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Fleetbase\Storefront\Http\Requests;

use Fleetbase\Http\Requests\FleetbaseRequest;
use Fleetbase\Rules\IsValidLocation;
use Fleetbase\Storefront\Rules\IsValidLocation;
use Illuminate\Support\Str;

class GetServiceQuoteFromCart extends FleetbaseRequest
Expand Down
5 changes: 2 additions & 3 deletions server/src/Http/Requests/InitializeCheckoutRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace Fleetbase\Storefront\Http\Requests;

use Fleetbase\Http\Requests\FleetbaseRequest;
// use Fleetbase\Rules\Storefront\CartExists;
use Fleetbase\Rules\Storefront\CustomerExists;
use Fleetbase\Rules\Storefront\GatewayExists;
use Fleetbase\Storefront\Rules\CustomerExists;
use Fleetbase\Storefront\Rules\GatewayExists;

class InitializeCheckoutRequest extends FleetbaseRequest
{
Expand Down
10 changes: 5 additions & 5 deletions server/src/Http/Resources/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function toArray($request)
];
}

public function mapHours(\Illuminate\Database\Eloquent\Collection $hours = null): array
public function mapHours(?\Illuminate\Database\Eloquent\Collection $hours = null): array
{
if (empty($hours)) {
return [];
Expand All @@ -79,7 +79,7 @@ function ($hour) {
);
}

public function mapFiles(\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
public function mapFiles(?\Illuminate\Database\Eloquent\Collection $files = null, $contentType = 'image')
{
return collect($files)->map(function ($file) use ($contentType) {
if (!Str::contains($file->content_type, $contentType)) {
Expand All @@ -90,7 +90,7 @@ public function mapFiles(\Illuminate\Database\Eloquent\Collection $files = null,
})->filter()->values();
}

public function mapAddonCategories(\Illuminate\Database\Eloquent\Collection $addonCategories = null)
public function mapAddonCategories(?\Illuminate\Database\Eloquent\Collection $addonCategories = null)
{
return collect($addonCategories)->map(function ($addonCategory) {
$addons = data_get($addonCategory, 'category.addons', []);
Expand Down Expand Up @@ -120,7 +120,7 @@ public function mapAddonCategories(\Illuminate\Database\Eloquent\Collection $add
});
}

public function mapProductAddons(\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
public function mapProductAddons(?\Illuminate\Database\Eloquent\Collection $addons = null, $excluded = [])
{
return collect($addons)->map(function ($addon) use ($excluded) {
if (is_array($excluded) && in_array($addon->uuid, $excluded)) {
Expand Down Expand Up @@ -157,7 +157,7 @@ public function mapProductAddons(\Illuminate\Database\Eloquent\Collection $addon
})->filter()->values();
}

public function mapVariants(\Illuminate\Database\Eloquent\Collection $variants = null)
public function mapVariants(?\Illuminate\Database\Eloquent\Collection $variants = null)
{
return collect($variants)->map(function ($variant) {
$productVariantArr = [
Expand Down
2 changes: 1 addition & 1 deletion server/src/Imports/ProductsImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ProductsImport implements ToCollection, WithHeadingRow
{
/**
* @return \Illuminate\Support\Collection
* @return Collection
*/
public function collection(Collection $rows)
{
Expand Down
2 changes: 1 addition & 1 deletion server/src/Listeners/HandleOrderDriverAssigned.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class HandleOrderDriverAssigned implements ShouldQueue
*/
public function handle(OrderDriverAssigned $event)
{
/** @var \Fleetbase\FleetOps\Models\Order $order */
/** @var Order $order */
$order = $event->getModelRecord();

// halt if unable to resolve order record from event
Expand Down
2 changes: 1 addition & 1 deletion server/src/Models/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public function createEvent(string $eventName, $cartItemId = null, $save = true)
*
* @return \Fleetbase\Models\Storefront\Cart
*/
public function updateCurrency(string $currencyCode = null, $save = false)
public function updateCurrency(?string $currencyCode = null, $save = false)
{
$this->attributes['currency'] = $currencyCode ?? session('storefront_currency');

Expand Down
2 changes: 1 addition & 1 deletion server/src/Models/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getIsQpayGatewayAttribute()
/**
* Generates a new cash/cash on delivery gateway.
*/
public static function cash($attributes = ['sandbox' => 0]): Gateway
public static function cash($attributes = ['sandbox' => false]): Gateway
{
return new static([
'public_id' => 'gateway_cash',
Expand Down
10 changes: 5 additions & 5 deletions server/src/Models/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class Network extends StorefrontModel
{
use HasUuid;
use HasPublicId;
use HasPublicid;
use HasApiModelBehavior;
use HasOptionsAttributes;
use HasSlug;
Expand Down Expand Up @@ -83,7 +83,7 @@ class Network extends StorefrontModel
protected $hidden = ['logo', 'backdrop', 'files', 'media'];

/**
* @var \Spatie\Sluggable\SlugOptions
* @var SlugOptions
*/
public function getSlugOptions(): SlugOptions
{
Expand Down Expand Up @@ -220,7 +220,7 @@ public function getStoresCountAttribute()
/**
* Adds a new store to the network.
*/
public function addStore(Store $store, Category $category = null): NetworkStore
public function addStore(Store $store, ?Category $category = null): NetworkStore
{
return NetworkStore::updateOrCreate(
[
Expand All @@ -241,7 +241,7 @@ public function addStore(Store $store, Category $category = null): NetworkStore
* @param File|string|null $icon
* @param string $iconColor
*/
public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
public function createCategory(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
{
$iconFile = null;
$iconName = null;
Expand Down Expand Up @@ -276,7 +276,7 @@ public function createCategory(string $name, string $description = '', ?array $m
* @param File|string|null $icon
* @param string $iconColor
*/
public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], Category $parent = null, $icon = null, $iconColor = '#000000'): Category
public function createCategoryStrict(string $name, string $description = '', ?array $meta = [], ?array $translations = [], ?Category $parent = null, $icon = null, $iconColor = '#000000'): Category
{
$existingCategory = Category::where(['company_uuid' => $this->company_uuid, 'owner_uuid' => $this->uuid, 'name' => $name])->first();

Expand Down
2 changes: 1 addition & 1 deletion server/src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function boot()
}

/**
* @var \Spatie\Sluggable\SlugOptions
* @var SlugOptions
*/
public function getSlugOptions(): SlugOptions
{
Expand Down
2 changes: 1 addition & 1 deletion server/src/Models/ProductAddon.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ProductAddon extends StorefrontModel
protected $appends = [];

/**
* @var \Spatie\Sluggable\SlugOptions
* @var SlugOptions
*/
public function getSlugOptions(): SlugOptions
{
Expand Down
2 changes: 1 addition & 1 deletion server/src/Models/ProductStoreLocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class ProductStoreLocation extends StorefrontModel
protected $appends = [];

/**
* @var \Spatie\Sluggable\SlugOptions
* @var SlugOptions
*/
public function getSlugOptions(): SlugOptions
{
Expand Down
2 changes: 1 addition & 1 deletion server/src/Models/ProductVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ProductVariant extends StorefrontModel
protected $with = [];

/**
* @var \Spatie\Sluggable\SlugOptions
* @var SlugOptions
*/
public function getSlugOptions(): SlugOptions
{
Expand Down
Loading

0 comments on commit b5776ac

Please sign in to comment.