erp_integration 0.18.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/erp_integration/fulfil/api_resource.rb +2 -2
- data/lib/erp_integration/fulfil/pagination_methods.rb +24 -15
- data/lib/erp_integration/fulfil/query_methods.rb +20 -1
- data/lib/erp_integration/fulfil/where_clause.rb +7 -2
- data/lib/erp_integration/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc78fc9da96c988f29c92bf41501a8827626453e66fdd806f51e16a9f1b8e1bc
|
4
|
+
data.tar.gz: 7f0d3551bdb15ae06fbe67c96ff2d257f14a61eddc3cbe56d554643ec767e6ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 642e6917b8580bece6dc22acde22db86f91060419a059eda273861c2c6bf02928220128e4123249533024cf9b88a3d9455208065b538dc82a3a3080ccebd7f69
|
7
|
+
data.tar.gz: 0f542badd49a4615043e4b237d48606d18c354091fe564d74a92a005846e22338c76b1abff03be6ac99c26f358d78f46ce205dec44c2cb8c02ddcccd5769f864
|
@@ -69,8 +69,8 @@ module ErpIntegration
|
|
69
69
|
fields: selected_fields,
|
70
70
|
filters: where_clauses,
|
71
71
|
alternative_filters: or_clauses,
|
72
|
-
offset:
|
73
|
-
limit:
|
72
|
+
offset: offset_value,
|
73
|
+
limit: limit_value
|
74
74
|
)
|
75
75
|
).map { |item| resource_klass.new(item) }
|
76
76
|
end
|
@@ -6,27 +6,36 @@ module ErpIntegration
|
|
6
6
|
DEFAULT_OFFSET = 0
|
7
7
|
MAX_LIMIT = 500 # Max limit set by FF
|
8
8
|
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :offset_value, :limit_value
|
10
10
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
def offset(
|
17
|
-
|
11
|
+
# The {#offset} method allows navigating through the returned resources from
|
12
|
+
# Fulfil's API endpoints just as with a regular database.
|
13
|
+
#
|
14
|
+
# @param value [Integer] The offset for the number of resources.
|
15
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
16
|
+
def offset(value)
|
17
|
+
clone.offset!(value)
|
18
|
+
end
|
18
19
|
|
20
|
+
def offset!(value)
|
21
|
+
self.offset_value = value
|
19
22
|
self
|
20
23
|
end
|
21
24
|
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
|
25
|
+
# By default, Fulfil returns the first 500 records for every query to their
|
26
|
+
# API endpoints. With the {#limit} method, it's possible to modify the number
|
27
|
+
# of records to return.
|
28
|
+
#
|
29
|
+
# NOTE: The maximum limit is 500 per dictation of Fulfil.
|
30
|
+
#
|
31
|
+
# @param value [Integer] The number of resources to return.
|
32
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
33
|
+
def limit(value)
|
34
|
+
clone.limit!(value)
|
35
|
+
end
|
29
36
|
|
37
|
+
def limit!(value)
|
38
|
+
self.limit_value = [value, MAX_LIMIT].min
|
30
39
|
self
|
31
40
|
end
|
32
41
|
end
|
@@ -71,12 +71,13 @@ module ErpIntegration
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def where!(args)
|
74
|
+
domain = args.delete(:domain)
|
74
75
|
comparison_operator = args.delete(:comparison_operator)
|
75
76
|
|
76
77
|
args.each_pair do |key, value|
|
77
78
|
self.where_clauses =
|
78
79
|
(where_clauses || []) << WhereClause.new(
|
79
|
-
key: key, value: value, comparison_operator: comparison_operator
|
80
|
+
key: key, value: value, domain: domain, comparison_operator: comparison_operator
|
80
81
|
)
|
81
82
|
end
|
82
83
|
|
@@ -124,6 +125,24 @@ module ErpIntegration
|
|
124
125
|
self
|
125
126
|
end
|
126
127
|
|
128
|
+
# The `where_domain` method provides an interface for querying resources
|
129
|
+
# in Fulfil when filtered attributes require specifying
|
130
|
+
# the name of the domain model in which they are located.
|
131
|
+
#
|
132
|
+
# @example
|
133
|
+
# $ ErpIntegration::SalesOrder.where_domain('stock.shipment.out', 'shipment.state': 'done').all
|
134
|
+
# # => <ErpIntegration::Fulfil::Collection @items=[<ErpIntegration::SalesOrder @id=100 />] />
|
135
|
+
#
|
136
|
+
# Adds the domain model name as a fourth argument to each filers parameter
|
137
|
+
#
|
138
|
+
# @example
|
139
|
+
# :filters=>[
|
140
|
+
# ['shipment.state', '=', 'done', 'stock.shipment.out']
|
141
|
+
# ]
|
142
|
+
def where_domain(domain, args)
|
143
|
+
where(args.merge!(domain: domain))
|
144
|
+
end
|
145
|
+
|
127
146
|
def where_ilike(args)
|
128
147
|
where(args.merge(comparison_operator: 'ilike'))
|
129
148
|
end
|
@@ -23,16 +23,21 @@ module ErpIntegration
|
|
23
23
|
|
24
24
|
DEFAULT_COMPARISON_OPERATOR = '='
|
25
25
|
|
26
|
-
|
26
|
+
# @param key [String] The name of filtered attribute.
|
27
|
+
# @param value [String] The value by filtering will be performed.
|
28
|
+
# @param domain [String] The domain model name to specify filtering attributes location.
|
29
|
+
# @param comparison_operator [String] The way the key and the value are compared.
|
30
|
+
def initialize(key:, value:, domain: nil, comparison_operator: DEFAULT_COMPARISON_OPERATOR)
|
27
31
|
@comparison_operator = verify_comparison_operator(comparison_operator)
|
28
32
|
@key = key.to_s
|
29
33
|
@value = value
|
34
|
+
@domain = domain
|
30
35
|
end
|
31
36
|
|
32
37
|
# Transforms the `WhereClause` into a filter object for Fulfil.
|
33
38
|
# @return [Array<String>] The formatted filter for Fulfil.
|
34
39
|
def to_filter
|
35
|
-
[@key, @comparison_operator, @value]
|
40
|
+
[@key, @comparison_operator, @value, @domain].compact
|
36
41
|
end
|
37
42
|
|
38
43
|
# The `===` allows comparing different WhereClause objects. Under the hood,
|
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.20.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: 2023-01-
|
11
|
+
date: 2023-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|