e_plat 1.3.0 → 1.4.0

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: 9b76ee9e7103fc4e5cb491cb07cd8fd8cf24cc56d28e16cc99d222da3b65db77
4
- data.tar.gz: 623f8ef5b141c3b5b24138c7abca5610aec3d7acb840a749e6481320eeff890d
3
+ metadata.gz: 43bb902d0393d1fdf55cda97af98daf3e7d671a29ad508c19184b9cf8a1b7fa6
4
+ data.tar.gz: 8956828b1e9cfb81caa3b90350460129f245344429a05a8056dd69262abf5b44
5
5
  SHA512:
6
- metadata.gz: 878c953fc1ac93d857cbae808664affb031f68d1a9c5198059773373c5c74f9ab7139937ccab4199ae362af3b4bf80e0969a34de972eb3f80e25d7a95aeef92d
7
- data.tar.gz: 59679a5b7d68e46a15811e9591e052697c14589b0dbee5597bca550e595fd48878a0e9415f7a55a876a56f676a26a1a93d39699e8cee1126efa0d5f5c5b342b8
6
+ metadata.gz: ba32bbdf9786f7897d45298589b5e1f289640c529f04c076cb0cc03bcb2701231d216edde041ade63dab6470a30cac3b58c66e4a64d8648147c9fe5bf9ed3217
7
+ data.tar.gz: f3567911feab30badca852ef964bdc9d5e63de310614e2c39d07def9d9e0f1c88ab3171311b1115baa5ff69167776037374b592ea38f153a6b39ed926b05582f
@@ -60,11 +60,15 @@ module EPlat
60
60
  else
61
61
  case action
62
62
  when :find_one, :find_single
63
+ raise_resource_not_found! if resource_missing_from?(response)
64
+
63
65
  instantiate_record resources_parsed_from(response)
64
66
  else
65
67
  instantiate_collection resources_parsed_from(response)
66
68
  end
67
69
  end
70
+ rescue ActiveResource::ResourceNotFound
71
+ raise
68
72
  rescue StandardError => e
69
73
  raise EPlat::GraphqlError.new(e.message)
70
74
  end
@@ -79,6 +83,17 @@ module EPlat
79
83
  ).body
80
84
  end
81
85
 
86
+ # a 200 with a null resource is Shopify graphql's version of a 404
87
+ def resource_missing_from?(response)
88
+ data = response["data"].is_a?(Hash) ? response["data"] : response
89
+
90
+ data.key?(graphql_element_name) && data[graphql_element_name].nil?
91
+ end
92
+
93
+ def raise_resource_not_found!
94
+ raise ActiveResource::ResourceNotFound.new(nil, "#{name} not found")
95
+ end
96
+
82
97
  #utils
83
98
 
84
99
  def scope_with_options_hash(args, action)
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
data/lib/e_plat.rb CHANGED
@@ -1,13 +1,15 @@
1
- require "e_plat/version"
2
- require "e_plat/engine"
3
- require "zeitwerk"
1
+ # frozen_string_literal: true
4
2
 
5
- require "active_support"
6
- require "activeresource"
7
- require "activeresource-response"
3
+ require 'e_plat/version'
4
+ require 'e_plat/engine'
5
+ require 'zeitwerk'
6
+
7
+ require 'active_support'
8
+ require 'activeresource'
9
+ require 'activeresource-response'
8
10
  require 'dry-types'
9
11
  require 'active_resource/connection_error'
10
- require_relative "hash"
12
+ require_relative 'hash'
11
13
  # require "e_plat/railtie" if defined?(Rails::Railtie)
12
14
 
13
15
  Zeitwerk::Loader.for_gem(warn_on_extra_files: false)
@@ -16,66 +18,64 @@ loader.collapse("#{__dir__}/e_plat/resource") # So can call EPlat::Product
16
18
  loader.collapse("#{__dir__}/e_plat/resource/shopify_only")
17
19
  loader.collapse("#{__dir__}/e_plat/resource/platform_specific")
18
20
  loader.collapse("#{__dir__}/e_plat/errors")
19
- loader.setup
21
+ loader.setup
20
22
 
23
+ module EPlat
24
+ extend Dry::Configurable
25
+ SUPPORTED_SHOPIFY_API_VERSIONS = %w[2024_01 2024_07 2025_01 2025_10 2026_04].freeze
26
+ SUPPORTED_BIGCOMMERCE_API_VERSIONS = ['3'].freeze
27
+ SUPPORTED_WOOCOMMERCE_API_VERSIONS = ['3'].freeze
28
+ SUPPORTED_PLATFORMS = %w[shopify bigcommerce woocommerce].freeze
29
+ SUPPORTED_RESOURCES = [
30
+ 'shop',
31
+ 'product',
32
+ 'product/variant',
33
+ 'product/image',
34
+ 'product/option',
35
+ 'product/image',
36
+ 'order',
37
+ 'order/line_item',
38
+ 'order/shipping_address',
39
+ 'order/billing_address',
40
+ 'script_tag',
41
+ 'webhook',
42
+ 'metafield'
43
+ ].freeze
44
+ PROTECTED_PREFIX = '_protected_'
21
45
 
46
+ setting(:shopify_api_version, default: ENV['EPLAT_SHOPIFY_API_VERSION'] || '2026_04', constructor: lambda do |value|
47
+ SUPPORTED_SHOPIFY_API_VERSIONS.include?(value.underscore) ? value.underscore : raise(ArgumentError, "Shopify API version #{value} is not supported")
48
+ end)
22
49
 
