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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +74 -32
  3. data/lib/mintsoft/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ccd627b64addcd5ce4600e1df832ee931f1e98ff686ab706760cfdbc02f654f
4
- data.tar.gz: 130cc96ccd064f08341c96b6ede9f06b5f86278d6dd0f3d2cccb8cbc36fb4a57
3
+ metadata.gz: 193f53b2dad0b19c81c5eb571928dde974fd46fe02f096b6093a33119528b074
4
+ data.tar.gz: 6968738d3114be16799ffd322fcecf8d4500cc913c5b557fd01c8694bc9271d9
5
5
  SHA512:
6
- metadata.gz: 3597d97e005cf9ff18df541a96d8a3dd3348847f54fbf111b3999cebd1c7d77aea4df83d7ccfd9f5942278c0960a7267eeb79dd26f9d3e4dbad6414b4fb42360
7
- data.tar.gz: bb3384d9dc29b08531761d88107695d3b8a79591e23a2d00ef5fa8d06f58597559344cf1689a4b6c4561a647c40d15e3c86524adb7bc0b0ab5beecd970b46d83
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
- # Step 1: Get authentication token
37
- auth_client = Mintsoft::AuthClient.new
38
- token = auth_client.auth.authenticate("username", "password")
39
-
40
- # Step 2: Initialize client with token
41
- client = Mintsoft::Client.new(token: token)
42
-
43
- # Step 3: Search for orders
44
- orders = client.orders.search("ORD-2024-001")
45
- order = orders.first
46
-
47
- # Step 4: Get return reasons
48
- reasons = client.returns.reasons
49
- damage_reason = reasons.find { |r| r.name.include?("Damaged") && r.active? }
50
-
51
- # Step 5: Create return
52
- return_obj = client.returns.create(order.id)
53
-
54
- # Step 6: Add item to return
55
- result = client.returns.add_item(return_obj.id, {
56
- product_id: 123,
57
- quantity: 2,
58
- reason_id: damage_reason.id,
59
- unit_value: 25.00,
60
- notes: "Damaged in shipping"
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
- token = auth_client.auth.authenticate("username", "password")
74
- puts token # Direct token string
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mintsoft
4
- VERSION = "0.1.10"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mintsoft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Chong