mintsoft 0.1.3 → 0.1.4
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/.serena/cache/ruby/document_symbols_cache_v23-06-25.pkl +0 -0
- data/CLAUDE.md +92 -0
- data/README.md +1 -3
- data/lib/mintsoft/resources/returns.rb +0 -2
- data/lib/mintsoft/version.rb +1 -1
- metadata +2 -2
- data/examples/complete_workflow.rb +0 -140
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fecc0acb93629b1094c612dcf46ef86985971c4ec68a186acf5253632b40daab
|
4
|
+
data.tar.gz: ddd639413c7fad8c612f33cfe0e130db31df19bfff1273122763b264bc11e15a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30bb5d08f1fa6a8a87f1e18249ae98d48ce61bf6596c78adef4cb8dc27b675db83eae05445bf583fc0ba2b3a4e0ed68c9187afbf74540e9ccb907f5c6f994d95
|
7
|
+
data.tar.gz: 5fa4691f5ee53c469004ab8a9fd57b873b79327880a8694eb7162cb0df779b426bc8eb9be704acab6132efcc5c94af5bb151f9ccfbf950a8bfb4cd4494fc1208
|
Binary file
|
data/CLAUDE.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# Mintsoft Ruby Gem - Claude Instructions
|
2
|
+
|
3
|
+
## Project Overview
|
4
|
+
|
5
|
+
This is a Ruby gem that provides a wrapper for the Mintsoft API with token-based authentication and access to warehouse management functions.
|
6
|
+
|
7
|
+
## Core Principles
|
8
|
+
|
9
|
+
### API Response Handling - CRITICAL RULE
|
10
|
+
**DO NOT ENHANCE OR INJECT DATA TO THE RESPONSE WHEN WRAPPING THE API RESPONSE IN OBJECT**
|
11
|
+
|
12
|
+
- The `Base` class (lib/mintsoft/base.rb) wraps API responses in OpenStruct objects
|
13
|
+
- Objects should only contain data that comes directly from the API response
|
14
|
+
- DO NOT add computed properties, injected fields, or derived data
|
15
|
+
- Preserve the original response structure exactly as returned by the API
|
16
|
+
- Use `@original_response` to store the frozen, unmodified API response
|
17
|
+
|
18
|
+
### Object Design
|
19
|
+
- All API objects inherit from `Mintsoft::Objects::Base`
|
20
|
+
- Base class provides OpenStruct functionality with underscore key transformation
|
21
|
+
- Objects provide `.raw` method to access original API response
|
22
|
+
- Objects provide `.to_hash` method to convert back to hash representation
|
23
|
+
- Keep object classes simple - they are data containers, not business logic
|
24
|
+
|
25
|
+
## Project Structure
|
26
|
+
|
27
|
+
```
|
28
|
+
lib/
|
29
|
+
├── mintsoft/
|
30
|
+
│ ├── base.rb # Base class for all API objects
|
31
|
+
│ ├── client.rb # Main API client
|
32
|
+
│ ├── auth_client.rb # Authentication client
|
33
|
+
│ ├── resources/ # API resource handlers
|
34
|
+
│ └── objects/ # API response objects
|
35
|
+
│ ├── order.rb # Order object (inherits from Base)
|
36
|
+
│ └── return.rb # Return object (inherits from Base)
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development Guidelines
|
40
|
+
|
41
|
+
### When Adding New Object Classes
|
42
|
+
1. Inherit from `Mintsoft::Objects::Base`
|
43
|
+
2. Keep the class minimal - let Base handle the data transformation
|
44
|
+
3. DO NOT add computed properties or inject additional data
|
45
|
+
4. Test with actual API responses to ensure correct transformation
|
46
|
+
|
47
|
+
### When Modifying Base Class
|
48
|
+
1. Maintain backward compatibility
|
49
|
+
2. Preserve original response data integrity
|
50
|
+
3. Ensure `to_hash` and `raw` methods continue to work
|
51
|
+
4. Test key transformation (camelCase to underscore)
|
52
|
+
|
53
|
+
### Error Handling
|
54
|
+
- All error classes should include response context and status codes
|
55
|
+
- Provide clear error messages for common scenarios
|
56
|
+
- Use appropriate HTTP status-based error classes
|
57
|
+
|
58
|
+
### Authentication
|
59
|
+
- Token management is manual - no automatic refresh
|
60
|
+
- Auth client returns token directly as string
|
61
|
+
- Client initialization requires explicit token parameter
|
62
|
+
|
63
|
+
## Testing
|
64
|
+
|
65
|
+
- Run tests with `rake spec`
|
66
|
+
- Test with real API responses when possible
|
67
|
+
- Ensure object transformation preserves data integrity
|
68
|
+
- Test error scenarios with appropriate status codes
|
69
|
+
|
70
|
+
## Key Files to Understand
|
71
|
+
|
72
|
+
1. `lib/mintsoft/base.rb` - Core object transformation logic
|
73
|
+
2. `lib/mintsoft/client.rb` - Main API client interface
|
74
|
+
3. `lib/mintsoft/auth_client.rb` - Authentication handling
|
75
|
+
4. `spec/` - Test files showing expected behavior
|
76
|
+
|
77
|
+
## When Making Changes
|
78
|
+
|
79
|
+
1. Read the existing code patterns first
|
80
|
+
2. Follow Ruby conventions and the existing style
|
81
|
+
3. **NEVER inject or enhance API response data**
|
82
|
+
4. Keep object classes simple and focused on data representation
|
83
|
+
5. Maintain the original response preservation pattern
|
84
|
+
6. Test thoroughly with real API responses
|
85
|
+
|
86
|
+
## Common Pitfalls to Avoid
|
87
|
+
|
88
|
+
- Adding computed properties to object classes
|
89
|
+
- Modifying API response data during object creation
|
90
|
+
- Breaking the `@original_response` storage pattern
|
91
|
+
- Adding business logic to data objects
|
92
|
+
- Changing key transformation behavior without testing
|
data/README.md
CHANGED
@@ -122,7 +122,6 @@ result = client.returns.add_item(return_obj.id, {
|
|
122
122
|
|
123
123
|
# Access return properties
|
124
124
|
puts return_obj.id # Direct access to return ID
|
125
|
-
puts return_obj.order_id # Access to associated order ID (injected by resource)
|
126
125
|
# Note: Items data structure depends on API response format
|
127
126
|
```
|
128
127
|
|
@@ -173,7 +172,6 @@ return_obj = client.returns.create(order_id)
|
|
173
172
|
|
174
173
|
# Direct property access
|
175
174
|
return_obj.id # Return ID from API response
|
176
|
-
return_obj.order_id # Associated order ID (injected by resource)
|
177
175
|
# Note: Other properties depend on API response structure
|
178
176
|
```
|
179
177
|
|
@@ -189,7 +187,7 @@ puts token # Direct token string
|
|
189
187
|
client = Mintsoft::Client.new(token: token)
|
190
188
|
|
191
189
|
# For re-authentication when token expires:
|
192
|
-
token = auth_client.auth.authenticate("username", "password")
|
190
|
+
token = auth_client.auth.authenticate("username", "password")
|
193
191
|
client = Mintsoft::Client.new(token: token)
|
194
192
|
```
|
195
193
|
|
@@ -16,7 +16,6 @@ module Mintsoft
|
|
16
16
|
|
17
17
|
response = post_request("/api/Return/CreateReturn/#{order_id}")
|
18
18
|
response_data = handle_response(response)
|
19
|
-
response_data["order_id"] = order_id
|
20
19
|
|
21
20
|
Objects::Return.new(response_data)
|
22
21
|
end
|
@@ -28,7 +27,6 @@ module Mintsoft
|
|
28
27
|
payload = format_item_payload(item_attributes)
|
29
28
|
response = post_request("/api/Return/#{return_id}/AddItem", body: payload)
|
30
29
|
response_data = handle_response(response)
|
31
|
-
response_data["return_id"] = return_id
|
32
30
|
|
33
31
|
Objects::Return.new(response_data)
|
34
32
|
end
|
data/lib/mintsoft/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Chong
|
@@ -111,11 +111,11 @@ files:
|
|
111
111
|
- ".serena/project.yml"
|
112
112
|
- ".standard.yml"
|
113
113
|
- CHANGELOG.md
|
114
|
+
- CLAUDE.md
|
114
115
|
- CODE_OF_CONDUCT.md
|
115
116
|
- LICENSE.txt
|
116
117
|
- README.md
|
117
118
|
- Rakefile
|
118
|
-
- examples/complete_workflow.rb
|
119
119
|
- lib/mintsoft.rb
|
120
120
|
- lib/mintsoft/auth_client.rb
|
121
121
|
- lib/mintsoft/base.rb
|
@@ -1,140 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# Complete workflow example for the Mintsoft gem
|
5
|
-
# This demonstrates all 5 endpoints working together
|
6
|
-
|
7
|
-
require "mintsoft"
|
8
|
-
|
9
|
-
# Step 1: Authentication using AuthClient
|
10
|
-
puts "=== Step 1: Authentication ==="
|
11
|
-
auth_client = Mintsoft::AuthClient.new
|
12
|
-
begin
|
13
|
-
token = auth_client.auth.authenticate(
|
14
|
-
ENV.fetch("MINTSOFT_USERNAME"),
|
15
|
-
ENV.fetch("MINTSOFT_PASSWORD")
|
16
|
-
)
|
17
|
-
|
18
|
-
puts "✅ Authentication successful!"
|
19
|
-
puts "Token: #{token[0...10]}..."
|
20
|
-
rescue Mintsoft::AuthenticationError => e
|
21
|
-
puts "❌ Authentication failed: #{e.message}"
|
22
|
-
exit 1
|
23
|
-
rescue KeyError => e
|
24
|
-
puts "❌ Environment variable not set: #{e.message}"
|
25
|
-
puts "Please set MINTSOFT_USERNAME and MINTSOFT_PASSWORD environment variables"
|
26
|
-
exit 1
|
27
|
-
end
|
28
|
-
|
29
|
-
# Step 2: Initialize client with token
|
30
|
-
puts "\n=== Step 2: Initialize Client ==="
|
31
|
-
client = Mintsoft::Client.new(token: token)
|
32
|
-
puts "✅ Client initialized with token"
|
33
|
-
|
34
|
-
# Step 3: Search for orders
|
35
|
-
puts "\n=== Step 3: Search Orders ==="
|
36
|
-
order_number = "ORD-2024-001" # Change this to a real order number in your system
|
37
|
-
begin
|
38
|
-
orders = client.orders.search(order_number)
|
39
|
-
|
40
|
-
if orders.empty?
|
41
|
-
puts "⚠️ No orders found with number: #{order_number}"
|
42
|
-
puts "Please try with a different order number"
|
43
|
-
exit 1
|
44
|
-
end
|
45
|
-
|
46
|
-
order = orders.first
|
47
|
-
puts "✅ Found #{orders.size} order(s)"
|
48
|
-
puts "Order ID: #{order.id}"
|
49
|
-
puts "Order Number: #{order.order_number}"
|
50
|
-
puts "Customer ID: #{order.customer_id}" if order.respond_to?(:customer_id)
|
51
|
-
puts "Status: #{order.status}" if order.respond_to?(:status)
|
52
|
-
rescue Mintsoft::ValidationError => e
|
53
|
-
puts "❌ Validation error: #{e.message}"
|
54
|
-
exit 1
|
55
|
-
rescue Mintsoft::AuthenticationError => e
|
56
|
-
puts "❌ Authentication error: #{e.message}"
|
57
|
-
puts "Token may have expired. Please re-authenticate."
|
58
|
-
exit 1
|
59
|
-
rescue Mintsoft::APIError => e
|
60
|
-
puts "❌ API error: #{e.message}"
|
61
|
-
exit 1
|
62
|
-
end
|
63
|
-
|
64
|
-
# Step 4: Get return reasons
|
65
|
-
puts "\n=== Step 4: Get Return Reasons ==="
|
66
|
-
begin
|
67
|
-
reasons = client.returns.reasons
|
68
|
-
puts "✅ Found #{reasons.size} return reason(s)"
|
69
|
-
|
70
|
-
reasons.each do |reason|
|
71
|
-
status = reason.active? ? "✅" : "❌"
|
72
|
-
puts " #{status} #{reason.name} (ID: #{reason.id}): #{reason.description}"
|
73
|
-
end
|
74
|
-
|
75
|
-
# Select the first active reason for demo
|
76
|
-
selected_reason = reasons.find(&:active?)
|
77
|
-
if selected_reason.nil?
|
78
|
-
puts "❌ No active return reasons found"
|
79
|
-
exit 1
|
80
|
-
end
|
81
|
-
|
82
|
-
puts "\n🎯 Selected reason: #{selected_reason.name}"
|
83
|
-
rescue Mintsoft::APIError => e
|
84
|
-
puts "❌ API error: #{e.message}"
|
85
|
-
exit 1
|
86
|
-
end
|
87
|
-
|
88
|
-
# Step 5: Create return
|
89
|
-
puts "\n=== Step 5: Create Return ==="
|
90
|
-
begin
|
91
|
-
return_obj = client.returns.create(order.id)
|
92
|
-
puts "✅ Return created successfully!"
|
93
|
-
puts "Return ID: #{return_obj.id}"
|
94
|
-
puts "Order ID: #{return_obj.order_id}"
|
95
|
-
puts "Status: #{return_obj.status}"
|
96
|
-
rescue Mintsoft::ValidationError => e
|
97
|
-
puts "❌ Validation error: #{e.message}"
|
98
|
-
exit 1
|
99
|
-
rescue Mintsoft::APIError => e
|
100
|
-
puts "❌ API error: #{e.message}"
|
101
|
-
exit 1
|
102
|
-
end
|
103
|
-
|
104
|
-
# Step 6: Add item to return
|
105
|
-
puts "\n=== Step 6: Add Item to Return ==="
|
106
|
-
item_attributes = {
|
107
|
-
product_id: 123, # Replace with actual product ID
|
108
|
-
quantity: 2, # Quantity to return
|
109
|
-
reason_id: selected_reason.id, # Selected return reason
|
110
|
-
unit_value: 25.00, # Unit value
|
111
|
-
notes: "Damaged during shipping" # Optional notes
|
112
|
-
}
|
113
|
-
|
114
|
-
begin
|
115
|
-
success = client.returns.add_item(return_obj.id, item_attributes)
|
116
|
-
|
117
|
-
if success
|
118
|
-
puts "✅ Item added to return successfully!"
|
119
|
-
puts "Product ID: #{item_attributes[:product_id]}"
|
120
|
-
puts "Quantity: #{item_attributes[:quantity]}"
|
121
|
-
puts "Reason: #{selected_reason.name}"
|
122
|
-
puts "Unit Value: $#{item_attributes[:unit_value]}"
|
123
|
-
puts "Notes: #{item_attributes[:notes]}"
|
124
|
-
else
|
125
|
-
puts "❌ Failed to add item to return"
|
126
|
-
end
|
127
|
-
rescue Mintsoft::ValidationError => e
|
128
|
-
puts "❌ Validation error: #{e.message}"
|
129
|
-
rescue Mintsoft::APIError => e
|
130
|
-
puts "❌ API error: #{e.message}"
|
131
|
-
end
|
132
|
-
|
133
|
-
puts "\n=== Workflow Complete ==="
|
134
|
-
puts "🎉 Successfully completed the full Mintsoft API workflow!"
|
135
|
-
puts " 1. ✅ Authenticated and got token"
|
136
|
-
puts " 2. ✅ Initialized client"
|
137
|
-
puts " 3. ✅ Searched for orders"
|
138
|
-
puts " 4. ✅ Retrieved return reasons"
|
139
|
-
puts " 5. ✅ Created return"
|
140
|
-
puts " 6. ✅ Added item to return"
|