e_plat 0.2.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +633 -135
  3. data/lib/active_resource/connection_error.rb +29 -0
  4. data/lib/active_resource/formats.rb +27 -0
  5. data/lib/current.rb +7 -0
  6. data/lib/e_plat/client/default_request_args.rb +27 -3
  7. data/lib/e_plat/client.rb +114 -87
  8. data/lib/e_plat/connection.rb +4 -0
  9. data/lib/e_plat/errors/missing_session_error.rb +1 -1
  10. data/lib/e_plat/mapping/base.rb +119 -12
  11. data/lib/e_plat/mapping/bigcommerce/v_3/metafield.rb +62 -0
  12. data/lib/e_plat/mapping/bigcommerce/v_3/order/billing_address.rb +14 -0
  13. data/lib/e_plat/mapping/bigcommerce/v_3/order/line_item.rb +85 -0
  14. data/lib/e_plat/mapping/bigcommerce/v_3/order/shipping_address.rb +73 -0
  15. data/lib/e_plat/mapping/bigcommerce/v_3/order.rb +160 -0
  16. data/lib/e_plat/mapping/bigcommerce/v_3/product/image.rb +12 -12
  17. data/lib/e_plat/mapping/bigcommerce/v_3/product/variant.rb +1 -1
  18. data/lib/e_plat/mapping/bigcommerce/v_3/script_tag.rb +78 -0
  19. data/lib/e_plat/mapping/bigcommerce/v_3/shop.rb +11 -6
  20. data/lib/e_plat/mapping/bigcommerce/v_3/webhook.rb +54 -0
  21. data/lib/e_plat/mapping/request_body_root.rb +38 -0
  22. data/lib/e_plat/mapping/shopify/v_2024_01/metafield.rb +26 -0
  23. data/lib/e_plat/mapping/shopify/v_2024_01/order/billing_address.rb +14 -0
  24. data/lib/e_plat/mapping/shopify/v_2024_01/order/shipping_address.rb +30 -0
  25. data/lib/e_plat/mapping/shopify/{v_2022_07/product.rb → v_2024_01/order.rb} +3 -3
  26. data/lib/e_plat/mapping/shopify/{v_2022_07 → v_2024_01}/product/image.rb +1 -1
  27. data/lib/e_plat/mapping/shopify/{v_2022_07 → v_2024_01}/product/variant.rb +2 -1
  28. data/lib/e_plat/mapping/shopify/v_2024_01/product.rb +26 -0
  29. data/lib/e_plat/mapping/shopify/v_2024_01/script_tag.rb +26 -0
  30. data/lib/e_plat/mapping/shopify/{v_2022_07 → v_2024_01}/shop.rb +1 -1
  31. data/lib/e_plat/mapping/shopify/v_2024_01/webhook.rb +29 -0
  32. data/lib/e_plat/mapping/virtual_collection/base.rb +14 -0
  33. data/lib/e_plat/mapping/virtual_collection/bigcommerce/order_line_items.rb +297 -0
  34. data/lib/e_plat/mapping.rb +3 -3
  35. data/lib/e_plat/resource/attribute_interface.rb +28 -28
  36. data/lib/e_plat/resource/base.rb +107 -68
  37. data/lib/e_plat/resource/collection.rb +92 -0
  38. data/lib/e_plat/resource/concerns/aliases.rb +102 -18
  39. data/lib/e_plat/resource/concerns/dirty.rb +54 -0
  40. data/lib/e_plat/resource/concerns/metafieldable.rb +43 -0
  41. data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +108 -6
  42. data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +73 -37
  43. data/lib/e_plat/resource/countable.rb +43 -0
  44. data/lib/e_plat/resource/metafield.rb +70 -0
  45. data/lib/e_plat/resource/order/Consignment.rb +8 -0
  46. data/lib/e_plat/resource/order/billing_address.rb +6 -0
  47. data/lib/e_plat/resource/order/fulfillment.rb +1 -0
  48. data/lib/e_plat/resource/order/line_item.rb +1 -0
  49. data/lib/e_plat/resource/order/shipping_address.rb +44 -0
  50. data/lib/e_plat/resource/order/shipping_line.rb +15 -14
  51. data/lib/e_plat/resource/order.rb +32 -0
  52. data/lib/e_plat/resource/paginated/link_headers.rb +42 -0
  53. data/lib/e_plat/resource/paginated/link_params.rb +26 -0
  54. data/lib/e_plat/resource/product/image.rb +6 -0
  55. data/lib/e_plat/resource/product/option.rb +1 -0
  56. data/lib/e_plat/resource/product/variant.rb +8 -12
  57. data/lib/e_plat/resource/product.rb +8 -2
  58. data/lib/e_plat/resource/script_tag.rb +56 -0
  59. data/lib/e_plat/resource/shop.rb +17 -13
  60. data/lib/e_plat/resource/shopify_only/recurring_application_charge/usage_charge.rb +32 -0
  61. data/lib/e_plat/resource/shopify_only/recurring_application_charge.rb +47 -0
  62. data/lib/e_plat/resource/webhook.rb +50 -0
  63. data/lib/e_plat/session.rb +14 -14
  64. data/lib/e_plat/type_coercer.rb +15 -17
  65. data/lib/e_plat/types.rb +1 -1
  66. data/lib/e_plat/version.rb +1 -1
  67. data/lib/e_plat.rb +4 -4
  68. metadata +51 -19
  69. data/lib/e_plat/resource/order/customer.rb +0 -37
  70. data/lib/e_plat/session_state.rb +0 -25
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,44 +35,63 @@ 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 = "2022-10"
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
 
