e_plat 0.7.0 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d10eb52dda105627cb32fb58161da4777a8a020f6ea70ba4111da4487441e743
4
- data.tar.gz: 00ef52bdc6790981c6fcfb35615982c06b82152279d9a5f301ff3c84ad50747b
3
+ metadata.gz: 5577cb6f825d656e170ae63d33c027e9b50080040347496bdf96d3c4f09920c3
4
+ data.tar.gz: 75cde1f016be6b06f07ba9201655496c7262e47d1611e320193c9d994549561a
5
5
  SHA512:
6
- metadata.gz: f5951156f87b275af28cefeed42eff062aeb85155454a8b498c54d795843be40acd5245d1f20b5e724912abef7ef43b0dc47c4e09f2084ad1ad1fbab8418aafa
7
- data.tar.gz: 0af92dd3962135ec69c738eab60bc320e8add2de57832cc793ed11ab5118e1515a7a048623f75537e3c126ae1e78e9c109cab49685335d7a9860da655d611bdc
6
+ metadata.gz: 12484df951bb9fe2311ceb78e1b6ee3f990a82dcddc06702153da350b14e7b1e3c87180591536e80965eeff731c3a1d63f5012c8dceb8df7e86014c29d95479a
7
+ data.tar.gz: fe491070587b5284dc61d52db7bea1c2951e38bd6e0847b06d11b19077cf0468b7c35f8a7a19993bfac37632be6c9cabf863a30b76abcfab7c6929d064da26c3
data/README.md CHANGED
@@ -41,11 +41,11 @@ To your gemfile and then run
41
41
  You can configure which platform APIs are used by updating the EPlat config: <br/>
42
42
  ```ruby
43
43
  #initializers/e_plat.rb
44
- EPlat.config.shopify_api_version = "2024-01"
44
+ EPlat.config.shopify_api_version = "2024-07"
45
45
  EPlat.config.bigcommerce_api_version = "v3"
46
46
 
47
- # EPlat.api_display_name.shopify #=> "2024-01" # presents as the platform would display in URL paths
48
- # EPlat.config.shopify_api_version #=> "2024_01" # coerced interally for creating constants
47
+ # EPlat.api_display_name.shopify #=> "2024-07" # presents as the platform would display in URL paths
48
+ # EPlat.config.shopify_api_version #=> "2024_07" # coerced interally for creating constants
49
49
  # EPlat.config.print_graphql_requests #=> false # prints out Shopify graphql queries/mutations to the console
50
50
  ```
51
51
  <br>
@@ -109,7 +109,7 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
109
109
  tag.save
110
110
 
111
111
  # ...when session is a Shopify store
112
- # POST https://preproduct-test.myshopify.com/admin/api/2024-01/script_tags.json
112
+ # POST https://preproduct-test.myshopify.com/admin/api/2024-07/script_tags.json
113
113
  # body: '{"script_tag":{"display_scope":"online_store","event":"onload","src":"https://preproduct.io/mini-script.js"}}'
114
114
  #
115
115
  # ...when session is a BigCommerce store
@@ -267,6 +267,10 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
267
267
  | inventory_quantity | integer | getter only: node.inventoryQuantity | inventory_level | nil |
268
268
  | tax_code | string | * | nil | nil |
269
269
  | requires_shipping | boolean | InventoryItem[requiresShipping] | nil | nil |
270
+
271
+ helper methods: <br>
272
+ `image_src` => `String | nil`, platforms supported: Shopify, Bigcommerce
273
+
270
274
  *Bigcommerce variant.title= setter is not supported
271
275
 
272
276
 
@@ -290,7 +294,6 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
290
294
  | width | integer | * | nil | nil |
291
295
  | height | integer | * | nil | nil |
292
296
  | src | string | * | url_standard | nil |
293
- | variant_ids | array | * | nil | nil |
294
297
 
295
298
 
296
299
  ### EPlat::Product::Variant::OptionValue
@@ -835,6 +838,7 @@ EPlat::Product.find(my_id).destroy
835
838
  product = EPlat::Product.new(title: 't-shirt')
836
839
  product.save # true or false
837
840
  product.errors # active record like errors if .save returned false
841
+ product.formatted_id #returns the resource ID in the platform's format. i.e. Shopify Product would be "gid://shopify/Product/xxx", Shopify Order would be 123, BC order: 123
838
842
 
839
843
  product.full_response # <Net::HTTPOK>
840
844
  product.headers # { "date"=>"Fri, 17 Nov 2023 14:25:53 GMT", ...}
@@ -856,8 +860,8 @@ EPlat::Product.find(99, from: "/product/1/specific_url.json") #GET /product/1/sp
856
860
  EPlat::Product.count # 2
857
861
 
858
862
  # Nested resources - pass in the parent resource's ID to the params hash
859
- EPlat::Product::Variant.find(variant_id, params: {product: product.id}) # /admin/api/2024-01/products/{{ product.id }}/variants/{{ variant_id }}.json
860
- EPlat::Product::Variant.collection_path(product: 5) # /admin/api/2024-01/products/5/variants.json
863
+ EPlat::Product::Variant.find(variant_id, params: {product: product.id}) # /admin/api/2024-07/products/{{ product.id }}/variants/{{ variant_id }}.json
864
+ EPlat::Product::Variant.collection_path(product: 5) # /admin/api/2024-07/products/5/variants.json
861
865
 
862
866
 
863
867
 
@@ -8,6 +8,7 @@ module EPlat
8
8
 
9
9
  self.connection_class = EPlat::Connection
10
10
  self.collection_parser = EPlat::Collection
11
+ self.timeout = 10
11
12
  self.site = "/" # this is overwritten below in initialize_singleton! when EPlat::Session is initialized
