e_plat 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -6
  3. data/lib/e_plat/client.rb +21 -1
  4. data/lib/e_plat/initializer.rb +26 -0
  5. data/lib/e_plat/mapping.rb +39 -15
  6. data/lib/e_plat/resource/base.rb +15 -3
  7. data/lib/e_plat/resource/concerns/overwrite_request_methods.rb +64 -21
  8. data/lib/e_plat/resource/metafield.rb +2 -2
  9. data/lib/e_plat/resource/platform_specific/bigcommerce/metafield.rb +4 -0
  10. data/lib/e_plat/resource/platform_specific/bigcommerce/order/Consignment.rb +2 -0
  11. data/lib/e_plat/resource/platform_specific/bigcommerce/order/billing_address.rb +2 -0
  12. data/lib/e_plat/resource/platform_specific/bigcommerce/order/fulfillment.rb +2 -0
  13. data/lib/e_plat/resource/platform_specific/bigcommerce/order/line_item.rb +2 -0
  14. data/lib/e_plat/resource/platform_specific/bigcommerce/order/shipping_address.rb +2 -0
  15. data/lib/e_plat/resource/platform_specific/bigcommerce/order/shipping_line.rb +2 -0
  16. data/lib/e_plat/resource/platform_specific/bigcommerce/order.rb +4 -0
  17. data/lib/e_plat/resource/platform_specific/bigcommerce/product/image.rb +2 -0
  18. data/lib/e_plat/resource/platform_specific/bigcommerce/product/option.rb +2 -0
  19. data/lib/e_plat/resource/platform_specific/bigcommerce/product/variant.rb +2 -0
  20. data/lib/e_plat/resource/platform_specific/bigcommerce/product.rb +4 -0
  21. data/lib/e_plat/resource/platform_specific/bigcommerce/script_tag.rb +4 -0
  22. data/lib/e_plat/resource/platform_specific/bigcommerce/shop.rb +4 -0
  23. data/lib/e_plat/resource/platform_specific/bigcommerce/webhook.rb +4 -0
  24. data/lib/e_plat/resource/platform_specific/shopify/metafield.rb +4 -0
  25. data/lib/e_plat/resource/platform_specific/shopify/order/Consignment.rb +2 -0
  26. data/lib/e_plat/resource/platform_specific/shopify/order/billing_address.rb +2 -0
  27. data/lib/e_plat/resource/platform_specific/shopify/order/fulfillment.rb +2 -0
  28. data/lib/e_plat/resource/platform_specific/shopify/order/line_item.rb +2 -0
  29. data/lib/e_plat/resource/platform_specific/shopify/order/shipping_address.rb +2 -0
  30. data/lib/e_plat/resource/platform_specific/shopify/order/shipping_line.rb +2 -0
  31. data/lib/e_plat/resource/platform_specific/shopify/order.rb +4 -0
  32. data/lib/e_plat/resource/platform_specific/shopify/product/image.rb +2 -0
  33. data/lib/e_plat/resource/platform_specific/shopify/product/option.rb +2 -0
  34. data/lib/e_plat/resource/platform_specific/shopify/product/variant.rb +2 -0
  35. data/lib/e_plat/resource/platform_specific/shopify/product.rb +4 -0
  36. data/lib/e_plat/resource/platform_specific/shopify/recurring_application_charge/usage_charge.rb +2 -0
  37. data/lib/e_plat/resource/platform_specific/shopify/recurring_application_charge.rb +4 -0
  38. data/lib/e_plat/resource/platform_specific/shopify/script_tag.rb +4 -0
  39. data/lib/e_plat/resource/platform_specific/shopify/shop.rb +4 -0
  40. data/lib/e_plat/resource/platform_specific/shopify/webhook.rb +4 -0
  41. data/lib/e_plat/resource/product/variant.rb +2 -4
  42. data/lib/e_plat/type_coercer.rb +1 -1
  43. data/lib/e_plat/version.rb +1 -1
  44. data/lib/e_plat.rb +21 -1
  45. metadata +35 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85b0fb58fb552bdd494649429de66feb12612b53ee0cf49bda4b1a87e14e81b7
