erp_integration 0.53.0 → 0.54.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: 7719f3eaa455812be74cbdb4448118217e8294c90e742bb9d4074fad423a10ab
4
- data.tar.gz: 35e221932e9c229957951869daa324c7f40549bf1cdfe21d7c56dc3202741832
3
+ metadata.gz: 015dee8d29c0a8bcd763966f25c24b77efb9cd2e7ac4a1555aa104e9a708c2ec
4
+ data.tar.gz: 92f5a27785677904bd7b0cd60fc5a033195ed99d64d9c16941fbb4d942db8b31
5
5
  SHA512:
6
- metadata.gz: e9835ef2f7400c112999ac8ca0135d7f11be0c69129bd4403f5620042b06394e09a6ec62c225d9d82d41d66b7d6290a602edf525d48fe910e92ab48562456711
7
- data.tar.gz: 4a39d845dda9398b971334392fb58539a3cc208896a19e608c2207ddc040331b9e2a27ffef6ff1bcdc1ab56df4ba4a5de1a6da85399d37ca53a3b795f762771f
6
+ metadata.gz: 526e86fb610c85d0b5c69f36e2cf1b1c396ff36e6f74c2db6d9764eae9eb1f076d9ed7771b5347ac3060bbdbd047777c1901c427351a280bcb26bf49b6edb269
7
+ data.tar.gz: f876d9874077923090353f7e2c9d6766cae725fe1558345ba98f4d5cfc07495bb272f451205f04c6a957402fdf10bc756d69ad8792a55405c91a07ce856d5e4e
data/README.md CHANGED
@@ -26,7 +26,7 @@ To configure the gem, create an initializer and add the following lines:
26
26
  # config/initializers/erp_integration.rb
27
27
  ErpIntegration.configure do |config|
28
28
  config.fulfil_api_keys = '<your-api-key>'
29
- config.fulfil_merchant_id = '<your-merchant-id>'
29
+ config.fulfil_base_url = '<your-base-url>'
30
30
  end
31
31
  ```
32
32
 
@@ -35,7 +35,7 @@ You can configure multiple API keys, to enable rotation mechanism (see ["API key
35
35
  # config/initializers/erp_integration.rb
36
36
  ErpIntegration.configure do |config|
37
37
  config.fulfil_api_keys = ['<your-api-key1>', '<your-api-key2>']
38
- config.fulfil_merchant_id = '<your-merchant-id>'
38
+ config.fulfil_base_url = '<your-base-url>'
39
39
  end
40
40
  ```
41
41
 
@@ -14,13 +14,13 @@ module ErpIntegration
14
14
  class Configuration
15
15
  # The `fulfil_api_keys` sets a single or a list of API keys to use
16
16
  # in the `FulfilClient` to authorize the requests to the Fulfil API endpoints.
17
- # @return [Array<Atring>] The API keys for Fulfil.
17
+ # @return [Array<String>] The API keys for Fulfil.
18
18
  attr_accessor :fulfil_api_keys
19
19
 
20
- # The `fulfil_merchant_id` is used by the `FulfilClient` to connect to
20
+ # The `fulfil_base_url` is used by the `FulfilClient` to connect to
21
21
  # the right Fulfil API endpoints.
22
- # @return [String] The merchant ID for Fulfil.
23
- attr_accessor :fulfil_merchant_id
22
+ # @return [String] The base URL for Fulfil.
23
+ attr_accessor :fulfil_base_url
24
24
 
25
25
  # Allows configuring an adapter for the `BillOfMaterial` resource. When
26
26
  # none is configured, it will default to Fulfil.
@@ -28,7 +28,7 @@ module ErpIntegration
28
28
  def self.client
29
29
  Client.new(
30
30
  api_keys_pool: api_keys_pool,
31
- merchant_id: config.fulfil_merchant_id,
31
+ base_url: config.fulfil_base_url,
32
32
  logger: config.logger
33
33
  )
34
34
  end
@@ -72,16 +72,19 @@ module ErpIntegration
72
72
  # be executed and the results will be fetched.