12
13
  add_response_method :full_response #full response of the request
13
14
 
@@ -129,7 +130,7 @@ module EPlat
129
130
  top_level_resource?
130
131
  end
131
132
 
132
- def formatted_id(id)
133
+ def formatted_id
133
134
  return id unless client.shopify? && client.api_version != "2024_01"
134
135
  return if id.to_s.include?("gid://")
135
136
 
@@ -236,7 +236,7 @@ module EPlat
236
236
  additional_graphql = self.class.before_graphql_callbacks[action.to_sym]&.call(self)
237
237
  input =
238
238
  if action == :delete
239
- self.is_a?(EPlat::Product::Variant) ? graphql_input.new(id: formatted_id(id)) : graphql_input.new({id: formatted_id(id)})
239
+ self.is_a?(EPlat::Product::Variant) ? graphql_input.new(id: formatted_id) : graphql_input.new({id: formatted_id})
240
240
  else
241
241
  graphql_input.new mapping.via_native_attributes_where_possible(self.class.remove_root_from as_json)
242
242
  end
@@ -90,7 +90,7 @@ module EPlat
90
90
  def unrepresented_collection_ids(key, array_of_hashes)
91
91
  return [] unless client.can_update_nested_resources?
92
92
 
93
- all_instance_ids = send(key).map{|resource| resource.formatted_id resource.id} || []
93
+ all_instance_ids = send(key).map{|resource| resource.formatted_id} || []
94
94
  represented_instance_ids = array_of_hashes.map{|item| item["id"] }
95
95
 
96
96
  all_instance_ids.compact - represented_instance_ids.compact
@@ -29,7 +29,7 @@ class EPlat::Shopify::Product::Variant < EPlat::Product::Variant
29
29
  barcode
30
30
  weight
31
31
  image {
32
- id
32
+ #{ EPlat::Shopify::Product::Image.graphql_fields }
33
33
  }
34
34
  inventoryItem {
35
35
  id
@@ -9,6 +9,7 @@ module EPlat
9
9
 
10
10
  schema do
11
11
  integer :id
12
+ integer :product_id # nil-able because of Shopify GraphQL
12
13
  string :alt
13
14
  integer :width
14
15
  integer :height
@@ -34,6 +34,15 @@ module EPlat
34
34
  prefix_options[:product] ||= try(:product)&.id
35
35
  super
36
36
  end
37
+
38
+ def image_src
39
+ if client.bigcommerce?
40
+ image_url
41
+ elsif client.shopify? && client.uses_graphql_for_products?
42
+ image&.src
43
+ end
44
+ end
45
+
37
46
  end
38
47
  end
39
48
  end
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e_plat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-29 00:00:00.000000000 Z
11
+ date: 2024-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.3'
19
+ version: '2'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '2.3'
29
+ version: '2'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2'
@@ -36,7 +36,7 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 7.0.4
39
+ version: '7.0'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: '7.0'
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 7.0.4
49
+ version: '7.0'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
52
  version: '7.0'
@@ -156,7 +156,7 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: 1.7.2
159
+ version: '1.7'
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '1.0'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: 1.7.2
169
+ version: '1.7'
170
170
  - - ">="
171
171
  - !ruby/object:Gem::Version
172
172
  version: '1.0'
@@ -176,7 +176,7 @@ dependencies:
176
176
  requirements:
177
177
  - - "~>"
178
178
  - !ruby/object:Gem::Version
179
- version: '3.18'
179
+ version: '3'
180
180
  - - ">="
181
181
  - !ruby/object:Gem::Version
182
182
  version: '3'
@@ -186,7 +186,7 @@ dependencies:
186
186
  requirements:
187
187
  - - "~>"
188
188
  - !ruby/object:Gem::Version
189
- version: '3.18'
189
+ version: '3'
190
190
  - - ">="
191
191
  - !ruby/object:Gem::Version
192
192
  version: '3'
@@ -196,7 +196,7 @@ dependencies:
196
196
  requirements:
197
197
  - - "~>"
198
198
  - !ruby/object:Gem::Version
199
- version: '6.1'
199
+ version: '6'
200
200
  - - ">="
201
201
  - !ruby/object:Gem::Version
202
202
  version: 6.0.0
@@ -206,7 +206,7 @@ dependencies:
206
206
  requirements:
207
207
  - - "~>"
208
208
  - !ruby/object:Gem::Version
209
- version: '6.1'
209
+ version: '6'
210
210
  - - ">="
211
211
  - !ruby/object:Gem::Version
212
212
  version: 6.0.0
@@ -216,7 +216,7 @@ dependencies:
216
216
  requirements:
217
217
  - - "~>"
218
218
  - !ruby/object:Gem::Version
219
- version: '2.8'
219
+ version: '2'
220
220
  - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '2'
@@ -226,7 +226,7 @@ dependencies:
226
226
  requirements:
227
227
  - - "~>"
228
228
  - !ruby/object:Gem::Version
229
- version: '2.8'
229
+ version: '2'
230
230
  - - ">="
231
231
  - !ruby/object:Gem::Version
232
232
  version: '2'
@@ -236,7 +236,7 @@ dependencies:
236
236
  requirements:
237
237
  - - "~>"
238
238
  - !ruby/object:Gem::Version
239
- version: 0.16.0
239
+ version: '0.16'
240
240
  - - ">="
241
241
  - !ruby/object:Gem::Version
242
242
  version: 0.1.0
@@ -246,7 +246,7 @@ dependencies:
246
246
  requirements:
247
247
  - - "~>"
248
248
  - !ruby/object:Gem::Version
249
- version: 0.16.0
249
+ version: '0.16'
250
250
  - - ">="
251
251
  - !ruby/object:Gem::Version
252
252
  version: 0.1.0