23
- module EPlat
24
- extend Dry::Configurable
25
- SUPPORTED_SHOPIFY_API_VERSIONS = ['2024_01', '2024_07', '2025_01', '2025_10', '2026_04']
26
- SUPPORTED_BIGCOMMERCE_API_VERSIONS = ['3']
27
- SUPPORTED_WOOCOMMERCE_API_VERSIONS = ['3']
28
- SUPPORTED_PLATFORMS = ["shopify", "bigcommerce", "woocommerce"]
29
- SUPPORTED_RESOURCES = [
30
- "shop",
31
- "product",
32
- "product/variant",
33
- "product/image",
34
- "product/option",
35
- "product/image",
36
- "order",
37
- "order/line_item",
38
- "order/shipping_address",
39
- "order/billing_address",
40
- "script_tag",
41
- "webhook",
42
- "metafield"
43
- ]
44
- PROTECTED_PREFIX = "_protected_"
45
-
46
- setting(:shopify_api_version, default: ENV['EPLAT_SHOPIFY_API_VERSION'] || "2026_04", constructor: ->(value) do
47
- SUPPORTED_SHOPIFY_API_VERSIONS.include?(value.underscore) ? value.underscore : raise(ArgumentError, "Shopify API version #{value} is not supported")
48
- end)
50
+ setting(:bigcommerce_api_version, default: ENV['EPLAT_BIGCOMMERCE_API_VERSION'] || 'v3', constructor: lambda do |value|
51
+ v = value.downcase.gsub('v', '')
52
+ SUPPORTED_BIGCOMMERCE_API_VERSIONS.include?(v) ? v : raise(ArgumentError, "Bigcommerce API version #{value} is not supported")
53
+ end)
49
54
 
50
- setting(:bigcommerce_api_version, default: ENV['EPLAT_BIGCOMMERCE_API_VERSION'] || "v3", constructor: ->(value) do
51
- v = value.downcase.gsub("v", "")
52
- SUPPORTED_BIGCOMMERCE_API_VERSIONS.include?(v) ? v : raise(ArgumentError, "Bigcommerce API version #{value} is not supported")
53
- end)
54
-
55
- setting(:woocommerce_api_version, default: ENV['EPLAT_WOOCOMMERCE_API_VERSION'] || "v3", constructor: ->(value) do
56
- v = value.downcase.gsub("v", "")
57
- SUPPORTED_WOOCOMMERCE_API_VERSIONS.include?(v) ? v : raise(ArgumentError, "WooCommerce API version #{value} is not supported")
58
- end)
55
+ setting(:woocommerce_api_version, default: ENV['EPLAT_WOOCOMMERCE_API_VERSION'] || 'v3', constructor: lambda do |value|
56
+ v = value.downcase.gsub('v', '')
57
+ SUPPORTED_WOOCOMMERCE_API_VERSIONS.include?(v) ? v : raise(ArgumentError, "WooCommerce API version #{value} is not supported")
58
+ end)
59
59
 
60
- setting(:print_graphql_requests, default:ENV['EPLAT_PRINT_GRAPHQL_REQUESTS'] || false)
60
+ setting(:print_graphql_requests, default: ENV['EPLAT_PRINT_GRAPHQL_REQUESTS'] || false)
61
61
 
62
- setting(:mute_woocommerce_variant_warnings, default: ENV['EPLAT_MUTE_WOOCOMMERCE_VARIANT_WARNINGS'] || false)
62
+ setting(:mute_woocommerce_variant_warnings, default: ENV['EPLAT_MUTE_WOOCOMMERCE_VARIANT_WARNINGS'] || false)
63
63
 
64
- def self.api_display_name
65
- apis = Struct.new(:shopify, :bigcommerce, :woocommerce)
66
- apis.new(
67
- shopify: config.shopify_api_version&.dasherize, # "2024-01"
68
- bigcommerce: "v#{config.bigcommerce_api_version}", # "v3"
69
- woocommerce: "v#{config.woocommerce_api_version}" # "v3"
70
- )
71
- end
64
+ def self.api_display_name
65
+ apis = Struct.new(:shopify, :bigcommerce, :woocommerce)
66
+ apis.new(
67
+ shopify: config.shopify_api_version&.dasherize, # "2024-01"
68
+ bigcommerce: "v#{config.bigcommerce_api_version}", # "v3"
69
+ woocommerce: "v#{config.woocommerce_api_version}" # "v3"
70
+ )
71
+ end
72
72
 
73
- def self.shopify_graphql_version
74
- "V#{ EPlat.config.shopify_api_version.gsub("_", "") }"
75
- end
73
+ def self.shopify_graphql_version
74
+ "V#{EPlat.config.shopify_api_version.gsub('_', '')}"
75
+ end
76
76
 
77
- class Error < StandardError; end
78
- class GraphqlError < Error; end
77
+ class Error < StandardError; end
78
+ class GraphqlError < Error; end
79
79
  end
80
80
 
81
81
  EPlat::Initializer.check_required_classes!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e_plat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - oliwoodsuk
@@ -503,7 +503,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
503
  - !ruby/object:Gem::Version
504
504
  version: '0'
505
505
  requirements: []
506
- rubygems_version: 4.0.5
506
+ rubygems_version: 4.0.10
507
507
  specification_version: 4
508
508
  summary: Creates a single interface for integrating with ecommerce platform APIs.
509
509
  test_files: []