fulfil_api 0.1.0 → 0.1.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10fcad8a31843f9c7c15e2c0d7e9ed00331fbc665091f088f6fd7794fae7159a
|
4
|
+
data.tar.gz: 367ed1508c804dc8fffc4da5089683702ca18d35433c5d6ae8744a06fae7bde7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84f5db4b17bb3c6e0011f30dd5b9a8d9472199a49f2562ad1e2646540e0d08f1d89372e42fc3f4492731c6df52e4343cda4547b20dbdcafc48c388aa176780f1
|
7
|
+
data.tar.gz: fa251dcc692380fa34543b6ae0d82338cc09b9cadd5d2d8875d02a02ee6c49168017808607a7508996f61ab10dc1d389b5915c7269b24792997ba65113071c44
|
@@ -10,20 +10,17 @@ module FulfilApi
|
|
10
10
|
# Sets the fulfillment status of the customer shipment on hold
|
11
11
|
#
|
12
12
|
# @param id_or_ids [String, Integer, Array[String], Array[Integer]] The ID(s) of the customer shipment(s) to hold.
|
13
|
-
# @param note [String] A note to define the reason for holding.
|
14
|
-
# @param hold_reason [String] An hold reason ID. (Optional)
|
13
|
+
# @param note [String] A note to define the reason for holding.
|
15
14
|
# @return [Boolean] Returns true if hold successfully.
|
16
15
|
# @raise [FulfilApi::Error] If an error occurs during holding the customer shipment.
|
17
16
|
#
|
18
17
|
# @example Hold a customer shipment
|
19
|
-
# FulfilApi::CustomerShipment.hold(123, note: "Double booking"
|
18
|
+
# FulfilApi::CustomerShipment.hold(123, note: "Double booking")
|
20
19
|
#
|
21
20
|
# @example Hold multipe customer shipments
|
22
|
-
# FulfilApi::CustomerShipment.hold([123, 456], note: "Double booking"
|
23
|
-
def hold!(id_or_ids, note:
|
24
|
-
FulfilApi.client.put("/model/#{MODEL_NAME}/hold",
|
25
|
-
body: [[*id_or_ids].flatten, { note: note, hold_reason: hold_reason }.compact_blank])
|
26
|
-
|
21
|
+
# FulfilApi::CustomerShipment.hold([123, 456], note: "Double booking")
|
22
|
+
def hold!(id_or_ids, note:)
|
23
|
+
FulfilApi.client.put("/model/#{MODEL_NAME}/hold", body: [[*id_or_ids].flatten, note])
|
27
24
|
true
|
28
25
|
end
|
29
26
|
|
@@ -40,25 +37,23 @@ module FulfilApi
|
|
40
37
|
#
|
41
38
|
# @example Unhold a customer shipment
|
42
39
|
# FulfilApi::CustomerShipment.unhold([123, 456], note: "All clear")
|
43
|
-
def unhold!(id_or_ids, note:
|
44
|
-
FulfilApi.client.put("/model/#{MODEL_NAME}/unhold", body: [[*id_or_ids].flatten,
|
45
|
-
|
40
|
+
def unhold!(id_or_ids, note:)
|
41
|
+
FulfilApi.client.put("/model/#{MODEL_NAME}/unhold", body: [[*id_or_ids].flatten, note])
|
46
42
|
true
|
47
43
|
end
|
48
44
|
end
|
49
45
|
|
50
46
|
# Sets the current customer shipment on hold, rescuing any errors that occur and handling them based on error type.
|
51
47
|
#
|
52
|
-
# @param note [String] A note to define the reason for holding.
|
53
|
-
# @param hold_reason [String] An hold reason ID. (Optional)
|
48
|
+
# @param note [String] A note to define the reason for holding.
|
54
49
|
# @return [Boolean] Returns true if hold successfully, otherwise false.
|
55
50
|
#
|
56
51
|
# @example Holds a customer_shipment
|
57
|
-
# customer_shipment.hold(
|
58
|
-
def hold(note
|
59
|
-
self.class.hold!(id, note: note
|
52
|
+
# customer_shipment.hold("Holding the shipment for 30 minutes to allow edits to the order")
|
53
|
+
def hold(note)
|
54
|
+
self.class.hold!(id, note: note)
|
60
55
|
rescue FulfilApi::Error => e
|
61
|
-
|
56
|
+
handle_exception(e)
|
62
57
|
false
|
63
58
|
end
|
64
59
|
|
@@ -68,18 +63,12 @@ module FulfilApi
|
|
68
63
|
# @return [Boolean] Returns true if unhold successfully, otherwise false.
|
69
64
|
#
|
70
65
|
# @example Unholds a customer_shipment
|
71
|
-
# customer_shipment.unhold(
|
72
|
-
def unhold(note
|
66
|
+
# customer_shipment.unhold("Ship out these items to the customer")
|
67
|
+
def unhold(note)
|
73
68
|
self.class.unhold!(id, note: note)
|
74
69
|
rescue FulfilApi::Error => e
|
75
|
-
|
70
|
+
handle_exception(e)
|
76
71
|
false
|
77
72
|
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
def handle_error(err)
|
82
|
-
errors.add(code: err.details[:response_status], type: :system, message: err.details[:response_body])
|
83
|
-
end
|
84
73
|
end
|
85
74
|
end
|
@@ -52,14 +52,7 @@ module FulfilApi
|
|
52
52
|
def save
|
53
53
|
save!
|
54
54
|
rescue FulfilApi::Error => e
|
55
|
-
|
56
|
-
in { type: "UserError" }
|
57
|
-
errors.add(code: error[:code], type: :user, message: error[:message])
|
58
|
-
in { code: Integer, name: String, description: String }
|
59
|
-
errors.add(code: error[:code], type: :authorization, message: error[:description])
|
60
|
-
end
|
61
|
-
|
62
|
-
self
|
55
|
+
handle_exception(e)
|
63
56
|
end
|
64
57
|
|
65
58
|
# Saves the current resource, raising an error if it cannot be saved.
|
@@ -67,7 +67,7 @@ module FulfilApi
|
|
67
67
|
# @return [FulfilApi::Resource::Relation] A new {Relation} instance with the conditions applied.
|
68
68
|
def where(conditions)
|
69
69
|
clone.tap do |relation|
|
70
|
-
relation.conditions << conditions
|
70
|
+
relation.conditions << conditions
|
71
71
|
relation.conditions.uniq!
|
72
72
|
end
|
73
73
|
end
|
data/lib/fulfil_api/resource.rb
CHANGED
@@ -72,5 +72,18 @@ module FulfilApi
|
|
72
72
|
private
|
73
73
|
|
74
74
|
attr_reader :model_name
|
75
|
+
|
76
|
+
def handle_exception(exception) # rubocop:disable Metrics/AbcSize
|
77
|
+
case (error = JSON.parse(exception.details[:response_body]).deep_symbolize_keys!)
|
78
|
+
in { type: "UserError" }
|
79
|
+
errors.add(code: error[:code], type: :user, message: error[:message])
|
80
|
+
in { code: Integer, name: String, description: String }
|
81
|
+
errors.add(code: error[:code], type: :authorization, message: error[:description])
|
82
|
+
else
|
83
|
+
errors.add(code: exception.details[:response_status], type: :system, message: exception.details[:response_body])
|
84
|
+
end
|
85
|
+
|
86
|
+
self
|
87
|
+
end
|
75
88
|
end
|
76
89
|
end
|
data/lib/fulfil_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulfil_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
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-09
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|