mintsoft 0.1.10 → 0.1.11
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 +74 -32
- 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: 193f53b2dad0b19c81c5eb571928dde974fd46fe02f096b6093a33119528b074
|
4
|
+
data.tar.gz: 6968738d3114be16799ffd322fcecf8d4500cc913c5b557fd01c8694bc9271d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a1196c64c41022aa01ff352fb4ae13e0d100937f864cd8cc2ad965439dea86c435f89e92fee2332e4725ed1f87bba64299b837fa188ec88e32e6823abafab5
|
7
|
+
data.tar.gz: bb75d0cca832ea9e1f5f9a017587dbb45d20685fdffc1656952abfca76954dba7ea55deb04b54a55c2e2dd3f256f1097df5e10f990a10e28b10f8af1f564a137
|
data/README.md
CHANGED
@@ -33,32 +33,44 @@ Or install it yourself as:
|
|
33
33
|
```ruby
|
34
34
|
require 'mintsoft'
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
36
|
+
begin
|
37
|
+
# Step 1: Get authentication token
|
38
|
+
auth_client = Mintsoft::AuthClient.new
|
39
|
+
token = auth_client.auth.authenticate("username", "password")
|
40
|
+
|
41
|
+
# Step 2: Initialize client with token
|
42
|
+
client = Mintsoft::Client.new(token: token)
|
43
|
+
|
44
|
+
# Step 3: Search for orders
|
45
|
+
orders = client.orders.search("ORD-2024-001")
|
46
|
+
if orders.empty?
|
47
|
+
puts "No orders found"
|
48
|
+
return
|
49
|
+
end
|
50
|
+
order = orders.first
|
51
|
+
|
52
|
+
# Step 4: Get return reasons
|
53
|
+
reasons = client.returns.reasons
|
54
|
+
damage_reason = reasons.find { |r| r.name.include?("Damaged") && r.active? }
|
55
|
+
|
56
|
+
# Step 5: Create return
|
57
|
+
return_obj = client.returns.create(order.id)
|
58
|
+
|
59
|
+
# Step 6: Add item to return
|
60
|
+
result = client.returns.add_item(return_obj.id, {
|
61
|
+
product_id: 123,
|
62
|
+
quantity: 2,
|
63
|
+
reason_id: damage_reason.id,
|
64
|
+
unit_value: 25.00,
|
65
|
+
notes: "Damaged in shipping"
|
66
|
+
})
|
67
|
+
rescue Mintsoft::AuthClient::AuthenticationError => e
|
68
|
+
puts "Authentication failed: #{e.message}"
|
69
|
+
rescue Mintsoft::AuthenticationError => e
|
70
|
+
puts "Token expired: #{e.message}"
|
71
|
+
rescue Mintsoft::ValidationError => e
|
72
|
+
puts "Validation error: #{e.message}"
|
73
|
+
end
|
62
74
|
```
|
63
75
|
|
64
76
|
### API Reference
|
@@ -70,8 +82,16 @@ result = client.returns.add_item(return_obj.id, {
|
|
70
82
|
auth_client = Mintsoft::AuthClient.new
|
71
83
|
|
72
84
|
# Authenticate and get token
|
73
|
-
|
74
|
-
|
85
|
+
begin
|
86
|
+
token = auth_client.auth.authenticate("username", "password")
|
87
|
+
puts token # Direct token string
|
88
|
+
rescue Mintsoft::AuthClient::AuthenticationError => e
|
89
|
+
# Invalid credentials when getting auth token
|
90
|
+
puts "Auth failed: #{e.message}"
|
91
|
+
rescue Mintsoft::ValidationError => e
|
92
|
+
# Missing username or password
|
93
|
+
puts "Validation error: #{e.message}"
|
94
|
+
end
|
75
95
|
```
|
76
96
|
|
77
97
|
#### Client
|
@@ -93,6 +113,9 @@ client = Mintsoft::Client.new(
|
|
93
113
|
# Search for orders by order number
|
94
114
|
orders = client.orders.search("ORD-123")
|
95
115
|
|
116
|
+
# Retrieve specific order by ID
|
117
|
+
order = client.orders.retrieve(order_id)
|
118
|
+
|
96
119
|
# Access order properties
|
97
120
|
order = orders.first
|
98
121
|
puts order.id # Direct access to order ID
|
@@ -140,16 +163,17 @@ All error classes now include response context and status codes for better debug
|
|
140
163
|
begin
|
141
164
|
orders = client.orders.search("ORD-123")
|
142
165
|
rescue Mintsoft::AuthenticationError => e
|
143
|
-
# Token expired or invalid (401)
|
166
|
+
# Token expired or invalid (401) - for API resource calls
|
144
167
|
puts "Authentication failed: #{e.message}"
|
145
168
|
puts "Status: #{e.status_code}"
|
169
|
+
rescue Mintsoft::AuthClient::AuthenticationError => e
|
170
|
+
# Invalid credentials when getting auth token
|
171
|
+
puts "Auth client authentication failed: #{e.message}"
|
172
|
+
puts "Status: #{e.status_code}"
|
146
173
|
rescue Mintsoft::ValidationError => e
|
147
174
|
# Invalid request data (400)
|
148
175
|
puts "Validation error: #{e.message}"
|
149
176
|
puts "Response: #{e.response.body if e.response}"
|
150
|
-
rescue Mintsoft::NotFoundError => e
|
151
|
-
# Resource not found (404)
|
152
|
-
puts "Not found: #{e.message}"
|
153
177
|
rescue Mintsoft::APIError => e
|
154
178
|
# General API error
|
155
179
|
puts "API error: #{e.message}"
|
@@ -157,6 +181,24 @@ rescue Mintsoft::APIError => e
|
|
157
181
|
end
|
158
182
|
```
|
159
183
|
|
184
|
+
### Not Found Behavior
|
185
|
+
|
186
|
+
When resources cannot be found, the gem returns `nil` instead of raising exceptions:
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
# Search for orders - returns empty array if no orders found
|
190
|
+
orders = client.orders.search("NONEXISTENT-ORDER")
|
191
|
+
puts orders.empty? # true
|
192
|
+
|
193
|
+
# Retrieve specific order - returns nil if not found
|
194
|
+
order = client.orders.retrieve(99999)
|
195
|
+
puts order.nil? # true
|
196
|
+
|
197
|
+
# Retrieve specific return - returns nil if not found
|
198
|
+
return_obj = client.returns.retrieve(99999)
|
199
|
+
puts return_obj.nil? # true
|
200
|
+
```
|
201
|
+
|
160
202
|
### Object Methods
|
161
203
|
|
162
204
|
#### Order Objects
|
data/lib/mintsoft/version.rb
CHANGED