4
- data.tar.gz: e5702192f1057e1f65736e20c88d7c35a4d6490db785d0dc4ef95381015cc6b2
3
+ metadata.gz: e9dbde4e59673eba0dc91580fd4f4f50bc138c380cfa00a78a2be1de12f1706c
4
+ data.tar.gz: 9998fa572e61d5e043fdbe2ec804c18cde16c65f2bb64534003a5f00e0034d38
5
5
  SHA512:
6
- metadata.gz: ac493807a5ffc4e61a7eb7d5fa4b28777697a9aa5c50a8cb145e8d1327bef821f8efcdacc672e6652778fb3b3c5c5961d76d5844d4a874a2f2bdacdf3b7896e8
7
- data.tar.gz: c69b4fb8c31be9eecaaf6e587bbdd964a4a7ff046a844f0e3c81063d95a156fffe5667d9273a40e3e25fed5460e780bf02b2a5f29b7eb215d55c7806b15d718d
6
+ metadata.gz: d855f8148b8df76db6202da298128a8e3c9f8ba1b1adebd7824182e80676ff6f242c59f3aa54cc791b6567f04e1741fefe7a643fe2c7e8523c93d0fb7cbc0236
7
+ data.tar.gz: 8c478644bf379156b98e80992edbec4a24baa95e854a8d9864abc92c0e8c73ea4e4d4d9980c3957926eb70164e3f547fbfaffd88373fbc3bc1859dd7e8c80101
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  <strong>EPlat <small>(E-commerce Platform)</small> </br></strong>
4
4
  A single interface for interacting with E-commerce platform APIs.
5
5
 
6
- Goals are:
6
+ Goals:
7
7
  <ul>
8
8
  <li>
9
9
  Make it easy to use and request API resources from different platforms.
@@ -12,7 +12,7 @@ Goals are:
12
12
  Offer a universal alias interface for interacting with common natured attributes. e.g. Shopify's product.body_html and BigCommerce's product.description.
13
13
  </li>
14
14
  <li>
15
- Have a simple, easy-to-understand, lightweight project structure.
15
+ Have a simple, easy-to-understand project structure.
16
16
  </li>
17
17
  <li>
18
18
  The e_plat alias interface mimics Shopify's API schema names and types.
@@ -43,7 +43,6 @@ You can configure which platform APIs are used by updating the EPlat config: <br
43
43
  #initializers/e_plat.rb
44
44
  EPlat.config.shopify_api_version = "2024-01"
45
45
  EPlat.config.bigcommerce_api_version = "v3"
46
- EPlat.config.woocommerce_api_version = "v3"
47
46
 
48
47
  # EPlat.api_display_name.shopify #=> "2024-01" # presents as the platform would display in URL paths
49
48
  # EPlat.config.shopify_api_version #=> "2024_01" # coerced interally for creating constants
@@ -62,7 +61,7 @@ EPlat::Session.new(
62
61
  platform: :shopify,
63
62
  store_url: "test-store.myshopify.com",
64
63
  api_token: "123",
65
- # store_hash: optional BigCommerce store hash
64
+ # store_hash: "optional BigCommerce store hash"
66
65
  )
67
66
  ```
68
67
 
@@ -71,7 +70,7 @@ EPlat::Session.new(
71
70
  EPlat::Product.find(id: 123)
72
71
  ```
73
72
 
74
- 3. Which will return an instance of:
73
+ 3. Which will return a platform resource instance that inherits from:
75
74
  ```ruby
76
75
  EPlat::Product
77
76
  ```
@@ -412,6 +411,26 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
412
411
  | longitude | float | * | nil | nil |
413
412
 
414
413
 
414
+ ### EPlat::Order::BillingAddress
415
+
416
+ | Alias | Type | Shopify | BigCommerce | Etc |
417
+ |---------------|---------|---------|-------------|-------------|
418
+ | address1 | string | * | street_1 | nil |
419
+ | address2 | string | * | street_2 | nil |
420
+ | city | string | * | city | nil |
421
+ | company | string | * | company | nil |
422
+ | country | string | * | country | nil |
423
+ | first_name | string | * | first_name | nil |
424
+ | last_name | string | * | last_name | nil |
425
+ | phone | string | * | phone | nil |
426
+ | province | string | * | state | nil |
427
+ | zip | string | * | zip | nil |
428
+ | country_code | string | * | country_iso2| nil |
429
+ | province_code | string | * | nil | nil |
430
+ | latitude | float | * | nil | nil |
431
+ | longitude | float | * | nil | nil |
432
+
433
+
415
434
  ### EPlat::Order::LineItem
