Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9eb6bc7

Browse files
authored
Merge pull request #30 from grayloon/detach-storage
Detach Storage
2 parents 93d2aea + 94197bf commit 9eb6bc7

File tree

85 files changed

+88
-4497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+88
-4497
lines changed

.scrutinizer.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 88 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,28 @@
1313

1414
# Laravel - Magento API
1515

16-
A Magento 2 API Object Oriented wrapper for a Laravel application. This package also includes an optional opinionated storage system for consuming Magento 2 data in your Laravel application.
16+
A Magento 2 API Object Oriented wrapper for a Laravel application.
17+
18+
- [Installation](#installation)
19+
- [API Usage](#api-usage)
20+
- [Available Methods](#available-methods)
21+
- [Admin Token](#admin-token)
22+
- [Categories](#categories)
23+
- [Customer Token](#customer-token)
24+
- [Customers](#customers)
25+
- [Guest Cart](#guest-cart)
26+
- [Product Attributes](#product-attributes)
27+
- [Product Link Types](#product-link-types)
28+
- [Products](#products)
29+
- [Schema](#schema)
30+
- [Source Items](#source-items)
31+
1732

1833
## Installation
1934

20-
You can install the package via composer:
35+
Install this package via Composer:
2136

22-
```bash q
37+
```bash
2338
composer require grayloon/laravel-magento-api
2439
```
2540

@@ -28,20 +43,18 @@ Publish the config options:
2843
php artisan vendor:publish --provider="Grayloon\Magento\MagentoServiceProvider" --tag="config"
2944
```
3045

31-
Optional:
32-
If you are wanting to store the data from the Magento API and want to use our opinionated storage system, publish the migrations:
33-
```bash
34-
php artisan vendor:publish --provider="Grayloon\Magento\MagentoServiceProvider" --tag="migrations"
35-
```
36-
37-
> more configuration options are available in the [Manual Configuration Options](#manual-configuration-options) section.
38-
3946
Configure your Magento 2 API endpoint and token in your `.env` file:
4047
```
4148
MAGENTO_BASE_URL="https://mydomain.com"
4249
MAGENTO_ACCESS_TOKEN="client_access_token_here"
50+
51+
# Optional Config:
52+
MAGENTO_BASE_PATH="rest"
53+
MAGENTO_STORE_CODE="all"
54+
MAGENTO_API_VERSION="V1"
4355
```
4456

57+
> You can test your connection by running tinker, then: `(new \Grayloon\Magento\Magento)->api('schema')->show();`
4558
## API Usage
4659

4760
Example:
@@ -61,154 +74,123 @@ $response->serverError() : bool;
6174
$response->clientError() : bool;
6275
```
6376

64-
### Available Methods:
77+
## Available Methods:
6578

66-
#### Categories
79+
<a id="admin-token"></a>
80+
### Admin Token Integration (IntegrationAdminTokenServiceV1)
6781

68-
Get a list of all categories:
82+
`/V1/integration/admin/token`
83+
84+
Generate a admin token:
6985
```php
70-
$magento->api('categories')->all($pageSize = 50, $currentPage = 1, $filters = []);
86+
$magento->api('integration')->adminToken($username, $password);
7187
```
7288

73-
#### Customers
89+
<a id="categories"></a>
90+
### Categories (catalogCategoryManagementV1)
7491

75-
Get a list of customers:
92+
`/V1/categories`
93+
94+
Get a list of all categories:
7695
```php
77-
$magento->api('customers')->all($pageSize = 50, $currentPage = 1, $filters = []);
96+
$magento->api('categories')->all($pageSize = 50, $currentPage = 1, $filters = []);
7897
```
7998

80-
#### Integration (Tokens)
99+
<a id="customer-token"></a>
100+
### Customer Token Integration (IntegrationCustomerTokenServiceV1)
101+
102+
`/V1/integration/customer/token`
81103

82104
Generate a customer token:
83105
```php
84106
$magento->api('integration')->customerToken($username, $password);
85107
```
86108

87-
Generate an admin token:
88-
```php
89-
$magento->api('integration')->adminToken($username, $password);
90-
```
109+
<a id="customers"></a>
110+
### Customers (customerCustomerRepositoryV1)
91111

92-
#### Products
93-
Get a list of products:
94-
```php
95-
$magento->api('products')->all($pageSize = 50, $currentPage = 1, $filters = []);
96-
```
112+
`/V1/customers/search`
97113

98-
Get info about a product by the product SKU:
114+
Get a list of customers:
99115
```php
100-
$magento->api('products')->show($sku);
116+
$magento->api('customers')->all($pageSize = 50, $currentPage = 1, $filters = []);
101117
```
102118

103-
#### Product Attributes
104-
Retrieve specific product attribute information:
105-
```php
106-
$magento->api('productAttributes')->show($attributeCode);
107-
```
119+
<a id="guest-cart"></a>
120+
### Guest Cart
108121

109-
#### Product Link Types (catalogProductLinkTypeListV1)
110-
`/V1/products/links/types`
122+
`/V1/guest-carts`
111123

112-
Retrieve information about available product link types:
124+
Enable customer or guest user to create an empty cart and quote for an anonymous customer.
113125
```php
114-
$magento->api('productLinkType')->types();
126+
$magento->api('guestCarts')->create();
115127
```
116128

117-
#### Schema
118-
Get a schema blueprint of the Magento 2 REST API:
129+
`/V1/guest-carts/{cartId}`
130+
Return information for a specified cart.
119131
```php
120-
$magento->api('schema')->show();
132+
$magento->api('guestCarts')->cart($cartId);
121133
```
122134

123-
#### Source Items
124-
Get a list of paginated sort items (typically used for quantity retrieval):
135+
`/V1/guest-carts/{cartId}/items`
136+
137+
List items that are assigned to a specified cart.
125138
```php
126-
$magento->api('sourceItems')->all($pageSize = 50, $currentPage = 1, $filters = []);
139+
$magento->api('guestCarts')->items($cartId);
127140
```
128141

129-
## Manual Configuration Options
130-
131-
This package features additional configuration options which uses the Magento 2 default settings. You are more than welcome to change any of the values as you need fit in your application:
142+
<a id="product-attributes"></a>
143+
### Product Attributes (catalogProductAttributeRepositoryV1)
132144

133-
### Base API Path
145+
`/V1/products/attributes/{attributeCode}`
134146

135-
The Magento 2 REST API Base Path. By default, this is assigned as 'rest'. Developers should only update this setting if the path has changed:
136-
```
137-
MAGENTO_BASE_PATH='rest'
147+
Retrieve specific product attribute information:
148+
```php
149+
$magento->api('productAttributes')->show($attributeCode);
138150
```
139151

140-
### Magento Store Code
152+
<a id="product-link-types"></a>
153+
### Product Link Types (catalogProductLinkTypeListV1)
141154

142-
The Magento 2 REST API Store Code By default, this is assigned to 'all' specifying all magento stores on requests. Developers may update this to specify the API around a specific store code.
143-
```
144-
MAGENTO_STORE_CODE='all'
145-
```
146-
147-
### Magento API Version
155+
`/V1/products/links/types`
148156

149-
The Magento 2 REST API Version. By default, Magento 2 sets this to 'V1'. Developers should only update this setting if the version has changed.
150-
```
151-
MAGENTO_API_VERSION='V1'
157+
Retrieve information about available product link types:
158+
```php
159+
$magento->api('productLinkType')->types();
152160
```
153161

154-
## Jobs
155-
156-
> In order use these queue jobs, you must have registered the migrations from the installation section noted above.
162+
<a id="products"></a>
163+
### Products (catalogProductRepositoryV1)
157164

158-
This package has many pre-built queue jobs to sync your Magento products to your Laravel application. Feel free to leverage these jobs or create your own.
165+
`/V1/products`
159166

160-
Updates all products from the Magento API:
167+
Get a list of products:
161168
```php
162-
Bus::dispatch(\Grayloon\Magento\Jobs\SyncMagentoProducts::class);
169+
$magento->api('products')->all($pageSize = 50, $currentPage = 1, $filters = []);
163170
```
164171

165-
Updates a specified product from the Magento API:
166-
```php
167-
Bus::dispatch(\Grayloon\Magento\Jobs\SyncMagentoProduct::class, $sku);
168-
```
172+
`/V1/products/{sku}`
169173

170-
Updates all categories from the Magento API:
174+
Get info about a product by the product SKU:
171175
```php
172-
Bus::dispatch(\Grayloon\Magento\Jobs\SyncMagentoCategories::class);
173-
```
174-
175-
176-
## API / Webhooks
177-
178-
> In order use these api routes, you must have registered the migrations from the installation section noted above.
179-
180-
This package has included routes to automatically update Magento information from the API. These can be utilized with Magento Webhooks to keep your items in sync.
181-
182-
> All routes are guarded by the default `API` Laravel middleware.
183-
184-
Fire the `SyncMagentoProduct($sku)` job to update a specified product SKU:
185-
```
186-
/api/laravel-magento-api/products/update/{sku}
176+
$magento->api('products')->show($sku);
187177
```
188178

179+
<a id="schema"></a>
180+
### Schema
189181

190-
## Commands
191-
192-
> In order use these commands, you must have registered the migrations from the installation section noted above.
193-
194-
Launch a job to import all categories from the Magento 2 REST API:
195-
```bash
196-
php artisan magento:sync-categories
182+
Get a schema blueprint of the Magento 2 REST API:
183+
```php
184+
$magento->api('schema')->show();
197185
```
198186

199-
Launch a job to import all customers from the Magento 2 REST API:
200-
```bash
201-
php artisan magento:sync-customers
202-
```
187+
### Source Items (inventoryApiSourceItemRepositoryV1)
203188

204-
Launch a job to import all products from the Magento 2 REST API:
205-
```bash
206-
php artisan magento:sync-products
207-
```
189+
`/V1/inventory/source-items`
208190

209-
Launch a job to import all product link types from the Magento 2 REST API:
210-
```bash
211-
php artisan magento:sync-product-link-types
191+
Get a list of paginated sort items (typically used for quantity retrieval):
192+
```php
193+
$magento->api('sourceItems')->all($pageSize = 50, $currentPage = 1, $filters = []);
212194
```
213195

214196
## Testing

src/Console/SyncMagentoCategoriesCommand.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/Console/SyncMagentoCustomersCommand.php

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)