53
- 1. Add `include EPlat::SessionState` to the top of your `ApplicationController` class.
54
-
55
- 2. To make requests, first initialize a session like so:
56
+ 1. To make requests, first initialize a session like so:
56
57
  ```ruby
57
58
  EPlat::Session.new(
58
59
  platform: :shopify,
59
60
  store_url: "test-store.myshopify.com",
60
61
  api_token: "123",
61
- # store_hash: BigCommerce_specific
62
+ # store_hash: optional BigCommerce store hash
62
63
  )
63
64
  ```
64
65
 
65
- 3. You can then make requests to the platform via a singleton call on the class:
66
+ 2. You can then make requests to the platform via a singleton call on the Resource class:
66
67
  ```ruby
67
68
  EPlat::Product.find(id: 123)
68
69
  ```
69
70
 
70
- 4. Which will return an instance of:
71
+ 3. Which will return an instance of:
71
72
  ```ruby
72
73
  EPlat::Product
73
74
  ```
74
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>
75
95
 
76
96
  ## Under The Hood
77
97
 
@@ -91,11 +111,12 @@ EPlat::Product
91
111
  </li>
92
112
  <li>
93
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.
114
+ You can check if an attribute has been mapped by calling `resource.mapped? "attribute_name"`
94
115
  </li>
95
116
  </ul>
96
117
  </ol>
97
118
 
98
-
119
+ <br>
99
120
 
100
121
 
101
122
  ## EPlat Alias Interface
@@ -103,16 +124,16 @@ EPlat::Product
103
124
  <details>
104
125
  <summary>Shop</summary>
105
126
 
106
- ### Mapped Aliases
127
+ ### EPlat::Shop
107
128
 
108
- | Alas | Type | Shopify | BigCommerce | WooCommerce |
129
+ | Alias | Type | Shopify | BigCommerce| Etc |
109
130
  | ------------------------------------ | --------- | ------- | -----------| ------------|
110
- | id | integer | * | * | nil |
111
- | name | string | * | * | nil |
112
- | email | string | * | * | nil |
113
- | domain | string | * | * | nil |
114
- | province | string | * | * | nil |
115
- | country | string | * | * | nil |
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 |
116
137
  | address1 | string | * | nil | nil |
117
138
  | zip | string | * | nil | nil |
118
139
  | city | string | * | nil | nil |
@@ -124,30 +145,30 @@ EPlat::Product
124
145
  | address2 | string | * | nil | nil |
125
146
  | created_at | datetime | * | nil | nil |
126
147
  | updated_at | datetime | * | nil | nil |
127
- | country_code | string | * | * | nil |
148
+ | country_code | string | * | country_code | nil |
128
149
  | country_name | string | * | nil | nil |
129
- | currency | string | * | * | nil |
150
+ | currency | string | * | currency_symbol | nil |
130
151
  | customer_email | string | * | nil | nil |
131
152
  | timezone | string | * | nil | nil |
132
153
  | iana_timezone | string | * | nil | nil |
133
154
  | shop_owner | string | * | nil | nil |
134
155
  | money_format | string | * | nil | nil |
135
156
  | money_with_currency_format | string | * | nil | nil |
136
- | weight_unit | string | * | * | nil |
157
+ | weight_unit | string | * | weight_unit| nil |
137
158
  | province_code | string | * | nil | nil |
138
159
  | taxes_included | boolean | * | nil | nil |
139
160
  | auto_configure_tax_inclusivity | boolean | * | nil | nil |
140
161
  | tax_shipping | boolean | * | nil | nil |
141
162
  | county_taxes | boolean | * | nil | nil |
142
163
  | plan_display_name | string | * | nil | nil |