416
435
 
417
436
  | Attribute | Type | Shopify | BigCommerce | Etc |
@@ -749,7 +768,7 @@ Unfortunately it's in a Time Integer format. Haven't yet got dynamic conversion
749
768
  (although should be kept track of locally)
750
769
  </li>
751
770
  <li>
752
- <strong>GraphQL</strong>. EPlat just handles REST
771
+ <strong>GraphQL</strong>. EPlat just handles REST (for now, although we plan to change the internals for Shopify product to use Graphql under the hood)
753
772
  <ul>
754
773
  </details>
755
774
 
data/lib/e_plat/client.rb CHANGED
@@ -16,6 +16,20 @@ module EPlat
16
16
  def headers
17
17
  platform_headers
18
18
  end
19
+
20
+ # Dynamically determines the class based on the platform
21
+ # needs to return nil if there isn't a more specific class than the klass passed in
22
+ def platform_klass(klass)
23
+ return if klass.to_s.include? "EPlat::#{platform.capitalize}"
24
+ platform_specific_class_name = klass.to_s.gsub("EPlat::", "EPlat::#{platform.capitalize}::")
25
+
26
+ platform_specific_class = platform_specific_class_name.safe_constantize
27
+ if platform_specific_class_name != klass.to_s && platform_specific_class
28
+ platform_specific_class
29
+ else
30
+ nil
31
+ end
32
+ end
19
33
 
20
34
  def inspect
21
35
  "#<#{self.class} platform=#{platform.inspect} store_url=#{store_url.inspect} api_version=#{api_version.inspect}>"
@@ -42,8 +56,14 @@ module EPlat
42
56
 
43
57
  def url_prefix(klass: nil)
44
58
  # for nested resources like "/products/:product/variants/:id"
59
+ klass_without_platform_scoping = nil
60
+ EPlat::SUPPORTED_PLATFORMS.each do |platform|
61
+ klass_without_platform_scoping = klass.to_s.gsub!("#{ platform.capitalize }::", "") if klass.to_s.include?("#{ platform.capitalize }::")
62
+ end
63
+ klass = klass_without_platform_scoping&.safe_constantize || klass
64
+
45
65
  collection_path =
46
- if klass.to_s.scan("::").length == 2
66
+ if klass.to_s.scan("::").length > 1
47
67
  parent_klass = klass.to_s.split("::")[1].underscore
48
68
  "#{ parent_klass.pluralize }/:#{ parent_klass }/"
49
69
  else
@@ -0,0 +1,26 @@
1
+ module EPlat
2
+ class Initializer
3
+ class << self
4
+
5
+ REQUIRED_CLASSES = EPlat::SUPPORTED_RESOURCES.map do |resource|
6
+ [
7
+ "EPlat::#{ resource.classify }",
8
+ EPlat::SUPPORTED_PLATFORMS.map do |platform|
9
+ "EPlat::#{ platform.classify }::#{ resource.classify }"
10
+ end
11
+ ]
12
+ end.flatten.freeze
13
+
14
+ def check_required_classes!
15
+ REQUIRED_CLASSES.each do |klass|
16
+ unless Object.const_defined?(klass)
17
+ raise EPlat::Error, "Required class #{klass} not defined"
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
26
+
@@ -1,19 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EPlat
4
- class Mapping
5
-
6
- class << self
7
-
8
- def new_instance(specifc_mapping:, resource: nil)
9
- if Object.const_defined?(specifc_mapping)
10
- mapping = specifc_mapping.constantize.new(resource)
11
- else
12
- mapping = EPlat::Mapping::Base.new(resource)
13
- end
14
- end
15
-
16
- end
17
-
18
- end
4
+ class Mapping
5
+
6
+ class << self
7
+
8
+ def new_instance(specifc_mapping:, resource: nil)
9
+ platform = EPlat::Current.e_plat_session.platform.to_s
10
+ sanitized_mapping = sanitize_mapping(specifc_mapping, platform)
11
+
12
+ if Object.const_defined?(sanitized_mapping)
13
+ sanitized_mapping.constantize.new(resource)
14
+ elsif Object.const_defined?(specifc_mapping)
15
+ specifc_mapping.constantize.new(resource)
16
+ else
17
+ EPlat::Mapping::Base.new(resource)
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def sanitize_mapping(specifc_mapping, platform)
24
+ # Stripe out all instanced of the platform scope in the mapping
25
+ # then put platform back in as third scope, as mapping is always platform scoped.
26
+ # i.e. EPlat::Mapping::Bigcommerce::V3::Product::Variant
27
+ parts = specifc_mapping.split("::")
28
+
29
+ parts.reject! do |part|
30
+ platform.downcase == part.downcase
31
+ end
32
+
33
+ parts.insert(2, platform.capitalize)
34
+
35
+ parts.join("::")
36
+ end
37
+
38
+
39
+ end
40
+
41
+ end
19
42
  end
