mintsoft 0.1.11 → 0.1.12
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 +18 -7
- data/lib/mintsoft/errors.rb +2 -0
- data/lib/mintsoft/resources/base_resource.rb +5 -2
- data/lib/mintsoft/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f04dc7cd3bc75a9c2b2bc1d7cc36c247003fd0428e9c9a7d03ffc54831640429
|
4
|
+
data.tar.gz: cb488c9c266ddb1b346b5e055872918e59cdee4b6661daf055b95bc463dfca09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a329bf4a4a08129b09d3cf15f22e8e199b56218a747b0ef2007c8fa601913189df67a9b58fbb51d7d93ccad62609aa3cdf30ac043223b648d45983313e275060
|
7
|
+
data.tar.gz: ddd83252d8a4a3140cfce31220c687413b197100fcad8b864bf90dcd20b6e801780000a0f2b24246ed2f64183ef38ad5facd11d3dff330cd8afbdb563e79f2bf
|
data/README.md
CHANGED
@@ -68,6 +68,8 @@ rescue Mintsoft::AuthClient::AuthenticationError => e
|
|
68
68
|
puts "Authentication failed: #{e.message}"
|
69
69
|
rescue Mintsoft::AuthenticationError => e
|
70
70
|
puts "Token expired: #{e.message}"
|
71
|
+
rescue Mintsoft::ForbiddenError => e
|
72
|
+
puts "Insufficient permissions: #{e.message}"
|
71
73
|
rescue Mintsoft::ValidationError => e
|
72
74
|
puts "Validation error: #{e.message}"
|
73
75
|
end
|
@@ -135,13 +137,18 @@ active_reasons = reasons.select(&:active?)
|
|
135
137
|
return_obj = client.returns.create(order_id)
|
136
138
|
|
137
139
|
# Add item to return
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
140
|
+
begin
|
141
|
+
result = client.returns.add_item(return_obj.id, {
|
142
|
+
product_id: 123,
|
143
|
+
quantity: 2,
|
144
|
+
reason_id: reason_id,
|
145
|
+
unit_value: 25.00,
|
146
|
+
notes: "Optional notes"
|
147
|
+
})
|
148
|
+
rescue Mintsoft::ForbiddenError => e
|
149
|
+
# This typically occurs when credentials don't have permission to add items to returns
|
150
|
+
puts "Permission denied: #{e.message}"
|
151
|
+
end
|
145
152
|
|
146
153
|
# Retrieve a specific return by ID
|
147
154
|
return_obj = client.returns.retrieve(return_id)
|
@@ -170,6 +177,10 @@ rescue Mintsoft::AuthClient::AuthenticationError => e
|
|
170
177
|
# Invalid credentials when getting auth token
|
171
178
|
puts "Auth client authentication failed: #{e.message}"
|
172
179
|
puts "Status: #{e.status_code}"
|
180
|
+
rescue Mintsoft::ForbiddenError => e
|
181
|
+
# Insufficient permissions (403) - typically when adding items to returns
|
182
|
+
puts "Insufficient permissions: #{e.message}"
|
183
|
+
puts "Status: #{e.status_code}"
|
173
184
|
rescue Mintsoft::ValidationError => e
|
174
185
|
# Invalid request data (400)
|
175
186
|
puts "Validation error: #{e.message}"
|
data/lib/mintsoft/errors.rb
CHANGED
@@ -36,6 +36,7 @@ module Mintsoft
|
|
36
36
|
error_class = case response.status
|
37
37
|
when 400 then ValidationError
|
38
38
|
when 401 then AuthenticationError
|
39
|
+
when 403 then ForbiddenError
|
39
40
|
else APIError
|
40
41
|
end
|
41
42
|
|
@@ -45,10 +46,12 @@ module Mintsoft
|
|
45
46
|
|
46
47
|
def build_error_message(status, error_message)
|
47
48
|
case status
|
48
|
-
when 401
|
49
|
-
"Invalid or expired token"
|
50
49
|
when 400
|
51
50
|
"Invalid request data: #{error_message}"
|
51
|
+
when 401
|
52
|
+
"Invalid or expired token"
|
53
|
+
when 403
|
54
|
+
"Insufficient permissions"
|
52
55
|
else
|
53
56
|
"API error: #{status} - #{error_message}"
|
54
57
|
end
|
data/lib/mintsoft/version.rb
CHANGED