e_plat 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +631 -131
- data/lib/active_resource/connection_error.rb +29 -0
- data/lib/active_resource/formats.rb +27 -0
- data/lib/current.rb +1 -1
- data/lib/e_plat/client/default_request_args.rb +27 -3
- data/lib/e_plat/client.rb +114 -87
- data/lib/e_plat/connection.rb +4 -0
- data/lib/e_plat/mapping/base.rb +119 -12
- data/lib/e_plat/mapping/bigcommerce/v_3/metafield.rb +62 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/order/billing_address.rb +14 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/order/line_item.rb +85 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/order/shipping_address.rb +73 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/order.rb +160 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/product/image.rb +12 -12
- data/lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb +1 -1
- data/lib/e_plat/mapping/bigcommerce/v_3/script_tag.rb +78 -0
- data/lib/e_plat/mapping/bigcommerce/v_3/shop.rb +11 -6
- data/lib/e_plat/mapping/bigcommerce/v_3/webhook.rb +54 -0
- data/lib/e_plat/mapping/request_body_root.rb +38 -0
- data/lib/e_plat/mapping/shopify/v_2024_01/metafield.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2024_01/order/billing_address.rb +14 -0
- data/lib/e_plat/mapping/shopify/v_2024_01/order/shipping_address.rb +30 -0
- data/lib/e_plat/mapping/shopify/{v_2022_07/product.rb → v_2024_01/order.rb} +3 -3
- data/lib/e_plat/mapping/shopify/{v_2022_07 → v_2024_01}/product/image.rb +1 -1
- data/lib/e_plat/mapping/shopify/{v_2022_07 → v_2024_01}/product/variant.rb +2 -1
- data/lib/e_plat/mapping/shopify/v_2024_01/product.rb +26 -0
- data/lib/e_plat/mapping/shopify/v_2024_01/script_tag.rb +26 -0
- data/lib/e_plat/mapping/shopify/{v_2022_07 → v_2024_01}/shop.rb +1 -1
- data/lib/e_plat/mapping/shopify/v_2024_01/webhook.rb +29 -0
- data/lib/e_plat/mapping/virtual_collection/base.rb +14 -0
- data/lib/e_plat/mapping/virtual_collection/bigcommerce/order_line_items.rb +297 -0
- data/lib/e_plat/mapping.rb +3 -3
- data/lib/e_plat/resource/attribute_interface.rb +28 -28
- data/lib/e_plat/resource/base.rb +107 -66
- data/lib/e_plat/resource/collection.rb +92 -0
- data/lib/e_plat/resource/concerns/aliases.rb +102 -18
- data/lib/e_plat/resource/concerns/dirty.rb +54 -0
- data/lib/e_plat/resource/concerns/metafieldable.rb +43 -0
- data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +108 -6
- data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +73 -37
- data/lib/e_plat/resource/countable.rb +43 -0
- data/lib/e_plat/resource/metafield.rb +70 -0
- data/lib/e_plat/resource/order/Consignment.rb +8 -0
- data/lib/e_plat/resource/order/billing_address.rb +6 -0
- data/lib/e_plat/resource/order/fulfillment.rb +1 -0
- data/lib/e_plat/resource/order/line_item.rb +1 -0
- data/lib/e_plat/resource/order/shipping_address.rb +44 -0
- data/lib/e_plat/resource/order/shipping_line.rb +15 -14
- data/lib/e_plat/resource/order.rb +32 -0
- data/lib/e_plat/resource/paginated/link_headers.rb +42 -0
- data/lib/e_plat/resource/paginated/link_params.rb +26 -0
- data/lib/e_plat/resource/product/image.rb +6 -0
- data/lib/e_plat/resource/product/option.rb +1 -0
- data/lib/e_plat/resource/product/variant.rb +8 -12
- data/lib/e_plat/resource/product.rb +8 -2
- data/lib/e_plat/resource/script_tag.rb +56 -0
- data/lib/e_plat/resource/shop.rb +17 -13
- data/lib/e_plat/resource/shopify_only/recurring_application_charge/usage_charge.rb +32 -0
- data/lib/e_plat/resource/shopify_only/recurring_application_charge.rb +47 -0
- data/lib/e_plat/resource/webhook.rb +50 -0
- data/lib/e_plat/session.rb +10 -7
- data/lib/e_plat/type_coercer.rb +15 -17
- data/lib/e_plat/version.rb +1 -1
- data/lib/e_plat.rb +14 -4
- metadata +67 -7
- data/lib/e_plat/resource/order/customer.rb +0 -37
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Goals are:
|
|
23
23
|
<img src="mascot.png" width="350" title="hover text" alt="EPlat Platypus">
|
24
24
|
</p>
|
25
25
|
|
26
|
+
<br>
|
26
27
|
|
27
28
|
## Installation
|
28
29
|
|
@@ -34,19 +35,21 @@ To your gemfile and then run
|
|
34
35
|
|
35
36
|
$ bundle
|
36
37
|
|
38
|
+
<br>
|
37
39
|
|
38
40
|
## Config
|
39
41
|
You can configure which platform APIs are used by updating the EPlat config: <br/>
|
40
42
|
```ruby
|
41
43
|
#initializers/e_plat.rb
|
42
|
-
EPlat.config.shopify_api_version = "
|
44
|
+
EPlat.config.shopify_api_version = "2024-01"
|
43
45
|
EPlat.config.bigcommerce_api_version = "v3"
|
44
46
|
EPlat.config.woocommerce_api_version = "v3"
|
45
47
|
```
|
48
|
+
<br>
|
46
49
|
|
47
50
|
## Relasing new version
|
48
51
|
https://dev.to/doctolib/release-a-new-gem-version-je0
|
49
|
-
|
52
|
+
<br>
|
50
53
|
|
51
54
|
## Usage
|
52
55
|
|
@@ -56,7 +59,7 @@ EPlat::Session.new(
|
|
56
59
|
platform: :shopify,
|
57
60
|
store_url: "test-store.myshopify.com",
|
58
61
|
api_token: "123",
|
59
|
-
# store_hash:
|
62
|
+
# store_hash: optional BigCommerce store hash
|
60
63
|
)
|
61
64
|
```
|
62
65
|
|
@@ -70,6 +73,25 @@ EPlat::Product.find(id: 123)
|
|
70
73
|
EPlat::Product
|
71
74
|
```
|
72
75
|
|
76
|
+
EPlat is designed to let you mostly use it's universal interface, but then easily interact with non supported platform attributes when needed.
|
77
|
+
```ruby
|
78
|
+
tag = EPlat::ScriptTag.new(
|
79
|
+
display_scope: :online_store,
|
80
|
+
event: :onload,
|
81
|
+
src: "https://preproduct.io/mini-script.js"
|
82
|
+
)
|
83
|
+
tag.name = "mini script" if Current.e_plat_session.bigcommerce?
|
84
|
+
tag.save
|
85
|
+
|
86
|
+
# ...when session is a Shopify store
|
87
|
+
# POST https://preproduct-test.myshopify.com/admin/api/2024-01/script_tags.json
|
88
|
+
# body: '{"script_tag":{"display_scope":"online_store","event":"onload","src":"https://preproduct.io/mini-script.js"}}'
|
89
|
+
#
|
90
|
+
# ...when session is a BigCommerce store
|
91
|
+
# POST https://api.bigcommerce.com/stores/d0kmq3bory/v3/content/scripts
|
92
|
+
# body: {"location":"head","auto_uninstall":true,"kind":"src","load_method":"async","name":"mini script","enabled":true,"visibility":"storefront","event":"onload","src":"https://preproduct.io/mini-script.js"}
|
93
|
+
```
|
94
|
+
<br>
|
73
95
|
|
74
96
|
## Under The Hood
|
75
97
|
|
@@ -89,12 +111,12 @@ EPlat::Product
|
|
89
111
|
</li>
|
90
112
|
<li>
|
91
113
|
The EPlat alias interface is just a set of dynamically created getter/setter/predicate methods with types that control the native attributes of the resource.
|
92
|
-
You can check if an attribute has been mapped by calling
|
114
|
+
You can check if an attribute has been mapped by calling `resource.mapped? "attribute_name"`
|
93
115
|
</li>
|
94
116
|
</ul>
|
95
117
|
</ol>
|
96
118
|
|
97
|
-
|
119
|
+
<br>
|
98
120
|
|
99
121
|
|
100
122
|
## EPlat Alias Interface
|
@@ -102,16 +124,16 @@ EPlat::Product
|
|
102
124
|
<details>
|
103
125
|
<summary>Shop</summary>
|
104
126
|
|
105
|
-
###
|
127
|
+
### EPlat::Shop
|
106
128
|
|
107
|
-
|
|
129
|
+
| Alias | Type | Shopify | BigCommerce| Etc |
|
108
130
|
| ------------------------------------ | --------- | ------- | -----------| ------------|
|
109
|
-
| id | integer | * |
|
110
|
-
| name | string | * |
|
111
|
-
| email | string | * |
|
112
|
-
| domain | string | * |
|
113
|
-
| province | string | * |
|
114
|
-
| country | string | * |
|
131
|
+
| id | integer | * | nil | nil |
|
132
|
+
| name | string | * | name | nil |
|
133
|
+
| email | string | * | admin_email| nil |
|
134
|
+
| domain | string | * | domain | nil |
|
135
|
+
| province | string | * | nil | nil |
|
136
|
+
| country | string | * | country | nil |
|
115
137
|
| address1 | string | * | nil | nil |
|
116
138
|
| zip | string | * | nil | nil |
|
117
139
|
| city | string | * | nil | nil |
|
@@ -123,30 +145,30 @@ EPlat::Product
|
|
123
145
|
| address2 | string | * | nil | nil |
|
124
146
|
| created_at | datetime | * | nil | nil |
|
125
147
|
| updated_at | datetime | * | nil | nil |
|
126
|
-
| country_code | string | * |
|
148
|
+
| country_code | string | * | country_code | nil |
|
127
149
|
| country_name | string | * | nil | nil |
|
128
|
-
| currency | string | * |
|
150
|
+
| currency | string | * | currency_symbol | nil |
|
129
151
|
| customer_email | string | * | nil | nil |
|
130
152
|
| timezone | string | * | nil | nil |
|
131
153
|
| iana_timezone | string | * | nil | nil |
|
132
154
|
| shop_owner | string | * | nil | nil |
|
133
155
|
| money_format | string | * | nil | nil |
|
134
156
|
| money_with_currency_format | string | * | nil | nil |
|
135
|
-
| weight_unit | string | * |
|
157
|
+
| weight_unit | string | * | weight_unit| nil |
|
136
158
|
| province_code | string | * | nil | nil |
|
137
159
|
| taxes_included | boolean | * | nil | nil |
|
138
160
|
| auto_configure_tax_inclusivity | boolean | * | nil | nil |
|
139
161
|
| tax_shipping | boolean | * | nil | nil |
|
140
162
|
| county_taxes | boolean | * | nil | nil |
|
141
163
|
| plan_display_name | string | * | nil | nil |
|
142
|
-
| plan_name | string | * |
|
164
|
+
| plan_name | string | * | plan_name | nil |
|
143
165
|
| has_discounts | boolean | * | nil | nil |
|
144
166
|
| has_gift_cards | boolean | * | nil | nil |
|
145
|
-
| myshopify_domain | string | * |
|
167
|
+
| myshopify_domain | string | * | control_panel_base_url | nil |
|
146
168
|
| google_apps_domain | string | * | nil | nil |
|
147
169
|
| google_apps_login_enabled | boolean | * | nil | nil |
|
148
170
|
| money_in_emails_format | string | * | nil | nil |
|
149
|
-
| money_with_currency_in_emails_format| string | * | nil | nil |
|
171
|
+
| money_with_currency_in_emails_format | string | * | nil | nil |
|
150
172
|
| eligible_for_payments | boolean | * | nil | nil |
|
151
173
|
| requires_extra_payments_agreement | boolean | * | nil | nil |
|
152
174
|
| password_enabled | boolean | * | nil | nil |
|
@@ -162,81 +184,80 @@ EPlat::Product
|
|
162
184
|
| pre_launch_enabled | boolean | * | nil | nil |
|
163
185
|
| enabled_presentment_currencies | array | * | nil | nil |
|
164
186
|
| transactional_sms_disabled | boolean | * | nil | nil |
|
165
|
-
| marketing_sms_consent_enabled_at_checkout | boolean | * | nil | nil
|
187
|
+
| marketing_sms_consent_enabled_at_checkout | boolean | * | nil | nil |
|
188
|
+
|
189
|
+
```ruby
|
190
|
+
# Bigcommerce translation. myshopify_domain is a permanent
|
191
|
+
shop.myshopify_domain #"store-#{ store_hash }.mybigcommerce.com"
|
192
|
+
shop.domain # custom_domain.com
|
193
|
+
```
|
166
194
|
|
167
195
|
</details>
|
168
|
-
|
196
|
+
|
169
197
|
<details>
|
170
198
|
<summary>Product</summary>
|
171
199
|
|
172
|
-
|
200
|
+
### EPlat::Product
|
173
201
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
| body_html | string | * |
|
177
|
-
| created_at | datetime | * |
|
178
|
-
| handle | string | * |
|
179
|
-
| id | integer | * |
|
180
|
-
| images | array | * |
|
181
|
-
| options | array | * |
|
182
|
-
| product_type | string | * |
|
183
|
-
| published_at | datetime | * | nil
|
184
|
-
| published_scope | string | * | nil
|
185
|
-
| status | string | * |
|
186
|
-
| tags | string | * | nil
|
187
|
-
| admin_graphql_api_id | string | * | nil
|
188
|
-
| template_suffix | string | * | nil
|
189
|
-
| title | string | * |
|
190
|
-
| updated_at | datetime | * |
|
191
|
-
| variants | array | * |
|
192
|
-
| vendor | string | * | nil
|
202
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
203
|
+
| ------------------------ | -------- | ------- | -------------| ------------|
|
204
|
+
| body_html | string | * | description | nil |
|
205
|
+
| created_at | datetime | * | date_created | nil |
|
206
|
+
| handle | string | * | name | nil |
|
207
|
+
| id | integer | * | id | nil |
|
208
|
+
| images | array | * | * | nil |
|
209
|
+
| options | array | * | * | nil |
|
210
|
+
| product_type | string | * | type | nil |
|
211
|
+
| published_at | datetime | * | nil | nil |
|
212
|
+
| published_scope | string | * | nil | nil |
|
213
|
+
| status | string | * | availability | nil |
|
214
|
+
| tags | string | * | nil | nil |
|
215
|
+
| admin_graphql_api_id | string | * | nil | nil |
|
216
|
+
| template_suffix | string | * | nil | nil |
|
217
|
+
| title | string | * | name | nil |
|
218
|
+
| updated_at | datetime | * | date_modified| nil |
|
219
|
+
| variants | array | * | * | nil |
|
220
|
+
| vendor | string | * | nil | nil |
|
193
221
|
|
194
|
-
</details>
|
195
|
-
</br>
|
196
|
-
<details>
|
197
|
-
<summary>Product Variant</summary>
|
198
222
|
|
199
|
-
|
223
|
+
### EPlat::Product::Variant
|
224
|
+
|
200
225
|
|
201
|
-
|
|
202
|
-
| --------------------- | -------- | ------- |
|
203
|
-
| id | integer | * |
|
204
|
-
| product_id | integer | * |
|
205
|
-
| title | string | * | nil
|
206
|
-
| price | string | * |
|
207
|
-
| sku | string | * |
|
208
|
-
| position | integer | * | nil
|
209
|
-
| inventory_policy | string | * | nil
|
210
|
-
| compare_at_price | string | * | nil
|
211
|
-
| fulfillment_service | string | * | nil
|
212
|
-
| inventory_management | string | * | nil
|
213
|
-
| option1 | string | * |
|
214
|
-
| option2 | string | * | nil
|
215
|
-
| option3 | string | * | nil
|
216
|
-
| created_at | datetime | * |
|
217
|
-
| updated_at | datetime | * |
|
218
|
-
| taxable | boolean | * | nil
|
219
|
-
| barcode | string | * | nil
|
220
|
-
| grams | integer | * | nil
|
221
|
-
| image_id | integer | * | nil
|
222
|
-
| weight | float | * |
|
223
|
-
| weight_unit | string | * | nil
|
224
|
-
| inventory_item_id | integer | * | nil
|
225
|
-
| inventory_quantity | integer | * |
|
226
|
-
| old_inventory_quantity| integer | * | nil
|
227
|
-
| presentment_prices | array | * | nil
|
228
|
-
| tax_code | string | * | nil
|
229
|
-
| requires_shipping | boolean | * | nil
|
230
|
-
| admin_graphql_api_id | string | * | nil
|
226
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
227
|
+
| --------------------- | -------- | ------- | ----------------------| ------------|
|
228
|
+
| id | integer | * | id | nil |
|
229
|
+
| product_id | integer | * | product_id | nil |
|
230
|
+
| title | string | * | nil | nil |
|
231
|
+
| price | string | * | price | nil |
|
232
|
+
| sku | string | * | sku | nil |
|
233
|
+
| position | integer | * | nil | nil |
|
234
|
+
| inventory_policy | string | * | nil | nil |
|
235
|
+
| compare_at_price | string | * | nil | nil |
|
236
|
+
| fulfillment_service | string | * | nil | nil |
|
237
|
+
| inventory_management | string | * | nil | nil |
|
238
|
+
| option1 | string | * | option_values[0].label| nil |
|
239
|
+
| option2 | string | * | nil | nil |
|
240
|
+
| option3 | string | * | nil | nil |
|
241
|
+
| created_at | datetime | * | nil | nil |
|
242
|
+
| updated_at | datetime | * | nil | nil |
|
243
|
+
| taxable | boolean | * | nil | nil |
|
244
|
+
| barcode | string | * | nil | nil |
|
245
|
+
| grams | integer | * | nil | nil |
|
246
|
+
| image_id | integer | * | nil | nil |
|
247
|
+
| weight | float | * | weight | nil |
|
248
|
+
| weight_unit | string | * | nil | nil |
|
249
|
+
| inventory_item_id | integer | * | nil | nil |
|
250
|
+
| inventory_quantity | integer | * | inventory_level | nil |
|
251
|
+
| old_inventory_quantity| integer | * | nil | nil |
|
252
|
+
| presentment_prices | array | * | nil | nil |
|
253
|
+
| tax_code | string | * | nil | nil |
|
254
|
+
| requires_shipping | boolean | * | nil | nil |
|
255
|
+
| admin_graphql_api_id | string | * | nil | nil |
|
231
256
|
|
232
|
-
</details>
|
233
|
-
</br>
|
234
|
-
<details>
|
235
|
-
<summary>Product Option</summary>
|
236
|
-
|
237
|
-
### Mapped Aliases
|
238
257
|
|
239
|
-
|
258
|
+
### EPlat::Product::Option
|
259
|
+
|
260
|
+
| Alias | Type | Shopify | BigCommerce| Etc |
|
240
261
|
| --------- | -------- | ------- | -----------| ------------|
|
241
262
|
| id | integer | * | nil | nil |
|
242
263
|
| product_id| integer | * | nil | nil |
|
@@ -244,51 +265,513 @@ EPlat::Product
|
|
244
265
|
| position | integer | * | nil | nil |
|
245
266
|
| values | array | * | nil | nil |
|
246
267
|
|
268
|
+
|
269
|
+
### EPlat::Product::Image
|
270
|
+
|
271
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
272
|
+
| -------------------- | -------- | ------- | ----------- | ------------|
|
273
|
+
| id | integer | * | id | nil |
|
274
|
+
| product_id | integer | * | product_id | nil |
|
275
|
+
| position | integer | * | nil | nil |
|
276
|
+
| created_at | datetime | * | date_created | nil |
|
277
|
+
| updated_at | datetime | * | date_modified| nil |
|
278
|
+
| alt | string | * | nil | nil |
|
279
|
+
| width | integer | * | nil | nil |
|
280
|
+
| height | integer | * | nil | nil |
|
281
|
+
| src | string | * | url_standard | nil |
|
282
|
+
| variant_ids | array | * | nil | nil |
|
283
|
+
| admin_graphql_api_id | string | * | nil | nil |
|
284
|
+
|
247
285
|
</details>
|
248
|
-
|
286
|
+
|
249
287
|
<details>
|
250
|
-
<summary>
|
288
|
+
<summary>Order</summary>
|
289
|
+
|
290
|
+
### EPlat::Order
|
291
|
+
|
292
|
+
| attribute_name | type | Shopify | BigCommerce | Etc |
|
293
|
+
|--------------------------------------|----------|---------|-------------|-------------|
|
294
|
+
| id | integer | * | id | nil |
|
295
|
+
| app_id | integer | * | nil | nil |
|
296
|
+
| billing_address_address1 | string | * | nil | nil |
|
297
|
+
| billing_address_address2 | string | * | nil | nil |
|
298
|
+
| billing_address_city | string | * | nil | nil |
|
299
|
+
| billing_address_company | string | * | nil | nil |
|
300
|
+
| billing_address_country | string | * | nil | nil |
|
301
|
+
| billing_address_first_name | string | * | nil | nil |
|
302
|
+
| billing_address_last_name | string | * | nil | nil |
|
303
|
+
| billing_address_phone | string | * | nil | nil |
|
304
|
+
| billing_address_province | string | * | nil | nil |
|
305
|
+
| billing_address_zip | string | * | nil | nil |
|
306
|
+
| billing_address_name | string | * | nil | nil |
|
307
|
+
| billing_address_province_code | string | * | nil | nil |
|
308
|
+
| billing_address_country_code | string | * | nil | nil |
|
309
|
+
| billing_address_latitude | string | * | nil | nil |
|
310
|
+
| billing_address_longitude | string | * | nil | nil |
|
311
|
+
| browser_ip | string | * | nil | nil |
|
312
|
+
| buyer_accepts_marketing | boolean | * | nil | nil |
|
313
|
+
| cancel_reason | string | * | nil | nil |
|
314
|
+
| cancelled_at | datetime | * | nil | nil |
|
315
|
+
| cart_token | string | * | nil | nil |
|
316
|
+
| checkout_token | string | * | nil | nil |
|
317
|
+
| client_details | hash | * | nil | nil |
|
318
|
+
| closed_at | datetime | * | nil | nil |
|
319
|
+
| created_at | datetime | * | date_created | nil |
|
320
|
+
| currency | string | * | currency_code | nil |
|
321
|
+
| current_total_discounts | string | * | discount_amount | nil |
|
322
|
+
| current_total_discounts_set | hash | * | nil | nil |
|
323
|
+
| current_total_duties_set | hash | * | nil | nil |
|
324
|
+
| current_total_price | string | * | nil | nil |
|
325
|
+
| current_total_price_set | hash | * | nil | nil |
|
326
|
+
| current_subtotal_price | string | * | nil | nil |
|
327
|
+
| current_subtotal_price_set | hash | * | nil | nil |
|
328
|
+
| current_total_tax | string | * | nil | nil |
|
329
|
+
| current_total_tax_set | hash | * | nil | nil |
|
330
|
+
| customer_locale | string | * | customer_locale | nil |
|
331
|
+
| device_id | integer | * | nil | nil |
|
332
|
+
| discount_codes | array | * | nil | nil |
|
333
|
+
| email | string | * | billing_address[email]| nil |
|
334
|
+
| estimated_taxes | boolean | * | nil | nil |
|
335
|
+
| financial_status | string | * | status_id | nil |
|
336
|
+
| fulfillment_status | string | * | nil | nil |
|
337
|
+
| gateway | string | * | nil | nil |
|
338
|
+
| landing_site | string | * | nil | nil |
|
339
|
+
| landing_site_ref | string | * | nil | nil |
|
340
|
+
| location_id | integer | * | nil | nil |
|
341
|
+
| merchant_of_record_app_id | integer | * | nil | nil |
|
342
|
+
| name | string | * | nil | nil |
|
343
|
+
| note | string | * | staff_notes | nil |
|
344
|
+
| note_attributes | array | * | nil | nil |
|
345
|
+
| number | integer | * | nil | nil |
|
346
|
+
| order_number | integer | * | nil | nil |
|
347
|
+
| order_status_url | string | * | nil | nil |
|
348
|
+
| original_total_duties_set | hash | * | nil | nil |
|
349
|
+
| payment_gateway_names | array | * | nil | nil |
|
350
|
+
| phone | string | * | nil | nil |
|
351
|
+
| presentment_currency | string | * | nil | nil |
|
352
|
+
| processed_at | string | * | nil | nil |
|
353
|
+
| processing_method | string | * | nil | nil |
|
354
|
+
| reference | string | * | nil | nil |
|
355
|
+
| referring_site | string | * | nil | nil |
|
356
|
+
| source_identifier | string | * | nil | nil |
|
357
|
+
| source_name | string | * | nil | nil |
|
358
|
+
| source_url | string | * | nil | nil |
|
359
|
+
| subtotal_price | string | * | subtotal_ex_tax | nil |
|
360
|
+
| subtotal_price_set | hash | * | nil | nil |
|
361
|
+
| tags | string | * | nil | nil |
|
362
|
+
| tax_lines | array | * | nil | nil |
|
363
|
+
| taxes_included | boolean | * | nil | nil |
|
364
|
+
| test | boolean | * | nil | nil |
|
365
|
+
| token | string | * | nil | nil |
|
366
|
+
| total_discounts | string | * | nil | nil |
|
367
|
+
| total_discounts_set | hash | * | nil | nil |
|
368
|
+
| total_line_items_price | string | * | nil | nil |
|
369
|
+
| total_line_items_price_set | hash | * | nil | nil |
|
370
|
+
| total_outstanding | string | * | nil | nil |
|
371
|
+
| total_price | string | * | total_inc_tax | nil |
|
372
|
+
| total_price_set | hash | * | nil | nil |
|
373
|
+
| total_shipping_price_set | hash | * | nil | nil |
|
374
|
+
| total_tax | string | * | total_tax | nil |
|
375
|
+
| total_tax_set | hash | * | nil | nil |
|
376
|
+
| total_tip_received | string | * | nil | nil |
|
377
|
+
| total_weight | integer | * | nil | nil |
|
378
|
+
| updated_at | datetime | * | date_modified | nil |
|
379
|
+
| billing_address | hash | * | billing_address | nil |
|
380
|
+
| customer | hash | * | nil | nil |
|
381
|
+
| discount_applications | array | * | nil | nil |
|
382
|
+
| fulfillments | array | * | nil | nil |
|
383
|
+
| line_items | array | * | nil | nil |
|
384
|
+
| payment_details | hash | * | nil | nil |
|
385
|
+
| payment_terms | hash | * | nil | nil |
|
386
|
+
| refunds | array | * | nil | nil |
|
387
|
+
| shipping_address | hash | * | nil | nil |
|
388
|
+
| shipping_lines | array | * | nil | nil |
|
389
|
+
|
390
|
+
### EPlat::Order::ShippingAddress
|
391
|
+
|
392
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
393
|
+
|---------------|---------|---------|-------------|-------------|
|
394
|
+
| address1 | string | * | street_1 | nil |
|
395
|
+
| address2 | string | * | street_2 | nil |
|
396
|
+
| city | string | * | city | nil |
|
397
|
+
| company | string | * | company | nil |
|
398
|
+
| country | string | * | country | nil |
|
399
|
+
| first_name | string | * | first_name | nil |
|
400
|
+
| last_name | string | * | last_name | nil |
|
401
|
+
| phone | string | * | phone | nil |
|
402
|
+
| province | string | * | state | nil |
|
403
|
+
| zip | string | * | zip | nil |
|
404
|
+
| country_code | string | * | country_iso2| nil |
|
405
|
+
| province_code | string | * | nil | nil |
|
406
|
+
| latitude | float | * | nil | nil |
|
407
|
+
| longitude | float | * | nil | nil |
|
408
|
+
|
409
|
+
|
410
|
+
### EPlat::Order::LineItem
|
411
|
+
|
412
|
+
| Attribute | Type | Shopify | BigCommerce | Etc |
|
413
|
+
|-------------------------------|---------|---------|-------------|------|
|
414
|
+
| id | integer | * | order[consignments][0][shipping][0][line_items][#{i}][id] | nil |
|
415
|
+
| admin_graphql_api_id | string | * | nil | nil |
|
416
|
+
| fulfillable_quantity | integer | * | nil | nil |
|
417
|
+
| fulfillment_service | string | * | nil | nil |
|
418
|
+
| fulfillment_status | string | * | nil | nil |
|
419
|
+
| gift_card | boolean | * | nil | nil |
|
420
|
+
| grams | integer | * | nil | nil |
|
421
|
+
| name | string | * | order[consignments][0][shipping][0][line_items][#{i}][name] | nil |
|
422
|
+
| price | string | * | order[consignments][0][shipping][0][line_items][#{i}][price] | nil |
|
423
|
+
| price_set | hash | * | nil | nil |
|
424
|
+
| product_exists | boolean | * | nil | nil |
|
425
|
+
| product_id | integer | * | order[consignments][0][shipping][0][line_items][#{i}][product_id] | nil |
|
426
|
+
| properties | array | * | nil | nil |
|
427
|
+
| quantity | integer | * | order[consignments][0][shipping][0][line_items][#{i}][quantity] | nil |
|
428
|
+
| requires_shipping | boolean | * | nil | nil |
|
429
|
+
| sku | string | * | order[consignments][0][shipping][0][line_items][#{i}][sku] | nil |
|
430
|
+
| taxable | boolean | * | nil | nil |
|
431
|
+
| title | string | * | nil | nil |
|
432
|
+
| total_discount | string | * | nil | nil |
|
433
|
+
| total_discount_set | hash | * | nil | nil |
|
434
|
+
| variant_id | integer | * | order[consignments][0][shipping][0][line_items][#{i}][variant_id] | nil |
|
435
|
+
| variant_inventory_management | string | * | nil | nil |
|
436
|
+
| variant_title | string | * | nil | nil |
|
437
|
+
| vendor | string | * | nil | nil |
|
438
|
+
| tax_lines | array | * | nil | nil |
|
439
|
+
| duties | array | * | nil | nil |
|
440
|
+
| discount_allocations | array | * | nil | nil |
|
441
|
+
|
442
|
+
*line_item uses a virtual collection for BigCommerce, this allows us to present with the correct nesting position, whilst updating the native much deeper nested set below
|
443
|
+
|
444
|
+
</details>
|
251
445
|
|
252
|
-
### Mapped Aliases
|
253
446
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
| position | integer | * | nil | nil |
|
259
|
-
| created_at | datetime | * | * | nil |
|
260
|
-
| updated_at | datetime | * | * | nil |
|
261
|
-
| alt | string | * | nil | nil |
|
262
|
-
| width | integer | * | nil | nil |
|
263
|
-
| height | integer | * | nil | nil |
|
264
|
-
| src | string | * | * | nil |
|
265
|
-
| variant_ids | array | * | nil | nil |
|
266
|
-
| admin_graphql_api_id | string | * | nil | nil |
|
447
|
+
</details>
|
448
|
+
|
449
|
+
<details>
|
450
|
+
<summary> Metafield </summary>
|
267
451
|
|
452
|
+
### EPlat::Metafield
|
453
|
+
|
454
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
455
|
+
|-----------------|----------|----------------|----------------|-----|
|
456
|
+
| created_at | datetime | * | date_created | nil |
|
457
|
+
| description | string | * | description | nil |
|
458
|
+
| id | integer | * | id | nil |
|
459
|
+
| key | string | * | key | nil |
|
460
|
+
| namespace | string | * | namespace | nil |
|
461
|
+
| owner_id | integer | * | resource_id | nil |
|
462
|
+
| owner_resource | string | * | resource_type | nil |
|
463
|
+
| updated_at | datetime | * | date_modified | nil |
|
464
|
+
| value | string | * | value | nil |
|
465
|
+
| type | string | * | nil | nil |
|
466
|
+
|
467
|
+
*Note: Bigcommerce always assumes a type of String and a native attribute permission_set of "read_and_sf_access"
|
468
|
+
|
469
|
+
</details>
|
470
|
+
|
471
|
+
<details>
|
472
|
+
<summary> ScriptTag </summary>
|
473
|
+
|
474
|
+
### EPlat::ScriptTag
|
475
|
+
|
476
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
477
|
+
|---------------|----------------|---------------|--------------------|-------------------|
|
478
|
+
| id | integer/string | id | uuid | |
|
479
|
+
| src | string | src | src | |
|
480
|
+
| created_at | datetime | created_at | date_created | |
|
481
|
+
| updated_at | datetime | updated_at | date_modified | |
|
482
|
+
| display_scope | string | display_scope | visibility | |
|
483
|
+
| event | string | event | nil | |
|
484
|
+
| cache | boolean | cache | nil | |
|
485
|
+
|
486
|
+
*display_scope available options: `online_store`, `order_status`, `all`
|
487
|
+
|
488
|
+
**Bigcommerce has some native attribute defaults set, which can be overwritten if needed:
|
489
|
+
`location: "head"`, `auto_uninstall: true`, `kind: "src"`, `load_method: "async"`, `name: "app-script"`, `enabled: true`
|
490
|
+
|
491
|
+
|
492
|
+
</details>
|
493
|
+
|
494
|
+
<details>
|
495
|
+
<summary> Webhook </summary>
|
496
|
+
|
497
|
+
### EPlat::Webhook
|
498
|
+
|
499
|
+
| Alias | Type | Shopify | BigCommerce | Etc |
|
500
|
+
|-------------------------------|--------------|------------------------------|----------------------|-----|
|
501
|
+
| address | string | address | destination | |
|
502
|
+
| api_version | string | api_version | nil | |
|
503
|
+
| created_at | datetime/Int | created_at | created_at | |
|
504
|
+
| fields | array | fields | nil | |
|
505
|
+
| format | string | format | nil | |
|
506
|
+
| id | integer | id | id | |
|
507
|
+
| metafield_namespaces | array | metafield_namespaces | nil | |
|
508
|
+
| private_metafield_namespaces | array | private_metafield_namespaces | nil | |
|
509
|
+
| topic | string | topic | scope | |
|
510
|
+
| updated_at | datetime/Int | updated_at | updated_at | |
|
511
|
+
|
512
|
+
*EPlat doesn't make any attemps to alias the varias topic/scope values between platforms.
|
513
|
+
**Notice that BigCommerce uses updated_at and created_at for this resource.
|
514
|
+
Unfortunately it's in a Time Integer format. Haven't yet got dynamic conversion so just tread carefully.
|
515
|
+
|
268
516
|
</details>
|
269
517
|
|
518
|
+
|
519
|
+
<br>
|
520
|
+
<hr>
|
270
521
|
<br>
|
271
522
|
|
272
|
-
##
|
523
|
+
## API Coverage
|
524
|
+
|
525
|
+
<details>
|
526
|
+
<summary> Base / Config</summary>
|
527
|
+
|
528
|
+
| Method | ShopifyAPI Gem equivalent | Shopify - tested | BigCom - tested
|
529
|
+
| -------------------------------------------- | ------------------------- | ----------------- | ------------------ |
|
530
|
+
| EPlat::Session.new() | ::Session.new | * | * |
|
531
|
+
| EPlat::Session.new() | ::Base.activate_session | * | * |
|
532
|
+
| EPlat::Session.new() | ::Session.setup() | * | * |
|
533
|
+
| EPlat.config.values[:shopify_api_version] | ::Baseapi_version | * | |
|
534
|
+
| EPlat.config.values[:bigcommerce_api_version] | ::Baseapi_version | | * |
|
535
|
+
|
536
|
+
</details>
|
537
|
+
|
538
|
+
|
539
|
+
<details>
|
540
|
+
<summary> Shop</summary>
|
541
|
+
|
542
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
543
|
+
| ----------------------------- | ----------------- | ----------------- | ------ |
|
544
|
+
| ::Shop.current | * | * | |
|
545
|
+
| shop.attribute | * | * | |
|
546
|
+
|
547
|
+
</details>
|
548
|
+
|
549
|
+
|
550
|
+
<details>
|
551
|
+
<summary> Product</summary>
|
552
|
+
|
553
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
554
|
+
| ----------------------------- | ----------------- | ----------------- | ------ |
|
555
|
+
| ::Product.last | * | * | |
|
556
|
+
| ::Product.all | * | * | |
|
557
|
+
| ::Product.attribute | * | * | |
|
558
|
+
| ::Product.find(id) | * | * | |
|
559
|
+
| ::Product.where(attr: '') | * | * | |
|
560
|
+
| ::Product.find_by(attr: '') | * | * | |
|
561
|
+
| ::Product.create(attr:) | * | * | |
|
562
|
+
| ::Product.save | * | * | |
|
563
|
+
| .save saves nested resources | * | | |
|
564
|
+
| ::Product.delete(id) | * | * | |
|
565
|
+
| ::Product.count | * | * | |
|
566
|
+
| product.dup | * | * | |
|
567
|
+
| product.variants | * | * | |
|
568
|
+
| product.find_variant(id) | * | * | |
|
569
|
+
| product.images | * | * | |
|
570
|
+
| products.next_page? | * | * | |
|
571
|
+
| products.previous_page? | * | * | |
|
572
|
+
| products.fetch_next_page | * | * | |
|
573
|
+
| products.fetch_previous_page | * | * | |
|
574
|
+
| products.previous_page_info | * | * | |
|
575
|
+
| products.next_page_info | * | * | |
|
576
|
+
|
577
|
+
```ruby
|
578
|
+
# How you might safely handle pagination via user input
|
579
|
+
# <%= link_to "previous products", "/", page_info: products.previous_page_info %>
|
580
|
+
# <%= link_to "Next products", "/", page_info: products.next_page_info %>
|
581
|
+
|
582
|
+
EPlat::Product.find(:all, params: {limit: 2, Current.e_plat_session.pagination_param => params['page_info'] })
|
583
|
+
```
|
584
|
+
|
585
|
+
|
586
|
+
### Product::Variant
|
587
|
+
|
588
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
589
|
+
| ----------------------------- | ----------------- | ----------------- | ------ |
|
590
|
+
| product.variants | * | * | |
|
591
|
+
| product.find_variant | * | * | |
|
592
|
+
| variants.attribute | * | * | |
|
593
|
+
| variant.attributes.delete | * | * | |
|
594
|
+
| variant.save | * | * | |
|
595
|
+
|
596
|
+
* Nested resources currently need to be saved on their own instance. product.variants.first.save, as opposed to product.save
|
597
|
+
* Also bear in mind that for platforms like BigCommerce, product and variant IDs are only unique within that store's context
|
598
|
+
* so if storing these IDs locally, remember to query via the shop i.e. shop.listings.where(platform_product_id: 123)
|
599
|
+
|
600
|
+
</details>
|
601
|
+
|
602
|
+
|
603
|
+
<details>
|
604
|
+
<summary> Order</summary>
|
605
|
+
|
606
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
607
|
+
| ----------------------------- | ----------------- | ----------------- | ------ |
|
608
|
+
| ::Order.last | * | * | |
|
609
|
+
| ::Order.all | * | * | |
|
610
|
+
| ::Order.attribute | * | * | |
|
611
|
+
| ::Order.find(id) | * | * | |
|
612
|
+
| ::Order.where(title: '') | * | * | |
|
613
|
+
| ::Order.find_by(title: '') | * | * | |
|
614
|
+
| ::Order.create(attr: '', ) | * | * | |
|
615
|
+
| ::Order.new(attr: '', ) | * | * | |
|
616
|
+
| ::Order.save | * | * | |
|
617
|
+
| ::Order.count | * | * | |
|
618
|
+
| order.cancel | * | * | |
|
619
|
+
| orders.next_page? | * | nil | |
|
620
|
+
| orders.previous_page? | * | nil | |
|
621
|
+
| orders.fetch_next_page | * | nil | |
|
622
|
+
| orders.fetch_previous_page | * | nil | |
|
623
|
+
|
624
|
+
*included nested resources: can update non-resource nested hashes like shipping_address, but not proper resources like customer
|
625
|
+
|
626
|
+
</details>
|
627
|
+
|
628
|
+
<details>
|
629
|
+
<summary> Metafield </summary>
|
630
|
+
|
631
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
632
|
+
| ----------------------------- | ----------------- | ----------------- | ------ |
|
633
|
+
| product.metafields | * | * | |
|
634
|
+
| order.metafields | * | * | |
|
635
|
+
| product.find_metafield(id) | * | * | |
|
636
|
+
| order.find_metafield(id) | * | * | |
|
637
|
+
| order.find_metafield(id) | * | * | |
|
638
|
+
| product.add_metafield(EPlat::Metafield.new {}) |* | * | |
|
639
|
+
| order.add_metafield(EPlat::Metafield.new {}) |* | * | |
|
640
|
+
| .attribute | * | * | |
|
641
|
+
| .save | * | * | |
|
642
|
+
| .destroy | * | * | |
|
643
|
+
| ::Metafield.create(attr: '') | * | * | |
|
644
|
+
| ::Metafield.new(attr: '') | * | * | |
|
645
|
+
|
646
|
+
|
647
|
+
</details>
|
648
|
+
|
649
|
+
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
<details>
|
655
|
+
<summary> ScriptTag</summary>
|
656
|
+
|
657
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
658
|
+
| -------------------------------- | ----------------- | ----------------- | ------ |
|
659
|
+
| ::ScriptTag.new({}) | * | * | |
|
660
|
+
| ::ScriptTag.create({}) | * | * | |
|
661
|
+
| ::ScriptTag.last | * | * | |
|
662
|
+
| ::ScriptTag.all | * | * | |
|
663
|
+
| ::ScriptTag.find | * | * | |
|
664
|
+
| .attribute | * | * | |
|
665
|
+
| .save | * | * | |
|
666
|
+
| .destroy | * | * | |
|
667
|
+
|
668
|
+
*note that Bigcommerce uses UUID instead of ID for script tags. This should mostly be handled by EPlat, apart from when passing the value to .find
|
669
|
+
|
670
|
+
</details>
|
671
|
+
|
672
|
+
<details>
|
673
|
+
<summary> Webhook</summary>
|
674
|
+
|
675
|
+
|
676
|
+
| Method | Shopify - tested | BigCom - tested | Etc |
|
677
|
+
| -------------------------------- | ----------------- | ----------------- | ------ |
|
678
|
+
| ::Webhook.new({}) | * | * | |
|
679
|
+
| ::Webhook.create({}) | * | * | |
|
680
|
+
| ::Webhook.last | * | * | |
|
681
|
+
| ::Webhook.all | * | * | |
|
682
|
+
| ::Webhook.find | * | * | |
|
683
|
+
| .attribute | * | * | |
|
684
|
+
| .save | * | * | |
|
685
|
+
| .destroy | * | * | |
|
686
|
+
|
687
|
+
</details>
|
688
|
+
|
689
|
+
|
690
|
+
<details>
|
691
|
+
<summary>Shopify only</summary>
|
692
|
+
|
693
|
+
These areas of the API will just support Shopify.
|
694
|
+
|
695
|
+
### RecurringApplicationCharge
|
696
|
+
|
697
|
+
| Method | Shopify - tested |
|
698
|
+
| -------------------------------------- | ----------------- |
|
699
|
+
| ::RecurringApplicationCharge.current | * |
|
700
|
+
| ::RecurringApplicationCharge.new({}) | * |
|
701
|
+
| ::RecurringApplicationCharge.create({})| * |
|
702
|
+
| ::RecurringApplicationCharge.last | * |
|
703
|
+
| ::RecurringApplicationCharge.all | * |
|
704
|
+
| ::RecurringApplicationCharge.find | * |
|
705
|
+
| .attribute | * |
|
706
|
+
| .save | * |
|
707
|
+
| .cancel | * |
|
708
|
+
| .destroy | * |
|
709
|
+
| .usage_charges | * |
|
710
|
+
|
711
|
+
*The .current charge is the active charge for the app with the session's store. Only one charge can be active at any time.
|
712
|
+
|
713
|
+
<br>
|
714
|
+
|
715
|
+
### RecurringApplicationCharge::UsageCharge
|
716
|
+
|
717
|
+
| Method | Shopify - tested |
|
718
|
+
| --------------------------------------------------------------------- | ----------------- |
|
719
|
+
| ::UsageCharge.last(params: {recurring_application_charge: r.id}) | * |
|
720
|
+
| ::UsageCharge.all(params: {recurring_application_charge: r.id}) | * |
|
721
|
+
| ::UsageCharge.find(id, params: {recurring_application_charge: r.id}) | * |
|
722
|
+
| ::UsageCharge.new({recurring_application_charge_id: r.id, ...}) | * |
|
723
|
+
| ::UsageCharge.create({recurring_application_charge_id: r.id, ...}) | * |
|
724
|
+
| .save | * |
|
725
|
+
| .attribute | * |
|
726
|
+
|
727
|
+
*Note no :update or :delete options supported.
|
728
|
+
** the recurring_application_charge_id has to be passed to any requests called on the class.
|
729
|
+
|
730
|
+
<br>
|
731
|
+
</details>
|
732
|
+
|
733
|
+
|
734
|
+
<details>
|
735
|
+
<summary> Outside of the scope of EPlat </summary>
|
736
|
+
|
737
|
+
<ul>
|
738
|
+
<li>
|
739
|
+
<strong>ShopifyAPI::Asset</strong> is depricated.
|
740
|
+
(check_for_store_two_pont_o in main app code.)
|
741
|
+
</li>
|
742
|
+
<li>
|
743
|
+
<strong>ShopifyAPI::AccessScope</strong> doesn't have other platform API equivilents.
|
744
|
+
(although should be kept track of locally)
|
745
|
+
</li>
|
746
|
+
<li>
|
747
|
+
<strong>GraphQL</strong>. EPlat just handles REST
|
748
|
+
<ul>
|
749
|
+
</details>
|
750
|
+
|
751
|
+
<br>
|
752
|
+
|
753
|
+
|
754
|
+
|
755
|
+
<hr>
|
756
|
+
<br>
|
273
757
|
|
274
|
-
<ul>
|
275
|
-
<li>
|
276
|
-
Get BigCommerce request of shop working
|
277
|
-
</li>
|
278
|
-
<li>
|
279
|
-
find_by and where don't seem to work for big commerce
|
280
|
-
</li>
|
281
|
-
</ul>
|
282
758
|
|
283
759
|
|
284
760
|
## Request Syntax
|
285
761
|
|
286
762
|
```ruby
|
763
|
+
### activate session
|
764
|
+
EPlat::Session.new(
|
765
|
+
platform: :shopify,
|
766
|
+
store_url: "hi.myshopify.com",
|
767
|
+
api_token: 11223344
|
768
|
+
)
|
769
|
+
|
287
770
|
### create new record
|
288
|
-
product = EPlat::Product.new(:
|
771
|
+
product = EPlat::Product.new(title: 't-shirt')
|
289
772
|
product.save
|
290
773
|
# or...
|
291
|
-
EPlat::Product.create(:
|
774
|
+
EPlat::Product.create(title: 't-shirt')
|
292
775
|
new_product = product.dup #duplicates entry without saving
|
293
776
|
|
294
777
|
### delete record
|
@@ -297,41 +780,58 @@ EPlat::Product.delete(params[:id])
|
|
297
780
|
EPlat::Product.find(my_id).destroy
|
298
781
|
|
299
782
|
### save record
|
300
|
-
product = EPlat::Product.new(:
|
783
|
+
product = EPlat::Product.new(title: 't-shirt')
|
301
784
|
product.save
|
302
785
|
|
786
|
+
product.full_response # <Net::HTTPOK>
|
787
|
+
product.headers # { "date"=>"Fri, 17 Nov 2023 14:25:53 GMT", ...}
|
788
|
+
JSON.parse(product.full_response.body) # "{...}"
|
789
|
+
|
303
790
|
### get records
|
304
|
-
EPlat::Product.find(
|
305
|
-
EPlat::Product.
|
306
|
-
EPlat::Product.
|
307
|
-
EPlat::Product.
|
308
|
-
EPlat::Product.
|
791
|
+
EPlat::Product.find(101) # GET EPlat::Product.first(args)) (or EPlat::Product.last(args))
|
792
|
+
EPlat::Product.all
|
793
|
+
EPlat::Product.last
|
794
|
+
EPlat::Product.where(title: "tshirt") # GET ?title=tshirt
|
795
|
+
EPlat::Product.find_by(title: "tshirt") # GET ?title=tshirt &.first
|
796
|
+
EPlat::Product.find(:all, params: {title: "tshirt"}) # ?title=tshirt
|
797
|
+
|
798
|
+
EPlat::Product.find(99, from: :leader) # GET /platforms_resource_path/leader.json
|
799
|
+
EPlat::Product.find(99, from: "/product/1/specific_url.json") #GET /product/1/specific_url.json
|
800
|
+
|
801
|
+
### count records
|
802
|
+
EPlat::Product.count # 2
|
803
|
+
|
804
|
+
# Nested resources - pass in the parent resource's ID to the params hash
|
805
|
+
EPlat::Product::Variant.find(variant_id, params: {product: product.id}) # /admin/api/2024-01/products/{{ product.id }}/variants/{{ variant_id }}.json
|
806
|
+
EPlat::Product::Variant.collection_path(product: 5) # /admin/api/2024-01/products/5/variants.json
|
309
807
|
|
310
808
|
|
311
|
-
#### options
|
312
|
-
#prefix_options for nested URLs
|
313
|
-
EPlat::Product::Variant.collection_path(:variant_id => 5) # => /products/5/variants.json
|
314
|
-
#returns a EPlat::Product::Variant instance
|
315
809
|
|
316
|
-
# query_options to add to params ?x=y
|
317
|
-
EPlat::Product.find(:all, query_options: {test: "is it?"})
|
318
810
|
```
|
811
|
+
<br>
|
319
812
|
|
320
813
|
|
321
|
-
##
|
814
|
+
## Attribute info
|
322
815
|
|
323
816
|
```ruby
|
324
|
-
#get clients shop
|
325
|
-
shop = EPlat::Shop.current
|
326
817
|
|
327
|
-
#
|
328
|
-
|
818
|
+
# Attributes
|
819
|
+
product.attributes #return all native platform attributes
|
820
|
+
product.mapped_attributes.entries #return all mapped e_plat attributes for a resource
|
821
|
+
|
822
|
+
# Attribute keys
|
823
|
+
product.native_keys #An array of the native attribute keys
|
824
|
+
product.mapped_attributes. #An array of the e_plat attribute keys
|
329
825
|
|
330
|
-
#
|
331
|
-
|
826
|
+
# look up mapping
|
827
|
+
product.mapping.aliases # a hash of the mapped aliases. {native_attribute => e_plat_attribute, ...}
|
828
|
+
product.mapped? "body_html" #check if a platforms resource is mapped to a specific EPlat alias
|
332
829
|
|
333
|
-
#
|
334
|
-
|
830
|
+
# In the context of a Bigcommerce product that has aliases:
|
831
|
+
product.changed_attributes # {}
|
832
|
+
product.title = "oi"
|
833
|
+
product.changed_attributes # {"name"=>"oi", "title"=>"oi"}
|
834
|
+
#title is the e_plat key which won't be included in requests to the server. The native key 'name' has automatically been updated and will be sent in requests.
|
335
835
|
|
336
836
|
```
|
337
837
|
|