43
+
@@ -8,7 +8,7 @@ module EPlat
8
8
  self.connection_class = EPlat::Connection
9
9
  self.collection_parser = EPlat::Collection
10
10
  self.site = "/" # this is overwritten below in initialize_singleton! when EPlat::Session is initialized
11
- add_response_method :full_response
11
+ add_response_method :full_response #full response of the request
12
12
 
13
13
  class << self
14
14
  include Countable
@@ -18,6 +18,12 @@ module EPlat
18
18
  threadsafe_attribute :_headers, :_connection, :_user, :_password, :_bearer_token, :_site, :_proxy, # active resource
19
19
  :mapping, :include_root_in_json, :include_format_in_path # e_plat specific
20
20
 
21
+ def inherited(subclass)
22
+ super
23
+ subclass.exclude_from_json(read_only) if read_only
24
+ subclass.schema ||= schema.dup
25
+ end
26
+
21
27
  def initialize_singleton!
22
28
  self.site = client.base_url # .site is an ActiveResource method that uses the threadsafe _site attribute underneath
23
29
  self.prefix = client.url_prefix(klass: self) # this is overwritten below in prefix= for threadsafety
@@ -60,6 +66,9 @@ module EPlat
60
66
  self.read_only = read_only
61
67
  end
62
68
 
69
+ def platform_specific_class?
70
+ self.class.to_s.include? client.platform.to_s.capitalize
71
+ end
63
72
 
64
73
  private
65
74
 
@@ -118,7 +127,6 @@ module EPlat
118
127
  top_level_resource?
119
128
  end
120
129
 
121
-
122
130
  private
123
131
 
124
132
  def ensure_e_plat_attributes!
@@ -170,7 +178,11 @@ module EPlat
170
178
  end
171
179
 
172
180
  def top_level_resource?
173
- self.class.name.split("::").count <= 2
181
+ parts = self.class.name.split("::")
182
+ # platform scope not included, as top level resources can optionally be platform specific
183
+ parts.reject!{|part| EPlat::SUPPORTED_PLATFORMS.include? part.downcase }
184
+
185
+ parts.count <= 2
174
186
  end
175
187
 
176
188
  def element_name
@@ -8,16 +8,22 @@ module EPlat
8
8
 
9
9
  module ClassMethods
10
10
  def find(*arguments)
11
- initialize_singleton!
11
+ client = EPlat::Current.e_plat_session
12
12
 
13
- if arguments.second && arguments.second[:params]
14
- arguments.second[:params].merge!(client.try("#{element_name}_default_request_args") || {})
15
- arguments.second[:params] = mapping.via_native_attributes_where_possible(arguments.second[:params])
13
+ if client.platform_klass(self) and not platform_specific_class?
14
+ client.platform_klass(self).find(*arguments)
16
15
  else
17
- arguments << {params: (client.try("#{element_name}_default_request_args") || {}) }
18
- end
16
+ initialize_singleton!
19
17
 
20
- super
18
+ if arguments.second && arguments.second[:params]
19
+ arguments.second[:params].merge!(client.try("#{element_name}_default_request_args") || {})
20
+ arguments.second[:params] = mapping.via_native_attributes_where_possible(arguments.second[:params])
21
+ else
22
+ arguments << {params: (client.try("#{element_name}_default_request_args") || {}) }
23
+ end
24
+
25
+ super
26
+ end
21
27
  end
22
28
 
23
29
  def find_by(params)
@@ -30,30 +36,67 @@ module EPlat
30
36
  end
31
37
 
32
38
  def new(attributes={}, persisted = false)
33
- initialize_singleton!
39
+ if client.platform_klass(self) and not platform_specific_class?
40
+ client.platform_klass(self).new(attributes, persisted)
41
+ else
42
+ initialize_singleton!
34
43
 
35
- self.mapping = EPlat::Mapping.new_instance(specifc_mapping: specifc_mapping_name, resource: nil)
44
+ self.mapping = EPlat::Mapping.new_instance(specifc_mapping: specifc_mapping_name, resource: nil)
36
45
 
37
- if attributes[mapping.native_top_key]
38
- attributes = attributes.send(*top_key_method(mapping.native_top_key))
39
- end
40
- attributes = attributes.with_defaults(mapping.class::DEFAULT_VALUES)
46
+ if attributes[mapping.native_top_key]
47
+ attributes = attributes.send(*top_key_method(mapping.native_top_key))
48
+ end
49
+ attributes = attributes.with_defaults(mapping.class::DEFAULT_VALUES)
41
50
 
42
- super
51
+ super
52
+ end
43
53
  end
44
54
 
45
55
  def create(attributes = {})
46
- initialize_singleton!
47
- attributes = mapping.via_native_attributes_where_possible(attributes)
56
+ client = EPlat::Current.e_plat_session
48
57
 
49
- super
58
+ if client.platform_klass(self)
59
+ client.platform_klass(self).create(attributes)
60
+ else
61
+ initialize_singleton!
62
+ attributes = mapping.via_native_attributes_where_possible(attributes)
63
+ super
64
+ end
50
65
  end
51
66
 
52
67
  def update(attributes = {})
53
- initialize_singleton!
54
- attributes = mapping.via_native_attributes_where_possible(attributes)
55
-
56
- super
68
+ client = EPlat::Current.e_plat_session
69
+
70
+ if client.platform_klass(self)
71
+ client.platform_klass(self).update(attributes)
72
+ else
73
+ initialize_singleton!
74
+ attributes = mapping.via_native_attributes_where_possible(attributes)
75
+
76
+ super
77
+ end
78
+ end
79
+
80
+ def delete(id, options = {})
81
+ client = EPlat::Current.e_plat_session
82
+
83
+ if client.platform_klass(self)
84
+ client.platform_klass(self).delete(id, options)
85
+ else
86
+ initialize_singleton!
87
+ super
88
+ end
89
+ end
90
+
91
+ def exists?(id, options = {})
92
+ client = EPlat::Current.e_plat_session
93
+
94
+ if client.platform_klass(self)
95
+ client.platform_klass(self).exists?(id, options)
96
+ else
97
+ initialize_singleton!
98
+ super
99
+ end
57
100
  end
58
101
 
59
102
  private
@@ -48,8 +48,8 @@ module EPlat
48
48
 
49
49
  def parent_class
50
50
  raise "owner_resource is not defined" unless owner_resource.present?
51
-
52
- "EPlat::#{ owner_resource.classify }".constantize # e.g EPlat::Product
51
+
52
+ client.platform_klass("EPlat::#{ owner_resource.classify }") || "EPlat::#{ owner_resource.classify }".constantize # e.g EPlat::Product
53
53
  end
54
54
 