143
- | plan_name | string | * | * | nil |
164
+ | plan_name | string | * | plan_name | nil |
144
165
  | has_discounts | boolean | * | nil | nil |
145
166
  | has_gift_cards | boolean | * | nil | nil |
146
- | myshopify_domain | string | * | nil | nil |
167
+ | myshopify_domain | string | * | control_panel_base_url | nil |
147
168
  | google_apps_domain | string | * | nil | nil |
148
169
  | google_apps_login_enabled | boolean | * | nil | nil |
149
170
  | money_in_emails_format | string | * | nil | nil |
150
- | money_with_currency_in_emails_format| string | * | nil | nil |
171
+ | money_with_currency_in_emails_format | string | * | nil | nil |
151
172
  | eligible_for_payments | boolean | * | nil | nil |
152
173
  | requires_extra_payments_agreement | boolean | * | nil | nil |
153
174
  | password_enabled | boolean | * | nil | nil |
@@ -163,81 +184,80 @@ EPlat::Product
163
184
  | pre_launch_enabled | boolean | * | nil | nil |
164
185
  | enabled_presentment_currencies | array | * | nil | nil |
165
186
  | transactional_sms_disabled | boolean | * | nil | nil |
166
- | 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
+ ```
167
194
 
168
195
  </details>
169
- </br>
196
+
170
197
  <details>
171
198
  <summary>Product</summary>
172
199
 
173
- ### Mapped Aliases
200
+ ### EPlat::Product
174
201
 
175
- | Alas | Type | Shopify | BigCommerce | WooCommerce |
176
- | ------------------------| -------- | ------- | -----------| ------------|
177
- | body_html | string | * | * | nil |
178
- | created_at | datetime | * | * | nil |
179
- | handle | string | * | * | nil |
180
- | id | integer | * | * | nil |
181
- | images | array | * | * | nil |
182
- | options | array | * | [] | nil |
183
- | product_type | string | * | * | nil |
184
- | published_at | datetime | * | nil | nil |
185
- | published_scope | string | * | nil | nil |
186
- | status | string | * | nil | nil |
187
- | tags | string | * | nil | nil |
188
- | admin_graphql_api_id | string | * | nil | nil |
189
- | template_suffix | string | * | nil | nil |
190
- | title | string | * | * | nil |
191
- | updated_at | datetime | * | * | nil |
192
- | variants | array | * | * | nil |
193
- | vendor | string | * | nil | 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 |
194
221
 
195
- </details>
196
- </br>
197
- <details>
198
- <summary>Product Variant</summary>
199
222
 
200
- ### Mapped Aliases
223
+ ### EPlat::Product::Variant
224
+
201
225
 
202
- | Alas | Type | Shopify | BigCommerce | WooCommerce |
203
- | --------------------- | -------- | ------- | -----------| ------------|
204
- | id | integer | * | * | nil |
205
- | product_id | integer | * | * | nil |
206
- | title | string | * | nil | nil |
207
- | price | string | * | * | nil |
208
- | sku | string | * | * | nil |
209
- | position | integer | * | nil | nil |
210
- | inventory_policy | string | * | nil | nil |
211
- | compare_at_price | string | * | nil | nil |
212
- | fulfillment_service | string | * | nil | nil |
213
- | inventory_management | string | * | nil | nil |
214
- | option1 | string | * | * | nil |
215
- | option2 | string | * | nil | nil |
216
- | option3 | string | * | nil | nil |
217
- | created_at | datetime | * | * | nil |
218
- | updated_at | datetime | * | * | nil |
219
- | taxable | boolean | * | nil | nil |
220
- | barcode | string | * | nil | nil |
221
- | grams | integer | * | nil | nil |
222
- | image_id | integer | * | nil | nil |
223
- | weight | float | * | * | nil |
224
- | weight_unit | string | * | nil | nil |
225
- | inventory_item_id | integer | * | nil | nil |
226
- | inventory_quantity | integer | * | * | nil |
227
- | old_inventory_quantity| integer | * | nil | nil |
228
- | presentment_prices | array | * | nil | nil |
229
- | tax_code | string | * | nil | nil |
230
- | requires_shipping | boolean | * | nil | nil |
231
- | admin_graphql_api_id | string | * | nil | 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 |
232
256
 
233
- </details>
234
- </br>
235
- <details>
236
- <summary>Product Option</summary>
237
-
238
- ### Mapped Aliases
239
257
 
240
- | Alas | Type | Shopify | BigCommerce | WooCommerce |
258
+ ### EPlat::Product::Option
259
+
260
+ | Alias | Type | Shopify | BigCommerce| Etc |
241
261
  | --------- | -------- | ------- | -----------| ------------|
242
262
  | id | integer | * | nil | nil |
243
263
  | product_id| integer | * | nil | nil |
@@ -245,51 +265,513 @@ EPlat::Product
245
265
  | position | integer | * | nil | nil |
246
266
  | values | array | * | nil | nil |
247
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
+
248
285
  </details>
249
- </br>
286
+
250
287
  <details>
251
- <summary>Product Image</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>
252
445
 
253
- ### Mapped Aliases
254
446
 
255
- | Alas | Type | Shopify | BigCommerce | WooCommerce |
256
- | -------------------- | -------- | ------- | -----------| ------------|
257
- | id | integer | * | * | nil |
258
- | product_id | integer | * | * | nil |
259
- | position | integer | * | nil | nil |
260
- | created_at | datetime | * | * | nil |
261
- | updated_at | datetime | * | * | nil |
262
- | alt | string | * | nil | nil |
263
- | width | integer | * | nil | nil |
264
- | height | integer | * | nil | nil |
265
- | src | string | * | * | nil |
266
- | variant_ids | array | * | nil | nil |
267
- | admin_graphql_api_id | string | * | nil | nil |
447
+ </details>
448
+
449
+ <details>
450
+ <summary> Metafield </summary>
268
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
+
269
469
  </details>
270
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
+
516
+ </details>
517
+
518
+
519
+ <br>
520
+ <hr>
271
521
  <br>
272
522
 
273
- ## Todos
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>
274
757
 
275
- <ul>
276
- <li>
277
- Get BigCommerce request of shop working
278
- </li>
279
- <li>
280
- find_by and where don't seem to work for big commerce
281
- </li>
282
- </ul>
283
758
 
284
759
 
285
760
  ## Request Syntax
286
761
 
287
762
  ```ruby
