erp_integration 0.20.0 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/pull_requests.yml +1 -1
- data/lib/erp_integration/channel_listing.rb +2 -1
- data/lib/erp_integration/fulfil/api_resource.rb +3 -3
- data/lib/erp_integration/fulfil/pagination_methods.rb +49 -6
- data/lib/erp_integration/fulfil/query.rb +6 -6
- data/lib/erp_integration/fulfil/resources/sales_order.rb +6 -0
- data/lib/erp_integration/sales_order.rb +4 -0
- 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: 0521d80838f8ccd03a3c0dd41d712f9313e3dfc0c399b32bfc61164196e0bafa
|
4
|
+
data.tar.gz: ab487dd4c2f93eb5c41178970c76811cbb986d513f5aea4dd7fa9d646ec90336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e06719aa752a9c5e59723ab446285d1759190ddd5b467afa049de1e056710cf7564d4da13239384a7eb93cde799cd277e19bc3c2120fb8ce82cfd86a8716a0
|
7
|
+
data.tar.gz: cb8a670fc0a97172b4ac631c15b4ded0e600af49da29aebc1a80c11034bed903c63c76064c1f083d1ae33d9e2e1cdc1c14809a596407bb0e299e0188de46eb5f
|
@@ -4,6 +4,7 @@ module ErpIntegration
|
|
4
4
|
# The `ErpIntegration::ChannelListing` exposes an uniformed API for interaction with
|
5
5
|
# third-party ERP vendors.
|
6
6
|
class ChannelListing < Resource
|
7
|
-
attr_accessor :id, :channel, :product,
|
7
|
+
attr_accessor :availability_source, :bom, :id, :channel, :product,
|
8
|
+
:quantity, :product_identifier
|
8
9
|
end
|
9
10
|
end
|
@@ -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,18 +3,19 @@
|
|
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 :offset_value, :
|
10
|
+
attr_accessor :limit_value, :offset_value, :page_number
|
10
11
|
|
11
12
|
# The {#offset} method allows navigating through the returned resources from
|
12
13
|
# Fulfil's API endpoints just as with a regular database.
|
13
14
|
#
|
14
|
-
# @param value [Integer] The offset for the number of resources.
|
15
|
+
# @param value [String, Integer] The offset for the number of resources.
|
15
16
|
# @return [ErpIntegration::Fulfil::ApiResource]
|
16
17
|
def offset(value)
|
17
|
-
clone.offset!(value)
|
18
|
+
clone.offset!(value.to_i)
|
18
19
|
end
|
19
20
|
|
20
21
|
def offset!(value)
|
@@ -28,16 +29,58 @@ module ErpIntegration
|
|
28
29
|
#
|
29
30
|
# NOTE: The maximum limit is 500 per dictation of Fulfil.
|
30
31
|
#
|
31
|
-
# @param value [Integer] The number of resources to return.
|
32
|
+
# @param value [String, Integer] The number of resources to return.
|
32
33
|
# @return [ErpIntegration::Fulfil::ApiResource]
|
33
34
|
def limit(value)
|
34
|
-
clone.limit!(value)
|
35
|
+
clone.limit!(value.to_i)
|
35
36
|
end
|
36
37
|
|
37
38
|
def limit!(value)
|
38
39
|
self.limit_value = [value, MAX_LIMIT].min
|
39
40
|
self
|
40
41
|
end
|
42
|
+
|
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
|
56
|
+
|
57
|
+
# @param page_number [Integer]
|
58
|
+
# @return [ErpIntegration::Fulfil::ApiResource]
|
59
|
+
def page!(page_number)
|
60
|
+
self.page_number = page_number
|
61
|
+
self
|
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
|
41
84
|
end
|
42
85
|
end
|
43
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
|
@@ -29,6 +29,12 @@ module ErpIntegration
|
|
29
29
|
true
|
30
30
|
end
|
31
31
|
|
32
|
+
def return!(id, options)
|
33
|
+
client.put("model/sale.sale/#{id}/return_order", options)
|
34
|
+
rescue ErpIntegration::HttpError::BadRequest
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
32
38
|
# Allows duplicating the entire sales order in Fulfil.
|
33
39
|
# @param id [Integer|String] The ID of the to be duplicated order.
|
34
40
|
# @return [Array|boolean] Whether the sales order was duplicated successfully or not.
|
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.22.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-
|
11
|
+
date: 2023-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|