e_plat 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +84 -54
  3. data/lib/e_plat/client/default_request_args.rb +1 -1
  4. data/lib/e_plat/client.rb +34 -8
  5. data/lib/e_plat/mapping/bigcommerce/v_3/product/option.rb +58 -0
  6. data/lib/e_plat/mapping/bigcommerce/v_3/product/variant/option_value.rb +42 -0
  7. data/lib/e_plat/mapping/shopify/v_2024_07/metafield.rb +26 -0
  8. data/lib/e_plat/mapping/shopify/v_2024_07/order/billing_address.rb +14 -0
  9. data/lib/e_plat/mapping/shopify/v_2024_07/order/shipping_address.rb +30 -0
  10. data/lib/e_plat/mapping/shopify/v_2024_07/order.rb +26 -0
  11. data/lib/e_plat/mapping/shopify/v_2024_07/product/image.rb +52 -0
  12. data/lib/e_plat/mapping/shopify/v_2024_07/product/option.rb +45 -0
  13. data/lib/e_plat/mapping/shopify/v_2024_07/product/variant/option_value.rb +58 -0
  14. data/lib/e_plat/mapping/shopify/v_2024_07/product/variant.rb +180 -0
  15. data/lib/e_plat/mapping/shopify/v_2024_07/product.rb +100 -0
  16. data/lib/e_plat/mapping/shopify/v_2024_07/script_tag.rb +26 -0
  17. data/lib/e_plat/mapping/shopify/v_2024_07/shop.rb +26 -0
  18. data/lib/e_plat/mapping/shopify/v_2024_07/webhook.rb +29 -0
  19. data/lib/e_plat/mapping/virtual_collection/shopify/product/variant/option_value.rb +272 -0
  20. data/lib/e_plat/resource/base.rb +24 -2
  21. data/lib/e_plat/resource/collection.rb +45 -16
  22. data/lib/e_plat/resource/concerns/aliases.rb +39 -19
  23. data/lib/e_plat/resource/concerns/dirty.rb +12 -8
  24. data/lib/e_plat/resource/concerns/graph_q_lable.rb +253 -0
  25. data/lib/e_plat/resource/concerns/overwrite_instance_methods.rb +4 -4
  26. data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +1 -1
  27. data/lib/e_plat/resource/countable.rb +37 -10
  28. data/lib/e_plat/resource/platform_specific/bigcommerce/product/variant/option_value.rb +2 -0
  29. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product/variant.rb +47 -0
  30. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product/variants_bulk.rb +47 -0
  31. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input/product.rb +23 -0
  32. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/input.rb +98 -0
  33. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation/product/variant.rb +78 -0
  34. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation/product.rb +55 -0
  35. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/mutation.rb +5 -0
  36. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query/product/variant.rb +44 -0
  37. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query/product.rb +58 -0
  38. data/lib/e_plat/resource/platform_specific/shopify/graph_q_l/v_2024_07/query.rb +5 -0
  39. data/lib/e_plat/resource/platform_specific/shopify/product/image.rb +13 -1
  40. data/lib/e_plat/resource/platform_specific/shopify/product/option.rb +13 -1
  41. data/lib/e_plat/resource/platform_specific/shopify/product/variant/option_value.rb +14 -0
  42. data/lib/e_plat/resource/platform_specific/shopify/product/variant.rb +65 -1
  43. data/lib/e_plat/resource/platform_specific/shopify/product.rb +77 -2
  44. data/lib/e_plat/resource/product/image.rb +8 -5
  45. data/lib/e_plat/resource/product/option.rb +2 -3
  46. data/lib/e_plat/resource/product/variant/option_value.rb +17 -0
  47. data/lib/e_plat/resource/product/variant.rb +4 -10
  48. data/lib/e_plat/resource/product.rb +23 -11
  49. data/lib/e_plat/session.rb +3 -2
  50. data/lib/e_plat/type_coercer.rb +3 -1
  51. data/lib/e_plat/version.rb +1 -1
  52. data/lib/e_plat.rb +12 -3
  53. data/lib/hash.rb +39 -0
  54. metadata +130 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9dbde4e59673eba0dc91580fd4f4f50bc138c380cfa00a78a2be1de12f1706c
