e_plat 0.4.0 → 0.4.2

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: 386e1215b6388dde3ca778ad764b974cdd0ccb6826d40b3818d66b06835873a7
4
- data.tar.gz: 23d5a40e0cf55a8ad322f6964ebf9d6b78b0bcff4ae087de6bf0d48ee7928684
3
+ metadata.gz: 21cc14088c5f2804d52659aab7cfedb0ec808d42a1beb5a8a29ad4525f670d36
4
+ data.tar.gz: 24f4aba2574e129d4b8f00b7a4ddbefe71ddf3465cd2b5336348c94870685be8
5
5
  SHA512:
6
- metadata.gz: bc3dbea0f0ee2819422cc4fde686fce0a9916810ec7204cc665941f27ac110a9d4c0998beb32752cad3c28549210b3892d8066dd8f41257b35b481da93fb31c1
7
- data.tar.gz: 4ed2081d31de4c5217ccdf8de95b019111da428c53046a098d67902d5776e98eb884eb52a0d18dd83257476694b9b02275c15fe0ce48d019373d97f99211a1f8
6
+ metadata.gz: 3b95cf6b98b113934622fd3a093469646749e51c92dd268626419ca3da8ec0573461908087bb99a3a91c43e895e77c702ed7f6c6149df4c40a2f7632b73ea1a0
7
+ data.tar.gz: e42d9978e0dcecea62c891a907527a050dbbe89b0a1e7d72cb4c490f633eb21a4dad71ea1d0d0898f905637cc4984175c680309a20b8677cc453b42cb3584230
data/README.md CHANGED
@@ -82,7 +82,7 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
82
82
  )
83
83
  tag.name = "mini script" if Current.e_plat_session.bigcommerce?
84
84
  tag.save
85
-
85
+
86
86
  # ...when session is a Shopify store
87
87
  # POST https://preproduct-test.myshopify.com/admin/api/2024-01/script_tags.json
88
88
  # body: '{"script_tag":{"display_scope":"online_store","event":"onload","src":"https://preproduct.io/mini-script.js"}}'
@@ -829,8 +829,14 @@ product.mapped? "body_html" #check if a platforms resource is mapped to a specif
829
829
 
830
830
  # In the context of a Bigcommerce product that has aliases:
831
831
  product.changed_attributes # {}
832
- product.name = oi
833
- product.changed_attributes # {"name"=>"hey", "title"=>"hey"}
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.
835
+
836
+ product.as_json # hash of any updated attributes
837
+ product.as_full_json # hash of all attributes, regardless of if they've been updated or not
838
+ product.to_json # JSON string of any updated_attributes
839
+ product.to_full_json # JSON string of all attributes. regardless of if they've been updated or not
834
840
 
835
841
  ```
836
842
 
@@ -3,7 +3,7 @@
3
3
  module EPlat
4
4
  class Base < ActiveResource::Base
5
5
  include Concerns::OverwriteRequestMethods, Concerns::OverwriteInstanceMethods
6
- include Concerns::Aliases, Concerns::Dirty
6
+ include Concerns::Aliases, Concerns::Dirty, Concerns::FullJson
7
7
 
8
8
  self.connection_class = EPlat::Connection
9
9
  self.collection_parser = EPlat::Collection
@@ -0,0 +1,28 @@
1
+ module EPlat
2
+ module Concerns
3
+ module FullJson
4
+ extend ActiveSupport::Concern
5
+
6
+ def to_full_json # '{}'
7
+ as_full_json.to_json
8
+ end
9
+
10
+ def as_full_json # {}
11
+ self.attributes.each_with_object({}) do |(key, value), result|
12
+ result[key] =
13
+ case
14
+ when value.is_a?(EPlat::Base)
15
+ value.as_full_json
16
+ when value.is_a?(Array)
17
+ value.map do |v|
18
+ v.is_a?(EPlat::Base) ? v.as_full_json : v
19
+ end
20
+ else
21
+ value
22
+ end
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -5,8 +5,6 @@ module EPlat
5
5
  module Metafieldable #< ActiveResource::CustomMethods
6
6
 
7
7
  def metafields(**options)
8
- options.merge!(resource: self.class.collection_name, resource_id: id)
9
-
10
8
  Metafield.find(:all,
11
9
  from: current_resources_metafield_path,
12
10
  params: options
@@ -29,7 +29,7 @@ module EPlat
29
29
  super
30
30
  end
31
31
 
32
- def new(attributes, persisted = false)
32
+ def new(attributes={}, persisted = false)
33
33
  initialize_singleton!
34
34
 
35
35
  self.mapping = EPlat::Mapping.new_instance(specifc_mapping: specifc_mapping_name, resource: nil)
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/e_plat.rb CHANGED
@@ -20,9 +20,18 @@ loader.setup # ready!
20
20
 
21
21
  module EPlat
22
22
  extend Dry::Configurable
23
+ SUPPORTED_SHOPIFY_API_VERSIONS = ['2024_01']
24
+ SUPPORTED_BIGCOMMERCE_API_VERSIONS = ['3']
25
+
26
+ setting(:shopify_api_version, default: "2024_01", constructor: ->(value) do
27
+ SUPPORTED_SHOPIFY_API_VERSIONS.include?(value.underscore) ? value.underscore : raise(ArgumentError, "Shopify API version #{value} is not supported")
28
+ end)
29
+
30
+ setting(:bigcommerce_api_version, default: "v3", constructor: ->(value) do
31
+ v = value.downcase.gsub("v", "")
32
+ SUPPORTED_BIGCOMMERCE_API_VERSIONS.include?(v) ? v : raise(ArgumentError, "Bigcommerce API version #{value} is not supported")
33
+ end)
23
34
 
24
- setting(:shopify_api_version, default: "2024_01", constructor: ->(value) { value.underscore })
25
- setting(:bigcommerce_api_version, default: "v3", constructor: ->(value) { value.downcase.gsub("v", "") })
26
35
  setting(:woocommerce_api_version, default: "v3", constructor: ->(value) { value.downcase.gsub("v", "") })
27
36
 
28
37
  class Error < StandardError; 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.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 6.0.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: activeresource-response
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: dry-configurable
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +248,7 @@ files:
234
248
  - lib/e_plat/resource/collection.rb
235
249
  - lib/e_plat/resource/concerns/aliases.rb
236
250
  - lib/e_plat/resource/concerns/dirty.rb
251
+ - lib/e_plat/resource/concerns/full_json.rb
237
252
  - lib/e_plat/resource/concerns/metafieldable.rb
238
253
  - lib/e_plat/resource/concerns/overwrite_instance_methods.rb
239
254
  - lib/e_plat/resource/concerns/overwrite_request_methods.rb