e_plat 0.7.2 → 0.7.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5af5d23022fca18e27cc070f5975bd15c7aba8f7df53b3a764c9c1ba0a285284
4
- data.tar.gz: c4b5f3ad678da9135a7f840028ede728ea16b0ee15f66d0d5edac60f5b805bf0
3
+ metadata.gz: 5577cb6f825d656e170ae63d33c027e9b50080040347496bdf96d3c4f09920c3
4
+ data.tar.gz: 75cde1f016be6b06f07ba9201655496c7262e47d1611e320193c9d994549561a
5
5
  SHA512:
6
- metadata.gz: d0bdc8f94fb56bf2f7b36ea92cfbe3664caeb7ebd200d9d6215247f61b92b90f0f7e4a48b1aa860e4a8d6de35621f20621fe6ba2824389580bfb3109c15ab428
7
- data.tar.gz: 801cd77a5959527f12b62d24a104e829069049a1d66664db2fbe18aa04cb09944d9971dbe8f78496684409e20efc4d5e298b0b289ddcc2087f07443051558b7c
6
+ metadata.gz: 12484df951bb9fe2311ceb78e1b6ee3f990a82dcddc06702153da350b14e7b1e3c87180591536e80965eeff731c3a1d63f5012c8dceb8df7e86014c29d95479a
7
+ data.tar.gz: fe491070587b5284dc61d52db7bea1c2951e38bd6e0847b06d11b19077cf0468b7c35f8a7a19993bfac37632be6c9cabf863a30b76abcfab7c6929d064da26c3
data/README.md CHANGED
@@ -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", ...}
@@ -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.2"
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.2
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-30 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