763
+ ### activate session
764
+ EPlat::Session.new(
765
+ platform: :shopify,
766
+ store_url: "hi.myshopify.com",
767
+ api_token: 11223344
768
+ )
769
+
288
770
  ### create new record
289
- product = EPlat::Product.new(:title => 't-shirt')
771
+ product = EPlat::Product.new(title: 't-shirt')
290
772
  product.save
291
773
  # or...
292
- EPlat::Product.create(:title => 't-shirt')
774
+ EPlat::Product.create(title: 't-shirt')
293
775
  new_product = product.dup #duplicates entry without saving
294
776
 
295
777
  ### delete record
@@ -298,41 +780,57 @@ EPlat::Product.delete(params[:id])
298
780
  EPlat::Product.find(my_id).destroy
299
781
 
300
782
  ### save record
301
- product = EPlat::Product.new(:title => 't-shirt')
783
+ product = EPlat::Product.new(title: 't-shirt')
302
784
  product.save
303
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
+
304
790
  ### get records
305
- EPlat::Product.find(1) # => GET /product/1.json (or EPlat::Product.first(args)) (or EPlat::Product.last(args))
306
- EPlat::Product.find(:all) # => GET /people.json
307
- EPlat::Product.find(:all, :params => { :title => "tshirt" }) # => GET /product.json?title=tshirt
308
- EPlat::Product.find(:one, :from => :leader) # => GET /product/leader.json
309
- EPlat::Product.find(:one, :from => "/product/1/specific_url.json") # => GET /product/1/specific_url.json
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
310
807
 
311
808
 
312
- #### options
313
- #prefix_options for nested URLs
314
- EPlat::Product::Variant.collection_path(:variant_id => 5) # => /products/5/variants.json
315
- #returns a EPlat::Product::Variant instance
316
809
 
317
- # query_options to add to params ?x=y
318
- EPlat::Product.find(:all, query_options: {test: "is it?"})
319
810
  ```
811
+ <br>
320
812
 
321
813
 
322
- ## Resource Syntax
814
+ ## Attribute info
323
815
 
324
816
  ```ruby
325
- #get clients shop
326
- shop = EPlat::Shop.current
327
817
 
328
- #to return all native platform attributes
329
- EPlat::Product.new({}).attributes
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
330
825
 
331
- #see all of the successfully mapped aliases for a resource
332
- EPlat::Product.new({}).mapped_attributes.entries
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
333
829
 
334
- #check if a platforms resource is mapped to a specific EPlat alias
335
- EPlat::Product.new({}).mapped? "body_html"
830
+ # In the context of a Bigcommerce product that has aliases:
831
+ product.changed_attributes # {}
832
+ product.name = oi
833
+ product.changed_attributes # {"name"=>"hey", "title"=>"hey"}
336
834
 
337
835
  ```
338
836