erp_integration 0.53.0 → 0.54.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 +4 -4
- data/README.md +2 -2
- data/lib/erp_integration/configuration.rb +4 -4
- data/lib/erp_integration/fulfil/api_resource.rb +25 -19
- data/lib/erp_integration/fulfil/client.rb +5 -11
- data/lib/erp_integration/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 015dee8d29c0a8bcd763966f25c24b77efb9cd2e7ac4a1555aa104e9a708c2ec
|
4
|
+
data.tar.gz: 92f5a27785677904bd7b0cd60fc5a033195ed99d64d9c16941fbb4d942db8b31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
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<
|
17
|
+
# @return [Array<String>] The API keys for Fulfil.
|
18
18
|
attr_accessor :fulfil_api_keys
|
19
19
|
|
20
|
-
# The `
|
20
|
+
# The `fulfil_base_url` is used by the `FulfilClient` to connect to
|
21
21
|
# the right Fulfil API endpoints.
|
22
|
-
# @return [String] The
|
23
|
-
attr_accessor :
|
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
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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, :
|
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:,
|
9
|
+
def initialize(api_keys_pool:, base_url:, logger: nil)
|
10
10
|
@api_keys_pool = api_keys_pool
|
11
|
-
@
|
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? ||
|
54
|
-
raise ErpIntegration::Error, 'The Fulfil API key and/or
|
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
|
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.
|
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-
|
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.
|
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
|