4
- data.tar.gz: 9998fa572e61d5e043fdbe2ec804c18cde16c65f2bb64534003a5f00e0034d38
3
+ metadata.gz: d10eb52dda105627cb32fb58161da4777a8a020f6ea70ba4111da4487441e743
4
+ data.tar.gz: 00ef52bdc6790981c6fcfb35615982c06b82152279d9a5f301ff3c84ad50747b
5
5
  SHA512:
6
- metadata.gz: d855f8148b8df76db6202da298128a8e3c9f8ba1b1adebd7824182e80676ff6f242c59f3aa54cc791b6567f04e1741fefe7a643fe2c7e8523c93d0fb7cbc0236
7
- data.tar.gz: 8c478644bf379156b98e80992edbec4a24baa95e854a8d9864abc92c0e8c73ea4e4d4d9980c3957926eb70164e3f547fbfaffd88373fbc3bc1859dd7e8c80101
6
+ metadata.gz: f5951156f87b275af28cefeed42eff062aeb85155454a8b498c54d795843be40acd5245d1f20b5e724912abef7ef43b0dc47c4e09f2084ad1ad1fbab8418aafa
7
+ data.tar.gz: 0af92dd3962135ec69c738eab60bc320e8add2de57832cc793ed11ab5118e1515a7a048623f75537e3c126ae1e78e9c109cab49685335d7a9860da655d611bdc
data/README.md CHANGED
@@ -46,11 +46,34 @@ EPlat.config.bigcommerce_api_version = "v3"
46
46
 
47
47
  # EPlat.api_display_name.shopify #=> "2024-01" # presents as the platform would display in URL paths
48
48
  # EPlat.config.shopify_api_version #=> "2024_01" # coerced interally for creating constants
49
+ # EPlat.config.print_graphql_requests #=> false # prints out Shopify graphql queries/mutations to the console
49
50
  ```
50
51
  <br>
51
52
 
52
- ## Relasing new version
53
+ ## Testing
54
+
55
+ To run the test for the default versions of all supported platforms:
56
+ ```
57
+ bundle exec rails test
58
+ ```
59
+
60
+ To run with specific api versions, you can set globals inline
61
+ ```
62
+ EPLAT_SHOPIFY_API_VERSION=2024_07 EPLAT_BIGCOMMERCE_API_VERSION=v3 rails test
63
+ ```
64
+
65
+ To print out Shopify GraphQL queries/mutations
66
+ ```
67
+ EPLAT_PRINT_GRAPHQL_REQUESTS=true rails test
68
+ ```
69
+
70
+ <br>
71
+
72
+ ## Releasing a new version
53
73
  https://dev.to/doctolib/release-a-new-gem-version-je0
74
+
75
+ <br>
76
+
54
77
  <br>
55
78
 
56
79
  ## Usage
@@ -211,10 +234,8 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
211
234
  | options | array | * | * | nil |
212
235
  | product_type | string | * | type | nil |
213
236
  | published_at | datetime | * | nil | nil |
214
- | published_scope | string | * | nil | nil |
215
237
  | status | string | * | availability | nil |
216
238
  | tags | string | * | nil | nil |
217
- | admin_graphql_api_id | string | * | nil | nil |
218
239
  | template_suffix | string | * | nil | nil |
219
240
  | title | string | * | name | nil |
220
241
  | updated_at | datetime | * | date_modified| nil |
@@ -224,68 +245,62 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
224
245
 
225
246
  ### EPlat::Product::Variant
226
247
 
227
-
228
- | Alias | Type | Shopify | BigCommerce | Etc |
229
- | --------------------- | -------- | ------- | ----------------------| ------------|
230
- | id | integer | * | id | nil |
231
- | product_id | integer | * | product_id | nil |
232
- | title | string | * | option_values&.map(&:label)&.join(' ') | nil |
233
- | price | string | * | price | nil |
234
- | sku | string | * | sku | nil |
235
- | position | integer | * | nil | nil |
236
- | inventory_policy | string | * | nil | nil |
237
- | compare_at_price | string | * | nil | nil |
238
- | fulfillment_service | string | * | nil | nil |
239
- | inventory_management | string | * | nil | nil |
240
- | option1 | string | * | option_values[0].label| nil |
241
- | option2 | string | * | nil | nil |
242
- | option3 | string | * | nil | nil |
243
- | created_at | datetime | * | nil | nil |
244
- | updated_at | datetime | * | nil | nil |
245
- | taxable | boolean | * | nil | nil |
246
- | barcode | string | * | nil | nil |
247
- | grams | integer | * | nil | nil |
248
- | image_id | integer | * | nil | nil |
249
- | weight | float | * | weight | nil |
250
- | weight_unit | string | * | nil | nil |
251
- | inventory_item_id | integer | * | nil | nil |
252
- | inventory_quantity | integer | * | inventory_level | nil |
253
- | old_inventory_quantity| integer | * | nil | nil |
254
- | presentment_prices | array | * | nil | nil |
255
- | tax_code | string | * | nil | nil |
256
- | requires_shipping | boolean | * | nil | nil |
257
- | admin_graphql_api_id | string | * | nil | nil |
258
-
248
+
249
+ | Alias | Type | Shopify | BigCommerce | Etc |
250
+ |-----------------------|----------|---------|--------------------------------------|-----|
251
+ | id | integer | * | id | nil |
252
+ | title | string | * | option_values&.map(&:label)&.join(' ') | nil |
253
+ | price | string | * | price | nil |
254
+ | sku | string | * | sku | nil |
255
+ | position | integer | * | nil | nil |
256
+ | inventory_policy | string | * | nil | nil |
257
+ | compare_at_price | string | * | nil | nil |
258
+ | inventory_management | boolean | inventoryItem[tracked] | nil | nil |
259
+ | created_at | datetime | * | nil | nil |
260
+ | updated_at | datetime | * | nil | nil |
261
+ | taxable | boolean | * | nil | nil |
262
+ | barcode | string | * | nil | nil |
263
+ | grams | integer | getter only: converted node.inventoryItem[measurement][weight][value] | nil | nil |
264
+ | weight | float | getter only: node.inventoryItem[measurement][weight][value] | weight |
265
+ | weight_unit | string | getter only: node.inventoryItem[measurement][weight][unit] | nil |
266
+ | inventory_item_id | integer | getter only: node.inventoryItem[id]| nil | nil |
267
+ | inventory_quantity | integer | getter only: node.inventoryQuantity | inventory_level | nil |
268
+ | tax_code | string | * | nil | nil |
269
+ | requires_shipping | boolean | InventoryItem[requiresShipping] | nil | nil |
259
270
  *Bigcommerce variant.title= setter is not supported
260
271
 
261
272
 
262
273
  ### EPlat::Product::Option
263
274
 
264
- | Alias | Type | Shopify | BigCommerce| Etc |
265
- | --------- | -------- | ------- | -----------| ------------|
266
- | id | integer | * | nil | nil |
267
- | product_id| integer | * | nil | nil |
268
- | name | string | * | nil | nil |
269
- | position | integer | * | nil | nil |
270
- | values | array | * | nil | nil |
271
-
275
+ | Alias | Type | Shopify | BigCommerce | Etc |
276
+ | ---------- | -------- | ------- | ---------------------------- | --- |
277
+ | id | integer | * | id | nil |
278
+ | name | string | * | display_name | nil |
279
+ | position | integer | * | sort_order | nil |
280
+ | values | array | * | option_values[i][label] | nil |
281
+
272
282
 
273
283
  ### EPlat::Product::Image
274
284
 
275
285
  | Alias | Type | Shopify | BigCommerce | Etc |
276
286
  | -------------------- | -------- | ------- | ----------- | ------------|
277
287
  | id | integer | * | id | nil |
278
- | product_id | integer | * | product_id | nil |
279
288
  | position | integer | * | nil | nil |
280
- | created_at | datetime | * | date_created | nil |
281
- | updated_at | datetime | * | date_modified| nil |
282
289
  | alt | string | * | nil | nil |
283
290
  | width | integer | * | nil | nil |
284
291
  | height | integer | * | nil | nil |
285
292
  | src | string | * | url_standard | nil |
286
293
  | variant_ids | array | * | nil | nil |
287
- | admin_graphql_api_id | string | * | nil | nil |
288
294
 
295
+
296
+ ### EPlat::Product::Variant::OptionValue
297
+ (not supported for Shopify API v2024_01)
298
+
299
+ | Alias | Type | Shopify | BigCommerce | Etc |
300
+ | -------------------- | -------- | ------------------------------------------ | ------------------ | --- |
301
+ | id | integer | [selected_options][option_value][id] | id | nil |
302
+ | name | string | [selected_options][name] | option_display_name| nil |
303
+ | value | string | [selected_options][value] | label | nil |
289
304
  </details>
290
305
 
291
306
  <details>
@@ -584,11 +599,12 @@ Unfortunately it's in a Time Integer format. Haven't yet got dynamic conversion
584
599
  | ::Product.find_by(attr: '') | * | * | |
585
600
  | ::Product.create(attr:) | * | * | |
586
601
  | ::Product.save | * | * | |
587
- | .save saves nested resources | * | | |
602
+ | .save saves nested resources | only variants | | |
588
603
  | ::Product.delete(id) | * | * | |
589
604
  | ::Product.count | * | * | |
590
605
  | product.dup | * | * | |
591
606
  | product.variants | * | * | |
607
+ | product.load_all_variants | * | * | |
592
608
  | product.find_variant(id) | * | * | |
593
609
  | product.images | * | * | |
594
610
  | products.next_page? | * | * | |
@@ -599,11 +615,23 @@ Unfortunately it's in a Time Integer format. Haven't yet got dynamic conversion
599
615
  | products.next_page_info | * | * | |
600
616
 
601
617
  ```ruby
602
- # How you might safely handle pagination via user input
603
- # <%= link_to "previous products", "/", page_info: products.previous_page_info %>
604
- # <%= link_to "Next products", "/", page_info: products.next_page_info %>
605
-
606
- EPlat::Product.find(:all, params: {limit: 2, EPlat::Current.e_plat_session.pagination_param => params['page_info'] })
618
+ # The 2024 increased Shopify variants limit
619
+ @product.load_all_variants #returns all variants. In Shopify's case it will keep on requesting in batches until it has the full amount (capped at 10x requests of 200 currently i.e. 2,000 variants)
620
+
621
+ ### Pagination
622
+ # ...How you might handle pagination.
623
+
624
+ # Add pagination cursors to your link's params. This is available on any EPlat::Collection instance
625
+ <%= link_to "previous products", "/", forward_page_info: products.previous_page_info %>
626
+ <%= link_to "Next products", "/", backward_page_info: products.next_page_info %>
627
+
628
+ # Then on the server, let EPlat handle the correct platform specific arguments to request with.
629
+ EPlat::Product.find(:all, params: {
630
+ EPlat::Current.e_plat_session.pagination_param(:forward) => params['forward_page_info']
631
+ })
632
+ EPlat::Product.find(:all, params: {
633
+ EPlat::Current.e_plat_session.pagination_param(:backward) => params['backward_page_info']
634
+ })
607
635
  ```
608
636
 
609
637
 
@@ -805,12 +833,14 @@ EPlat::Product.find(my_id).destroy
805
833
 
806
834
  ### save record
807
835
  product = EPlat::Product.new(title: 't-shirt')
808
- product.save
836
+ product.save # true or false
837
+ product.errors # active record like errors if .save returned false
809
838
 
810
839
  product.full_response # <Net::HTTPOK>
811
840
  product.headers # { "date"=>"Fri, 17 Nov 2023 14:25:53 GMT", ...}
812
841
  JSON.parse(product.full_response.body) # "{...}"
813
842
 
843
+
814
844
  ### get records
815
845
  EPlat::Product.find(101) # GET EPlat::Product.first(args)) (or EPlat::Product.last(args))
816
846
  EPlat::Product.all
@@ -10,7 +10,7 @@ module EPlat
10
10
  {}
11
11
  when :bigcommerce
12
12
  {
13
- "include" => "variants,images"
13
+ "include" => "variants,images,options"
14
14
  }
15
15
  when :woocommerce
16
16
  {}
data/lib/e_plat/client.rb CHANGED
@@ -4,13 +4,15 @@ module EPlat
4
4
  class Client
5
5
  include Client::PlatformConvenienceMethods, Client::DefaultRequestArgs
6
6
 
7
- SHOPIFY_PAGINATION_PARAM = "page_info"
8
- BIGCOMMERCE_PAGINATION_PARAM = "page"
7
+ SHOPIFY_REST_PAGINATION_PARAM = "page_info"
8
+ SHOPIFY_GRAPHQL_FORWARD_PAGINATION_PARAM = "after"
9
+ SHOPIFY_GRAPHQL_BACKWARD_PAGINATION_PARAM = "before"
10
+ BIGCOMMERCE_PAGINATION_PARAM = "page"
9
11
 
10
12
  attr_reader :platform, :store_url, :api_token, :api_version, :store_hash
11
13
 
12
- def initialize(platform: nil, store_url: nil, api_token: nil, store_hash: nil)
13
- @platform, @store_url, @api_token, @store_hash = platform&.to_sym, store_url, api_token, store_hash
14
+ def initialize(platform: nil, store_url: nil, api_token: nil, store_hash: nil, api_version: nil)
15
+ @platform, @store_url, @api_token, @store_hash, @api_version = platform&.to_sym, store_url, api_token, store_hash, api_version
14
16
  end
15
17
 
16
18
  def headers
@@ -83,6 +85,19 @@ module EPlat
83
85
  "/" # not yet supported
84
86
  end
85
87
  end
88
+
89
+ def graphql_request_url
90
+ case platform
91
+ when :shopify
92
+ "https://#{ store_url }/admin/api/#{ api_version.dasherize }/graphql.json"
93
+ else
94
+ raise EPlat::Error, "GraphQL is not supported for #{ platform }"
95
+ end
96
+ end
97
+
98
+ def uses_graphql_for_products?
99
+ platform == :shopify && api_version != "2024_01"
100
+ end
86
101
 
87
102
  def platform_headers
88
103
  case platform
@@ -107,6 +122,8 @@ module EPlat
107
122
  end
108
123
 
109
124
  def api_version
125
+ return @api_version if @api_version.present?
126
+
110
127
  case platform
111
128
  when :shopify
112
129
  EPlat.config.shopify_api_version
@@ -117,6 +134,10 @@ module EPlat
117
134
  end
118
135
  end
119
136
 
137
+ def shopify_graphql_version
138
+ "V202407"
139
+ end
140
+
120
141
  def can_update_nested_resources?
121
142
  case platform
122
143
  when :shopify then true
@@ -125,11 +146,16 @@ module EPlat
125
146
  end
126
147
  end
127
148
 
128
- def pagination_param
149
+ def pagination_param(direction=:forward)
129
150
  case platform
130
- when :shopify then SHOPIFY_PAGINATION_PARAM
131
- when :bigcommerce then BIGCOMMERCE_PAGINATION_PARAM
132
- when :woocommerce then nil
151
+ when :shopify
152
+ if uses_graphql_for_products?
153
+ direction == :backward ? SHOPIFY_GRAPHQL_BACKWARD_PAGINATION_PARAM : SHOPIFY_GRAPHQL_FORWARD_PAGINATION_PARAM
154
+ else
155
+ SHOPIFY_REST_PAGINATION_PARAM
156
+ end
157
+ when :bigcommerce
158
+ BIGCOMMERCE_PAGINATION_PARAM
133
159
  end
134
160
  end
135
161
 
@@ -0,0 +1,58 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Bigcommerce
6
+ module V3
7
+ class Product
8
+ class Option < EPlat::Mapping::Base
9
+
10
+ def native_top_key
11
+ "data"
12
+ end
13
+
14
+ def native_attributes
15
+ super.concat([
16
+ "id",
17
+ "product_id",
18
+ "display_name",
19
+ "type",
20
+ "config",
21
+ "sort_order",
22
+ "option_values",
23
+ "modifiers",
24
+ "option_set_id",
25
+ "option_set_display",
26
+ "variants"
27
+ ])
28
+ end
29
+
30
+ def native_attribute_aliases
31
+ super.concat([
32
+ {
33
+ existing_entry: {native_key: "id", e_plat_key: "id"}
34
+ },
35
+ {
36
+ alias_attribute: {native_key: "display_name", e_plat_key: "name"}
37
+ },
38
+ {
39
+ alias_attribute: {native_key: "sort_order", e_plat_key: "position"}
40
+ },
41
+ {
42
+ alias_attribute: {native_key: "option_values", e_plat_key: "values",
43
+ custom_e_plat_getter: '-> (option_values) {
44
+ option_values.map{|val| val.label}
45
+ }',
46
+ custom_native_setter: '-> (option) { raise EPlat::Error.new "EPlat does not yet support native setting back to .option_values[i][:label]" }'
47
+ }
48
+ }
49
+
50
+ ])
51
+ end
52
+
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,42 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Bigcommerce
6
+ module V3
7
+ class Product::Variant
8
+ class OptionValue < EPlat::Mapping::Base
9
+
10
+ def native_top_key
11
+ "data"
12
+ end
13
+
14
+ def native_attributes
15
+ super.concat([
16
+ "id",
17
+ "label",
18
+ "option_id",
19
+ "option_display_name"
20
+ ])
21
+ end
22
+
23
+ def native_attribute_aliases
24
+ super.concat([
25
+ {
26
+ existing_entry: {native_key: "id", e_plat_key: "id"}
27
+ },
28
+ {
29
+ alias_attribute: {native_key: "option_display_name", e_plat_key: "name"}
30
+ },
31
+ {
32
+ alias_attribute: {native_key: "label", e_plat_key: "value"}
33
+ }
34
+ ])
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Shopify
4
+ module V202407 #< :module
5
+ class Metafield < EPlat::Mapping::Base
6
+
7
+ def native_top_key
8
+ "metafield"
9
+ end
10
+
11
+ def native_attributes
12
+ super.concat([
13
+ ])
14
+ end
15
+
16
+ def native_attribute_aliases
17
+ super.concat([
18
+ ])
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,14 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Shopify
6
+ module V202407
7
+ class Order
8
+ class BillingAddress < ShippingAddress; end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,30 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Shopify
6
+ module V202407
7
+ class Order
8
+ class ShippingAddress < EPlat::Mapping::Base
9
+
10
+ def native_top_key
11
+ :itself
12
+ end
13
+
14
+ def native_attributes
15
+ super.concat([
16
+ ])
17
+ end
18
+
19
+ def native_attribute_aliases
20
+ super.concat([
21
+ ])
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,26 @@
1
+ module EPlat
2
+ class Mapping
3
+ module Shopify
4
+ module V202407 #< :module
5
+ class Order < EPlat::Mapping::Base
6
+
7
+ def native_top_key
8
+ "order"
9
+ end
10
+
11
+ def native_attributes
12
+ super.concat([
13
+ ])
14
+ end
15
+
16
+ def native_attribute_aliases
17
+ super.concat([
18
+ ])
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
@@ -0,0 +1,52 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Shopify
6
+ module V202407
7
+ class Product
8
+ class Image < EPlat::Mapping::Base
9
+
10
+ def native_top_key
11
+ :itself
12
+ end
13
+
14
+ def native_attributes
15
+ super.concat([
16
+ "id",
17
+ "alt_text", #would be altText before and after EPlat processes it
18
+ "width",
19
+ "height",
20
+ "url"
21
+ ])
22
+ end
23
+
24
+ def native_attribute_aliases
25
+ super.concat([
26
+ {
27
+ existing_entry: {native_key: "id", e_plat_key: "id",
28
+ custom_e_plat_getter: '-> { _1.try(:split, "/")&.last || _1 }',
29
+ custom_native_setter: '-> { "gid://shopify/ProductImage/#{_1}" }'
30
+ }
31
+ },
32
+ {
33
+ alias_attribute: {native_key: "alt_text", e_plat_key: "alt"}
34
+ },
35
+ {
36
+ existing_entry: {native_key: "width", e_plat_key: "width"}
37
+ },
38
+ {
39
+ existing_entry: {native_key: "height", e_plat_key: "height"}
40
+ },
41
+ {
42
+ alias_attribute: {native_key: "url", e_plat_key: "src"}
43
+ }
44
+ ])
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,45 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Shopify
6
+ module V202407
7
+ class Product
8
+ class Option < EPlat::Mapping::Base
9
+ include_root_in_request_body true
10
+
11
+ def native_top_key
12
+ :itself
13
+ end
14
+
15
+ def native_attributes
16
+ super
17
+ end
18
+
19
+ def native_attribute_aliases
20
+ super.concat([
21
+
22
+ {
23
+ existing_entry: {native_key: "id", e_plat_key: "id",
24
+ custom_e_plat_getter: '-> { _1&.split("/")&.last }',
25
+ custom_native_setter: '-> { "gid://shopify/ProductOption/#{_1}" }'
26
+ }
27
+ },
28
+ {
29
+ existing_entry: {native_key: "name", e_plat_key: "name"}
30
+ },
31
+ {
32
+ existing_entry: {native_key: "position", e_plat_key: "position"}
33
+ },
34
+ {
35
+ existing_entry: {native_key: "values", e_plat_key: "values"}
36
+ }
37
+ ])
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,58 @@
1
+
2
+
3
+ module EPlat
4
+ class Mapping
5
+ module Shopify
6
+ module V202407
7
+ class Product::Variant
8
+ class OptionValue < EPlat::Mapping::Base
9
+ include_root_in_request_body true
10
+
11
+ def native_top_key
12
+ :itself
13
+ end
14
+
15
+ def native_attributes
16
+ super.concat([
17
+ ])
18
+ end
19
+
20
+
21
+ def native_attribute_aliases
22
+ super.concat([
23
+ # see virtual_collection @ EPlat::Mapping::VirtualCollection::Shopify::Product::Variant::OptionValue
24
+ ])
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+
35
+ # bigcommerce
36
+ # option_values => [{
37
+ # "id": 174,
38
+ # "label": "Beige",
39
+ # "option_id": 220,
40
+ # "option_display_name": "Color"
41
+ # }]
42
+
43
+ # shopify
44
+ # selected_options => [{
45
+ # "name"=>"Size",
46
+ # "value"=>"green",
47
+ # "option_value" => {
48
+ # "id"=>"gid://shopify/ProductOptionValue/657155129475",
49
+ # "name"=>"green"
50
+ # }
51
+ # }]
52
+
53
+ # target e_plat schema
54
+ # option_values => [{
55
+ # "id": 174,
56
+ # "name": "Color",
57
+ # "value": "Beige",
58
+ # }]