![]() use TimothyDC\LightspeedRetailApi\Traits\HasLightspeedRetailResources Return \TimothyDC\LightspeedRetailApi\Services\Lightspeed\ResourceItem::$resource ĭon't forget to add the HasLightspeedRetailResources trait to your manufacturer resource too. For example: public function getLightspeedRetailResourceName(): string In getLightspeedRetailResourceName() you need to define the Lightspeed resource that represents your model. In the example below we put the manufacturer resource before the product resourceīecause we need the manufacturer id for when we are syncing the product. The order of the resources is the order of the synchronisation. In getLightspeedRetailResourceMapping() you want to map your model fields to the Lightspeed resource. You can add the HasLightspeedRetailResources trait and the AutomaticSynchronisationInterface interface to your model If you would like to automatically synchronise your data to Lightspeed, This is the same as the 'next' and 'previous' attributes as described in the Pagination API documentationĪutomatic model synchronisation The 'after' attribute will be empty on the last page and the 'before' attribute will be empty on the first page. $response = LightspeedRetailApi::api()->sale()->getWithPagination(null, ) To get the next page of the resource, add the 'after' token to your request. $response = LightspeedRetailApi::api()->sale()->getWithPagination() Use \TimothyDC\LightspeedRetailApi\Services\Lightspeed\ResourceSale The full details of on how pagination works, you can find in the Pagination API documentation $sales = LightspeedRetailApi::api()->sale()->get(null, ) Īs of V3 of the Lightspeed Retail API the pagination works cursor based. get sales sorted by timestamp in descending order get categories with their parent relation $categories = LightspeedRetailApi::api()->category()->get(null, ]) If you would like to filter the GET-results you can look at the query parameters API Feel free to add them yourself via a pull request! Note that not all resources are added (yet). $categories = LightspeedRetailApi::api()->category()->first(20) $categories = LightspeedRetailApi::api()->category()->get(20) ![]() $categories = LightspeedRetailApi::api()->category()->get(null, ) filter with GET with a limit and custom sorting (full details: ) $account = LightspeedRetailApi::api()->account()->get() All resources return a Laravel collection. If you would like to alter the redirect you may extend this controller. The SaveAccessTokenController will store the initial access token and make follow-up request for the refresh token.Īfterwards you will be redirected to RouteServiceProvider::HOME. use \TimothyDC\LightspeedRetailApi\Http\Controllers\SaveAccessTokenController Update your-redirect-uri with the redirect URI you entered in the API client. Register the following route in your routes/web.php. You provided when configuring your client information via the Lightspeed Retail API Client. Return redirect()->to(LightspeedRetailApi::redirectToAuthorizationPortal($scope)) Īfter requesting your initial access token you will be redirected to the Redirect URI Use TimothyDC\LightspeedRetailApi\Facades\LightspeedRetailApi Excellent deal! Via controller use TimothyDC\LightspeedRetailApi\Scope The command will ask you about the scope, and you will get an URL in return. Via command line $ php artisan retail:auth More information on the scopes can be found in the documentation. Choose a $scope from the options in TimothyDC\LightspeedRetailApi\Scope. You can manage the access level to your POS data via a scope. ![]() php artisan migrateīefore we can request an access token you need to connect your Retail POS to this app. The API tokens are stored in the database, by default. Php artisan vendor:publish -tag="lightspeed-api:migrations" Php artisan vendor:publish -tag="lightspeed-api:config" You can publish all resources, or you may choose to publish them separately: php artisan vendor:publish -tag="lightspeed-api" envĪfter your API client is approved you will receive a key and secret. Remember the value of your redirect URI, we will need it later on. The API client is developer friendly, you can set as your redirect URI. Register API clientīefore creating an API connection, you will need to sign up for an API client with Lightspeed Retail. ![]() Via Composer composer require timothydc/laravel-lightspeed-retail-apiįor general information on how to use the Lightspeed Retail API, refer to the official documentation.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |