erp_integration 0.19.0 → 0.21.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c03eaf82065763fce0b3bf8b771b2af9a04e588ab56056f3b617f7696db110ad
|
4
|
+
data.tar.gz: bfdf6e68ea49ad4e72a5cfcaa28d2b99d39d67f26cebb866214583076e607047
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e368a61cd727304adf94f5dbfb14f149b2c976b27e68c7d1de00b93dee9d279f35dfcbf58d197ef3f9775cbf6a0e1d18af1c4ac0883edf8e3466eabe8c7c9fd4
|
7
|
+
data.tar.gz: b82940b549df5f315167152bcc65c60ce7fc44ed44d8863513238e06c66e330e553dd2cdbe6799bd01b7c3b418b5fb45d8e2d14d8f0e949e8b9a2c787c93be69
|
@@ -69,8 +69,8 @@ module ErpIntegration
|
|
69
69
|
fields: selected_fields,
|
70
70
|
filters: where_clauses,
|
71
71
|
alternative_filters: or_clauses,
|
72
|
-
|
73
|
-
|
72
|
+
limit: limit_value,
|
73
|
+
offset: calculated_offset
|
74
74
|
)
|
75
75
|
).map { |item| resource_klass.new(item) }
|
76
76
|
end
|
@@ -90,7 +90,7 @@ module ErpIntegration
|
|
90
90
|
fields: nil,
|
91
91
|
filters: where_clauses,
|
92
92
|
alternative_filters: or_clauses
|
93
|
-
).to_h.except(:fields
|
93
|
+
).to_h.except(:fields)
|
94
94
|
)
|
95
95
|
end
|
96
96
|
|
@@ -3,32 +3,84 @@
|
|
3
3
|
module ErpIntegration
|
4
4
|
module Fulfil
|
5
5
|
module PaginationMethods
|
6
|
-
|
6
|
+
DEFAULT_LIMIT = 500 # Default limit set in FF
|
7
|
+
DEFAULT_OFFSET = 0 # Default offset set by FF
|
7
8
|
MAX_LIMIT = 500 # Max limit set by FF
|
8
9
|
|
9
|
-
attr_accessor :
|
10
|
+
attr_accessor :limit_value, :offset_value, :page_number
|
10
11
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
def offset(
|
17
|
-
|
12
|
+
# The {#offset} method allows navigating through the returned resources from
|
13
|
+
# Fulfil's API endpoints just as with a regular database.
|
14
|
+
#
|
15
|
+
# @param value [String, Integer] The offset for the number of resources.
|
16
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
17
|
+
def offset(value)
|
18
|
+
clone.offset!(value.to_i)
|
19
|
+
end
|
20
|
+
|
21
|
+
def offset!(value)
|
22
|
+
self.offset_value = value
|
23
|
+
self
|
24
|
+
end
|
18
25
|
|
26
|
+
# By default, Fulfil returns the first 500 records for every query to their
|
27
|
+
# API endpoints. With the {#limit} method, it's possible to modify the number
|
28
|
+
# of records to return.
|
29
|
+
#
|
30
|
+
# NOTE: The maximum limit is 500 per dictation of Fulfil.
|
31
|
+
#
|
32
|
+
# @param value [String, Integer] The number of resources to return.
|
33
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
34
|
+
def limit(value)
|
35
|
+
clone.limit!(value.to_i)
|
36
|
+
end
|
37
|
+
|
38
|
+
def limit!(value)
|
39
|
+
self.limit_value = [value, MAX_LIMIT].min
|
19
40
|
self
|
20
41
|
end
|
21
42
|
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
43
|
+
alias per_page limit
|
44
|
+
|
45
|
+
# The `page` method will simplify the use of `limit` and `offset` together with
|
46
|
+
# the `per_page` method. Is the quantity of pages that we want to get on the response.
|
47
|
+
# It sets the instance variable page_number which will be useful to calculate the offset
|
48
|
+
# lazily when the method `calculated_offset` is called. This is because we need to know
|
49
|
+
# first the limit before calculate the offset
|
50
|
+
#
|
51
|
+
# @param page_number [Integer, String]
|
52
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
53
|
+
def page(page_number)
|
54
|
+
clone.page!(page_number.to_i)
|
55
|
+
end
|
29
56
|
|
57
|
+
# @param page_number [Integer]
|
58
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
59
|
+
def page!(page_number)
|
60
|
+
self.page_number = page_number
|
30
61
|
self
|
31
62
|
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
# @return [Boolean]
|
67
|
+
def paginating?
|
68
|
+
!page_number.nil?
|
69
|
+
end
|
70
|
+
|
71
|
+
# The `calculated_offset` will calculate the offset_value instance variable lazily
|
72
|
+
# @return [Integer]
|
73
|
+
def calculated_offset
|
74
|
+
return offset_value unless paginating?
|
75
|
+
|
76
|
+
# When paginating we want to set the {#limit_value} to equal the {MAX_LIMIT}
|
77
|
+
# when the {#limit_value} isn't set to prevent inconsistencies in the API response.
|
78
|
+
limit!(MAX_LIMIT) if limit_value.nil?
|
79
|
+
|
80
|
+
# Now, calculate the offset_value based on the {#limit_value} and the {#page_number}.
|
81
|
+
offset!((page_number - 1) * limit_value)
|
82
|
+
offset_value
|
83
|
+
end
|
32
84
|
end
|
33
85
|
end
|
34
86
|
end
|
@@ -38,12 +38,12 @@ module ErpIntegration
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def to_h
|
41
|
-
{
|
42
|
-
fields
|
43
|
-
filters
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
{}.tap do |hash|
|
42
|
+
hash[:fields] = @fields
|
43
|
+
hash[:filters] = @filters
|
44
|
+
hash[:limit] = @limit if @limit
|
45
|
+
hash[:offset] = @offset if @offset
|
46
|
+
end
|
47
47
|
end
|
48
48
|
end
|
49
49
|
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.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Vermaas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -224,7 +224,7 @@ dependencies:
|
|
224
224
|
- - '='
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: 1.19.2
|
227
|
-
description:
|
227
|
+
description:
|
228
228
|
email:
|
229
229
|
- stefan@knowndecimal.com
|
230
230
|
executables: []
|
@@ -321,7 +321,7 @@ metadata:
|
|
321
321
|
homepage_uri: https://www.github.com/mejuri-inc/erp-integration
|
322
322
|
source_code_uri: https://www.github.com/mejuri-inc/erp-integration
|
323
323
|
changelog_uri: https://www.github.com/mejuri-inc/erp-integration/blob/main/CHANGELOG.md
|
324
|
-
post_install_message:
|
324
|
+
post_install_message:
|
325
325
|
rdoc_options: []
|
326
326
|
require_paths:
|
327
327
|
- lib
|
@@ -336,9 +336,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
336
|
- !ruby/object:Gem::Version
|
337
337
|
version: '0'
|
338
338
|
requirements: []
|
339
|
-
|
340
|
-
|
341
|
-
signing_key:
|
339
|
+
rubygems_version: 3.3.7
|
340
|
+
signing_key:
|
342
341
|
specification_version: 4
|
343
342
|
summary: Connects Mejuri with third-party ERP vendors
|
344
343
|
test_files: []
|