e_plat 0.4.3 → 0.5.0

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: ee797b0b23712947fd4ed9e566a4a26548b887fc7958254343eab9b97073e708
4
- data.tar.gz: d26e103052bf4fbf770890e5b05d0f49dcf4c6cd9ae4f473e3737640837fa148
3
+ metadata.gz: 7940bc3d4b8d6b21b3ac8b36eba083a7cfea37fabd1161bca997c47338038b9b
4
+ data.tar.gz: 1d8ce726804d61e44f5b1c5e9675309219cfc03619b6bb7be3733cbd1f683e9e
5
5
  SHA512:
6
- metadata.gz: 213183bc25f835b78a18245f01cab417cd37625baf056e08a89500f492d3b019ee8691da997e33e60c8c4b7ea894eaf5120d7806b943fe001be3f888b58e74ce
7
- data.tar.gz: 464bb8e454266a48d6e157bd5e51f689216e59afc3bde7506a3ec3ae4ea1030bf4b0b3e3288b205ba88976885be76a1f6df2829dd93f5d7cae9d87ea977b8742
6
+ metadata.gz: 04c6492c9a0d3d79769e5223c6b16ba1672a088cc5ff7baa9a94e942c555b9e0b6134881c96db1f8f7cb5bc32cff70d97a796e1725a6a6a998d69835a50a6dd6
7
+ data.tar.gz: 6355bcf307dbe5d0ef1fe660510f142390ee01a7e0a0e45fe1fc2b3379a00b28350b5b5151625dde045e0e73b2ac74ead4e591d6539afffd1d76f0d239a24b12
data/README.md CHANGED
@@ -44,6 +44,9 @@ You can configure which platform APIs are used by updating the EPlat config: <br
44
44
  EPlat.config.shopify_api_version = "2024-01"
45
45
  EPlat.config.bigcommerce_api_version = "v3"
46
46
  EPlat.config.woocommerce_api_version = "v3"
47
+
48
+ # EPlat.api_display_name.shopify #=> "2024-01" # presents as the platform would display in URL paths
49
+ # EPlat.config.shopify_api_version #=> "2024_01" # coerced interally for creating constants
47
50
  ```
48
51
  <br>
49
52
 
@@ -80,7 +83,7 @@ EPlat is designed to let you mostly use it's universal interface, but then easil
80
83
  event: :onload,
81
84
  src: "https://preproduct.io/mini-script.js"
82
85
  )
83
- tag.name = "mini script" if Current.e_plat_session.bigcommerce?
86
+ tag.name = "mini script" if EPlat::Current.e_plat_session.bigcommerce?
84
87
  tag.save
85
88
 
86
89
  # ...when session is a Shopify store
@@ -579,7 +582,7 @@ Unfortunately it's in a Time Integer format. Haven't yet got dynamic conversion
579
582
  # <%= link_to "previous products", "/", page_info: products.previous_page_info %>
580
583
  # <%= link_to "Next products", "/", page_info: products.next_page_info %>
581
584
 
582
- EPlat::Product.find(:all, params: {limit: 2, Current.e_plat_session.pagination_param => params['page_info'] })
585
+ EPlat::Product.find(:all, params: {limit: 2, EPlat::Current.e_plat_session.pagination_param => params['page_info'] })
583
586
  ```
584
587
 
585
588
 
@@ -0,0 +1,9 @@
1
+ module EPlat
2
+ class Current < ActiveSupport::CurrentAttributes
3
+ attribute :e_plat_session
4
+
5
+ def e_plat_session
6
+ super || raise("EPlat session has not been initialized.")
7
+ end
8
+ end
9
+ end
@@ -30,7 +30,7 @@ module EPlat
30
30
  end
31
31
 
32
32
  def client
33
- Current.e_plat_session
33
+ EPlat::Current.e_plat_session
34
34
  end
35
35
 
36
36
 
@@ -87,7 +87,7 @@ module EPlat
87
87
  end
88
88
 
89
89
  def client
90
- Current.e_plat_session
90
+ EPlat::Current.e_plat_session
91
91
  end
92
92
 
93
93
  def mapped?(attribute)
@@ -85,7 +85,7 @@ module EPlat
85
85
  private
86
86
 
87
87
  def client
88
- Current.e_plat_session
88
+ EPlat::Current.e_plat_session
89
89
  end
90
90
 
91
91
  end
@@ -1,10 +1,10 @@
1
1
 
2
2
  module EPlat
3
3
  class Session
4
- #the session is an instance of EPlat::Client made available via Rails Current::Attributes
4
+ #the session is an instance of EPlat::Client made available via Rails EPlat::Current::Attributes
5
5
 
6
6
  def initialize(platform:, store_url:, api_token:, store_hash: nil)
7
- Current.e_plat_session = EPlat::Client.new(
7
+ EPlat::Current.e_plat_session = EPlat::Client.new(
8
8
  platform: platform,
9
9
  store_url: store_url,
10
10
  api_token: api_token,
@@ -13,7 +13,7 @@ module EPlat
13
13
  end
14
14
 
15
15
  def self.clear!
16
- Current.e_plat_session = nil
16
+ EPlat::Current.e_plat_session = nil
17
17
  end
18
18
 
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module EPlat
2
- VERSION = "0.4.3"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/e_plat.rb CHANGED
@@ -32,7 +32,16 @@ module EPlat
32
32
  SUPPORTED_BIGCOMMERCE_API_VERSIONS.include?(v) ? v : raise(ArgumentError, "Bigcommerce API version #{value} is not supported")
33
33
  end)
34
34
 
35
- setting(:woocommerce_api_version, default: "v3", constructor: ->(value) { value.downcase.gsub("v", "") })
35
+ setting(:woocommerce_api_version, default: "v3", constructor: ->(value) { value.downcase.gsub("v", "") })
36
+
37
+ def self.api_display_name
38
+ apis = Struct.new(:shopify, :bigcommerce, :woocommerce)
39
+ apis.new(
40
+ shopify: config.shopify_api_version&.dasherize, # "2024-01"
41
+ bigcommerce: "v#{config.bigcommerce_api_version}", # "v3"
42
+ woocommerce: "v#{config.woocommerce_api_version}" # "v3"
43
+ )
44
+ end
36
45
 
37
46
  class Error < StandardError; end
38
47
  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.3
4
+ version: 0.5.0
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-08 00:00:00.000000000 Z
11
+ date: 2024-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -207,12 +207,12 @@ files:
207
207
  - lib/active_resource/connection_error.rb
208
208
  - lib/active_resource/formats.rb
209
209
  - lib/active_resource/schema.rb
210
- - lib/current.rb
211
210
  - lib/e_plat.rb
212
211
  - lib/e_plat/client.rb
213
212
  - lib/e_plat/client/default_request_args.rb
214
213
  - lib/e_plat/client/platform_convenience_methods.rb
215
214
  - lib/e_plat/connection.rb
215
+ - lib/e_plat/current.rb
216
216
  - lib/e_plat/engine.rb
217
217
  - lib/e_plat/errors/incorrect_type_error.rb
218
218
  - lib/e_plat/errors/missing_migration_key_error.rb
data/lib/current.rb DELETED
@@ -1,7 +0,0 @@
1
- class Current < ActiveSupport::CurrentAttributes
2
- attribute :e_plat_session
3
-
4
- def e_plat_session
5
- super || raise("EPlat session has not been initialized.")
6
- end
7
- end