73
73
  # @return [Array] An enumerable collection object with all API results.
74
74
  def all
75
- client.put(
76
- api_resource_path,
77
- Query.new(
78
- fields: selected_fields,
79
- filters: where_clauses,
80
- alternative_filters: or_clauses,
81
- limit: limit_value,
82
- offset: calculated_offset
83
- )
84
- ).map { |item| resource_klass.new(item) }
75
+ return @results if defined?(@results)
76
+
77
+ @results =
78
+ client.put(
79
+ api_resource_path,
80
+ Query.new(
81
+ fields: selected_fields,
82
+ filters: where_clauses,
83
+ alternative_filters: or_clauses,
84
+ limit: limit_value,
85
+ offset: calculated_offset
86
+ )
87
+ ).map { |item| resource_klass.new(item) }
85
88
  end
86
89
 
87
90
  # As with the `all` method, the `query methods` lazyly build a search/read
@@ -90,14 +93,17 @@ module ErpIntegration
90
93
  # the result will be fetched
91
94
  # @return [Integer] The count of records that match with the query in Fulfil
92
95
  def count
93
- client.put(
94
- "model/#{model_name}/search_count",
95
- Query.new(
96
- fields: nil,
97
- filters: where_clauses,
98
- alternative_filters: or_clauses
99
- ).to_h.except(:fields)
100
- )
96
+ return @count if defined?(@count)
97
+
98
+ @count =
99
+ client.put(
100
+ "model/#{model_name}/search_count",
101
+ Query.new(
102
+ fields: nil,
103
+ filters: where_clauses,
104
+ alternative_filters: or_clauses
105
+ ).to_h.except(:fields)
106
+ )
101
107
  end
102
108
 
103
109
  # The `each` method turns the `ApiResource` instance into an enumerable object.
@@ -3,21 +3,15 @@
3
3
  module ErpIntegration
4
4
  module Fulfil
5
5
  class Client
6
- attr_reader :api_keys_pool, :merchant_id
6
+ attr_reader :api_keys_pool, :base_url
7
7
  attr_writer :connection, :faraday_adapter, :rotate_statuses
8
8
 
9
- def initialize(api_keys_pool:, merchant_id:, logger: nil)
9
+ def initialize(api_keys_pool:, base_url:, logger: nil)
10
10
  @api_keys_pool = api_keys_pool
11
- @merchant_id = merchant_id
11
+ @base_url = base_url.strip
12
12
  @logger = logger
13
13
  end
14
14
 
15
- # Generates the url prefix for the Faraday connection client.
16
- # @return [String] The base url for the Fulfil HTTP client
17
- def base_url
18
- "https://#{merchant_id}.fulfil.io/"
19
- end
20
-
21
15
  # Sets the default adapter for the Faraday Connection.
22
16
  # @return [Symbol] The default Faraday adapter
23
17
  def faraday_adapter
@@ -50,8 +44,8 @@ module ErpIntegration
50
44
 
51
45
  %i[delete get patch put post].each do |action_name|
52
46
  define_method(action_name) do |path, options = {}|
53
- if api_key.nil? || merchant_id.nil?
54
- raise ErpIntegration::Error, 'The Fulfil API key and/or Merchant ID are missing.'
47
+ if api_key.nil? || base_url.nil?
48
+ raise ErpIntegration::Error, 'The Fulfil API key and/or base URL are missing.'
55
49
  end
56
50
 
57
51
  connection.public_send(action_name, "api/#{version}/#{path}", options).body
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ErpIntegration
4
- VERSION = '0.53.0'
4
+ VERSION = '0.54.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erp_integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.53.0
4
+ version: 0.54.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Vermaas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-30 00:00:00.000000000 Z
11
+ date: 2024-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -368,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
368
368
  - !ruby/object:Gem::Version
369
369
  version: '0'
370
370
  requirements: []
371
- rubygems_version: 3.2.22
371
+ rubygems_version: 3.5.11
372
372
  signing_key:
373
373
  specification_version: 4
374
374
  summary: Connects Mejuri with third-party ERP vendors