55
55
 
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Bigcommerce
3
+ class Metafield < EPlat::Metafield; end
4
+ end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Order::Consignment < EPlat::Order::Consignment; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Order::BillingAddress < EPlat::Order::BillingAddress; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Order::Fulfillment < EPlat::Order::Fulfillment; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Order::LineItem < EPlat::Order::LineItem; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Order::ShippingAddress < EPlat::Order::ShippingAddress; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Order::ShippingLine < EPlat::Order::ShippingLine; end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Bigcommerce
3
+ class Order < EPlat::Order; end
4
+ end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Product::Image < EPlat::Product::Image; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Product::Option < EPlat::Product::Option; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Bigcommerce::Product::Variant < EPlat::Product::Variant; end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Bigcommerce
3
+ class Product < EPlat::Product; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Bigcommerce
3
+ class ScriptTag < EPlat::ScriptTag; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Bigcommerce
3
+ class Shop < EPlat::Shop; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Bigcommerce
3
+ class Webhook < EPlat::Webhook; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class Metafield < EPlat::Metafield; end
4
+ end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Order::Consignment < EPlat::Order::Consignment; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Order::BillingAddress < EPlat::Order::BillingAddress; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Order::Fulfillment < EPlat::Order::Fulfillment; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Order::LineItem < EPlat::Order::LineItem; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Order::ShippingAddress < EPlat::Order::ShippingAddress; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Order::ShippingLine < EPlat::Order::ShippingLine; end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class Order < EPlat::Order; end
4
+ end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Product::Image < EPlat::Product::Image; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Product::Option < EPlat::Product::Option; end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::Product::Variant < EPlat::Product::Variant; end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class Product < EPlat::Product; end
4
+ end
@@ -0,0 +1,2 @@
1
+
2
+ class EPlat::Shopify::RecurringApplicationCharge::UsageCharge < EPlat::RecurringApplicationCharge::UsageCharge; end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class RecurringApplicationCharge < EPlat::RecurringApplicationCharge; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class ScriptTag < EPlat::ScriptTag; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class Shop < EPlat::Shop; end
4
+ end
@@ -0,0 +1,4 @@
1
+
2
+ module EPlat::Shopify
3
+ class Webhook < EPlat::Webhook; end
4
+ end
@@ -3,8 +3,7 @@ module EPlat
3
3
  class Variant < Base
4
4
  belongs_to :product, class_name: "EPlat::Product"
5
5
 
6
- class << self
7
- end
6
+ class << self; end
8
7
 
9
8
  schema do
10
9
  integer :id
@@ -41,7 +40,6 @@ module EPlat
41
40
  prefix_options[:product] ||= product.id
42
41
  super
43
42
  end
44
-
45
43
  end
46
44
  end
47
- end
45
+ end
@@ -13,7 +13,7 @@ module EPlat
13
13
  end
14
14
 
15
15
  def type_value!(key, value)
16
- type = type_schema[key]&.downcase
16
+ type = type_schema[key].try(:downcase)
17
17
 
18
18
  if type.nil?
19
19
  return value
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
data/lib/e_plat.rb CHANGED
@@ -13,8 +13,9 @@ Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
13
13
  loader = Zeitwerk::Loader.for_gem
14
14
  loader.collapse("#{__dir__}/e_plat/resource") # So can call EPlat::Product
15
15
  loader.collapse("#{__dir__}/e_plat/resource/shopify_only")
16
+ loader.collapse("#{__dir__}/e_plat/resource/platform_specific")
16
17
  loader.collapse("#{__dir__}/e_plat/errors")
17
- loader.setup # ready!
18
+ loader.setup
18
19
 
19
20
 
20
21
 
@@ -22,6 +23,23 @@ module EPlat
22
23
  extend Dry::Configurable
23
24
  SUPPORTED_SHOPIFY_API_VERSIONS = ['2024_01']
24
25
  SUPPORTED_BIGCOMMERCE_API_VERSIONS = ['3']
26
+
27
+ SUPPORTED_PLATFORMS = ["shopify", "bigcommerce"]
28
+ SUPPORTED_RESOURCES = [
29
+ "shop",
30
+ "product",
31
+ "product/variant",
32
+ "product/image",
33
+ "product/option",
34
+ "product/image",
35
+ "order",
36
+ "order/line_item",
37
+ "order/shipping_address",
38
+ "order/billing_address",
39
+ "script_tag",
40
+ "webhook",
41
+ "metafield"
42
+ ]
25
43
 
26
44
  setting(:shopify_api_version, default: "2024_01", constructor: ->(value) do
27
45
  SUPPORTED_SHOPIFY_API_VERSIONS.include?(value.underscore) ? value.underscore : raise(ArgumentError, "Shopify API version #{value} is not supported")
@@ -45,3 +63,5 @@ module EPlat
45
63
 
46
64
  class Error < StandardError; end
47
65
  end
66
+
67
+ EPlat::Initializer.check_required_classes!
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.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-24 00:00:00.000000000 Z
11
+ date: 2024-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -203,6 +203,7 @@ files:
203
203
  - lib/e_plat/errors/incorrect_type_error.rb
204
204
  - lib/e_plat/errors/missing_migration_key_error.rb
205
205
  - lib/e_plat/errors/missing_session_error.rb
206
+ - lib/e_plat/initializer.rb
206
207
  - lib/e_plat/mapping.rb
207
208
  - lib/e_plat/mapping/base.rb
208
209
  - lib/e_plat/mapping/bigcommerce/v_3/metafield.rb
@@ -249,6 +250,38 @@ files:
249
250
  - lib/e_plat/resource/order/shipping_line.rb
250
251
  - lib/e_plat/resource/paginated/link_headers.rb
251
252
  - lib/e_plat/resource/paginated/link_params.rb
253
+ - lib/e_plat/resource/platform_specific/bigcommerce/metafield.rb
254
+ - lib/e_plat/resource/platform_specific/bigcommerce/order.rb
255
+ - lib/e_plat/resource/platform_specific/bigcommerce/order/Consignment.rb
256
+ - lib/e_plat/resource/platform_specific/bigcommerce/order/billing_address.rb
257
+ - lib/e_plat/resource/platform_specific/bigcommerce/order/fulfillment.rb
258
+ - lib/e_plat/resource/platform_specific/bigcommerce/order/line_item.rb
259
+ - lib/e_plat/resource/platform_specific/bigcommerce/order/shipping_address.rb
260
+ - lib/e_plat/resource/platform_specific/bigcommerce/order/shipping_line.rb
261
+ - lib/e_plat/resource/platform_specific/bigcommerce/product.rb
262
+ - lib/e_plat/resource/platform_specific/bigcommerce/product/image.rb
263
+ - lib/e_plat/resource/platform_specific/bigcommerce/product/option.rb
264
+ - lib/e_plat/resource/platform_specific/bigcommerce/product/variant.rb
265
+ - lib/e_plat/resource/platform_specific/bigcommerce/script_tag.rb
266
+ - lib/e_plat/resource/platform_specific/bigcommerce/shop.rb
267
+ - lib/e_plat/resource/platform_specific/bigcommerce/webhook.rb
268
+ - lib/e_plat/resource/platform_specific/shopify/metafield.rb
269
+ - lib/e_plat/resource/platform_specific/shopify/order.rb
270
+ - lib/e_plat/resource/platform_specific/shopify/order/Consignment.rb
271
+ - lib/e_plat/resource/platform_specific/shopify/order/billing_address.rb
272
+ - lib/e_plat/resource/platform_specific/shopify/order/fulfillment.rb
273
+ - lib/e_plat/resource/platform_specific/shopify/order/line_item.rb
274
+ - lib/e_plat/resource/platform_specific/shopify/order/shipping_address.rb
275
+ - lib/e_plat/resource/platform_specific/shopify/order/shipping_line.rb
276
+ - lib/e_plat/resource/platform_specific/shopify/product.rb
277
+ - lib/e_plat/resource/platform_specific/shopify/product/image.rb
278
+ - lib/e_plat/resource/platform_specific/shopify/product/option.rb
279
+ - lib/e_plat/resource/platform_specific/shopify/product/variant.rb
280
+ - lib/e_plat/resource/platform_specific/shopify/recurring_application_charge.rb
281
+ - lib/e_plat/resource/platform_specific/shopify/recurring_application_charge/usage_charge.rb
282
+ - lib/e_plat/resource/platform_specific/shopify/script_tag.rb
283
+ - lib/e_plat/resource/platform_specific/shopify/shop.rb
284
+ - lib/e_plat/resource/platform_specific/shopify/webhook.rb
252
285
  - lib/e_plat/resource/product.rb
253
286
  - lib/e_plat/resource/product/image.rb
254
287
  - lib/e_plat/resource/product/option.rb