myob_acumatica 0.1.2 → 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/CHANGELOG.md +30 -3
- data/Gemfile.lock +1 -1
- data/README.md +106 -38
- data/examples/invoice.rb +64 -9
- data/examples/payment.rb +255 -0
- data/examples/tax.rb +99 -0
- data/lib/myob_acumatica/api/payment.rb +506 -0
- data/lib/myob_acumatica/api/tax.rb +350 -0
- data/lib/myob_acumatica/version.rb +1 -1
- data/lib/myob_acumatica.rb +2 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e15a5861adfeb95df2fd9ba27fdcabdd38ddd7256e06114f4f24307c3f094429
|
4
|
+
data.tar.gz: b30cb9b7080780e7017572c24e886785c8ea6c7b136ac770396f36dada9f55b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d505819ddac73957aa98a108f1f4a7d2ae9d8f21b9b0f5faa7f026fb61e2e52c16e45cdf8f04eab7e2d4b69f6c9b45d920a800060c5b896d997c00978e89bcc
|
7
|
+
data.tar.gz: 9d558ce25b14bc005aebe2c4693d3ca2c9e1192d36a1f6aaf4ff984d8e640a4590b453ea75276acd8a47eb28fcd5f46200d354319353e535886ba77249443257
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
## [0.1.
|
3
|
+
## [0.1.4] - 2025-08-13
|
4
|
+
### Added
|
5
|
+
- **Tax API** support:
|
6
|
+
- `delete_by_id`
|
7
|
+
- `delete_by_keys`
|
8
|
+
- `get_ad_hoc_schema`
|
9
|
+
- `get_by_id`
|
10
|
+
- `get_by_keys`
|
11
|
+
- `get_list`
|
12
|
+
- `invoke_action`
|
13
|
+
- `put_entity`
|
14
|
+
- `put_file`
|
4
15
|
|
5
|
-
-
|
16
|
+
## [0.1.3] - 2025-08-10
|
17
|
+
### Added
|
18
|
+
- **Payment API** support:
|
19
|
+
- `delete_by_id`
|
20
|
+
- `delete_by_keys`
|
21
|
+
- `get_ad_hoc_schema`
|
22
|
+
- `get_by_id`
|
23
|
+
- `get_by_keys`
|
24
|
+
- `get_list`
|
25
|
+
- `put_entity`
|
26
|
+
- `put_file`
|
27
|
+
- `invoke_action`
|
28
|
+
- `capture_credit_card_payment`
|
29
|
+
- `card_operation`
|
30
|
+
- `release_payment`
|
31
|
+
- `void_card_payment`
|
32
|
+
- `void_payment`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Myob Acumatica
|
2
2
|
|
3
|
-
A
|
4
|
-
|
5
|
-
---
|
3
|
+
A simple to use Ruby library for integrating with the MYOB Acumatica REST API via OAuth2.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -18,38 +16,84 @@ Without Bundler:
|
|
18
16
|
gem install myob_acumatica
|
19
17
|
```
|
20
18
|
|
21
|
-
|
19
|
+
## Configuration
|
22
20
|
|
23
|
-
|
21
|
+
Provide configuration via **environment variables** and **explicitly per call**.
|
24
22
|
|
25
|
-
|
23
|
+
**Note**: explicit parameters always override environment variables.
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
### Environment variables
|
26
|
+
|
27
|
+
```env
|
28
|
+
MYOB_ACUMATICA_INSTANCE_NAME=example.myobadvanced.com
|
29
|
+
MYOB_ACUMATICA_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx@Company
|
30
|
+
MYOB_ACUMATICA_CLIENT_SECRET=xxxxxxxxxx_x_xxxxxxxxx
|
31
31
|
MYOB_ACUMATICA_REDIRECT_URI=http://localhost:4567/oauth2/callback
|
32
32
|
MYOB_ACUMATICA_SCOPE=api offline_access
|
33
33
|
MYOB_ACUMATICA_ENDPOINT_NAME=Default
|
34
|
-
MYOB_ACUMATICA_ENDPOINT_VERSION=
|
34
|
+
MYOB_ACUMATICA_ENDPOINT_VERSION=20.200.001
|
35
35
|
```
|
36
36
|
|
37
|
-
|
37
|
+
```ruby
|
38
|
+
MyobAcumatica::Api::Customer.get_list(
|
39
|
+
access_token: token["access_token"],
|
40
|
+
query_params: { '$filter' => "Status eq 'Active'" }
|
41
|
+
)
|
42
|
+
```
|
43
|
+
|
44
|
+
### Explicit parameters
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
MyobAcumatica::Api::Customer.get_list(
|
48
|
+
access_token: token["access_token"],
|
49
|
+
instance_name: "example.myobadvanced.com",
|
50
|
+
endpoint_name: "Default",
|
51
|
+
endpoint_version: "20.200.001",
|
52
|
+
query_params: { '$filter' => "Status eq 'Active'" }
|
53
|
+
)
|
54
|
+
```
|
55
|
+
|
56
|
+
## Authorization
|
57
|
+
|
58
|
+
Allow a client application to obtain an access token on behalf of a user, using an authorization code granted by the user after consent.
|
38
59
|
|
39
|
-
|
60
|
+
### Generate authorization request URL
|
40
61
|
|
41
|
-
|
62
|
+
Redirect the user to the authorization endpoint to initiate the consent flow.
|
42
63
|
|
43
64
|
```ruby
|
44
|
-
MyobAcumatica::OAuth2::Token.authorize_url
|
65
|
+
MyobAcumatica::OAuth2::Token.authorize_url(
|
66
|
+
instance_name: 'example.myobadvanced.com',
|
67
|
+
redirect_uri: 'https://example.myobadvanced.com/oauth2/callback',
|
68
|
+
client_id: 'abc123',
|
69
|
+
scope: 'api offline_access'
|
70
|
+
)
|
71
|
+
```
|
72
|
+
|
73
|
+
This returns a URL like:
|
74
|
+
|
75
|
+
```
|
76
|
+
https://example.myobadvanced.com/identity/connect/authorize?response_type=code&client_id=abc123&redirect_uri=https%3A%2F%2Fexample.myobadvanced.com%2Foauth2%2Fcallback&scope=api+offline_access
|
45
77
|
```
|
46
78
|
|
47
|
-
|
79
|
+
Send users to this URL to initiate the authorization code grant flow.
|
80
|
+
|
81
|
+
### Exchange authorization code for access token
|
82
|
+
|
83
|
+
After the user grants consent, Acumatica will redirect to your callback URL with a `code` parameter. Exchange it for an access token:
|
48
84
|
|
49
85
|
```ruby
|
50
|
-
token = MyobAcumatica::OAuth2::Token.authorize(
|
86
|
+
token = MyobAcumatica::OAuth2::Token.authorize(
|
87
|
+
code: params[:code],
|
88
|
+
instance_name: 'example.myobadvanced.com',
|
89
|
+
redirect_uri: 'https://example.myobadvanced.com/oauth2/callback',
|
90
|
+
client_id: 'abc123',
|
91
|
+
client_secret: 'secret123'
|
92
|
+
)
|
51
93
|
```
|
52
94
|
|
95
|
+
Example response:
|
96
|
+
|
53
97
|
```ruby
|
54
98
|
{
|
55
99
|
"access_token" => "...",
|
@@ -60,21 +104,34 @@ token = MyobAcumatica::OAuth2::Token.authorize(code: params[:code])
|
|
60
104
|
}
|
61
105
|
```
|
62
106
|
|
63
|
-
Refresh
|
107
|
+
### Refresh access token
|
108
|
+
|
109
|
+
When the access token expires, use the `refresh_token` to obtain a new one without prompting the user again.
|
64
110
|
|
65
111
|
```ruby
|
66
|
-
token = MyobAcumatica::OAuth2::Token.refresh(
|
112
|
+
token = MyobAcumatica::OAuth2::Token.refresh(
|
113
|
+
refresh_token: token["refresh_token"],
|
114
|
+
instance_name: 'example.myobadvanced.com',
|
115
|
+
client_id: 'abc123',
|
116
|
+
client_secret: 'secret123'
|
117
|
+
)
|
67
118
|
```
|
68
119
|
|
69
|
-
|
120
|
+
This returns a fresh token object with the same structure.
|
70
121
|
|
71
|
-
|
122
|
+
|
123
|
+
## Usage
|
124
|
+
|
125
|
+
### Customers
|
72
126
|
|
73
127
|
Create or update a customer:
|
74
128
|
|
75
129
|
```ruby
|
76
130
|
MyobAcumatica::Api::Customer.put_entity(
|
77
|
-
access_token: token[
|
131
|
+
access_token: token['access_token'],
|
132
|
+
instance_name: 'example.myobadvanced.com',
|
133
|
+
endpoint_name: 'Default',
|
134
|
+
endpoint_version: '20.200.001',
|
78
135
|
entity: {
|
79
136
|
'CustomerID' => { 'value' => 'JOHNGOOD' },
|
80
137
|
'CustomerName' => { 'value' => 'John Good' },
|
@@ -87,7 +144,10 @@ List customers:
|
|
87
144
|
|
88
145
|
```ruby
|
89
146
|
MyobAcumatica::Api::Customer.get_list(
|
90
|
-
access_token: token[
|
147
|
+
access_token: token['access_token'],
|
148
|
+
instance_name: 'example.myobadvanced.com',
|
149
|
+
endpoint_name: 'Default',
|
150
|
+
endpoint_version: '20.200.001',
|
91
151
|
query_params: { '$filter' => "Status eq 'Active'" }
|
92
152
|
)
|
93
153
|
```
|
@@ -96,7 +156,10 @@ Get customer by keys:
|
|
96
156
|
|
97
157
|
```ruby
|
98
158
|
MyobAcumatica::Api::Customer.get_by_keys(
|
99
|
-
access_token: token[
|
159
|
+
access_token: token['access_token'],
|
160
|
+
instance_name: 'example.myobadvanced.com',
|
161
|
+
endpoint_name: 'Default',
|
162
|
+
endpoint_version: '20.200.001',
|
100
163
|
keys: ['JOHNGOOD']
|
101
164
|
)
|
102
165
|
```
|
@@ -105,20 +168,24 @@ Delete a customer:
|
|
105
168
|
|
106
169
|
```ruby
|
107
170
|
MyobAcumatica::Api::Customer.delete_by_keys(
|
108
|
-
access_token: token[
|
171
|
+
access_token: token['access_token'],
|
172
|
+
instance_name: 'example.myobadvanced.com',
|
173
|
+
endpoint_name: 'Default',
|
174
|
+
endpoint_version: '20.200.001',
|
109
175
|
keys: ['JOHNGOOD']
|
110
176
|
)
|
111
177
|
```
|
112
178
|
|
113
|
-
|
114
|
-
|
115
|
-
## Invoice Examples
|
179
|
+
### Invoices
|
116
180
|
|
117
181
|
Create an invoice:
|
118
182
|
|
119
183
|
```ruby
|
120
184
|
MyobAcumatica::Api::Invoice.put_entity(
|
121
185
|
access_token: token["access_token"],
|
186
|
+
instance_name: 'example.myobadvanced.com',
|
187
|
+
endpoint_name: 'Default',
|
188
|
+
endpoint_version: '20.200.001',
|
122
189
|
entity: {
|
123
190
|
'CustomerID' => { 'value' => 'JOHNGOOD' },
|
124
191
|
'Date' => { 'value' => '2025-06-06' },
|
@@ -138,6 +205,9 @@ List invoices:
|
|
138
205
|
```ruby
|
139
206
|
MyobAcumatica::Api::Invoice.get_list(
|
140
207
|
access_token: token["access_token"],
|
208
|
+
instance_name: 'example.myobadvanced.com',
|
209
|
+
endpoint_name: 'Default',
|
210
|
+
endpoint_version: '20.200.001',
|
141
211
|
query_params: {
|
142
212
|
'$filter' => "Status eq 'Open'",
|
143
213
|
'$top' => 10,
|
@@ -151,6 +221,9 @@ Get invoice by ID:
|
|
151
221
|
```ruby
|
152
222
|
MyobAcumatica::Api::Invoice.get_by_id(
|
153
223
|
access_token: token["access_token"],
|
224
|
+
instance_name: 'example.myobadvanced.com',
|
225
|
+
endpoint_name: 'Default',
|
226
|
+
endpoint_version: '20.200.001',
|
154
227
|
id: '00000000-0000-0000-0000-000000000000'
|
155
228
|
)
|
156
229
|
```
|
@@ -160,18 +233,17 @@ Delete an invoice:
|
|
160
233
|
```ruby
|
161
234
|
MyobAcumatica::Api::Invoice.delete_by_id(
|
162
235
|
access_token: token["access_token"],
|
236
|
+
instance_name: 'example.myobadvanced.com',
|
237
|
+
endpoint_name: 'Default',
|
238
|
+
endpoint_version: '20.200.001',
|
163
239
|
id: '00000000-0000-0000-0000-000000000000'
|
164
240
|
)
|
165
241
|
```
|
166
242
|
|
167
|
-
---
|
168
|
-
|
169
243
|
## Documentation
|
170
244
|
|
171
245
|
See full API reference and usage examples: [rubydoc.info/gems/myob_acumatica](https://www.rubydoc.info/gems/myob_acumatica)
|
172
246
|
|
173
|
-
---
|
174
|
-
|
175
247
|
## Development
|
176
248
|
|
177
249
|
### 1. Clone the repo
|
@@ -185,7 +257,7 @@ bundle install
|
|
185
257
|
### 2. Create a `.env` file
|
186
258
|
|
187
259
|
```env
|
188
|
-
MYOB_ACUMATICA_INSTANCE_NAME=
|
260
|
+
MYOB_ACUMATICA_INSTANCE_NAME=example.myob.com
|
189
261
|
MYOB_ACUMATICA_CLIENT_ID=your-client-id
|
190
262
|
MYOB_ACUMATICA_CLIENT_SECRET=your-client-secret
|
191
263
|
MYOB_ACUMATICA_REDIRECT_URI=http://localhost:4567/oauth2/callback
|
@@ -219,8 +291,6 @@ Try this command with your token:
|
|
219
291
|
MyobAcumatica::Api::Customer.get_list(access_token: token["access_token"])
|
220
292
|
```
|
221
293
|
|
222
|
-
---
|
223
|
-
|
224
294
|
## Contributing
|
225
295
|
|
226
296
|
Bug reports and pull requests are welcome at:
|
@@ -229,8 +299,6 @@ https://github.com/fast-programmer/myob_acumatica
|
|
229
299
|
Please follow the code of conduct:
|
230
300
|
https://github.com/fast-programmer/myob_acumatica/blob/master/CODE_OF_CONDUCT.md
|
231
301
|
|
232
|
-
---
|
233
|
-
|
234
302
|
## License
|
235
303
|
|
236
304
|
MIT — see the LICENSE
|
data/examples/invoice.rb
CHANGED
@@ -18,18 +18,26 @@ invoice1 = MyobAcumatica::Api::Invoice.put_entity(
|
|
18
18
|
access_token: access_token,
|
19
19
|
entity: {
|
20
20
|
'Customer' => { 'value' => 'JOHNGOOD1' },
|
21
|
-
'CustomerID' => { 'value' => 'JOHNGOOD1' },
|
22
21
|
'Date' => { 'value' => Date.today.strftime('%Y-%m-%d') },
|
23
22
|
'DueDate' => { 'value' => (Date.today + 30).strftime('%Y-%m-%d') },
|
24
23
|
'Terms' => { 'value' => 'NET14DAYS' },
|
25
24
|
'Type' => { 'value' => 'Invoice' },
|
26
25
|
'Hold' => { 'value' => false },
|
26
|
+
'PostPeriod' => { 'value' => '08-2025' },
|
27
27
|
'BillingAddressOverride' => { 'value' => true },
|
28
28
|
'BillingAddress' => {
|
29
29
|
'AddressLine1' => { 'value' => 'Fillmore Str' },
|
30
30
|
'City' => { 'value' => 'San Francisco' },
|
31
31
|
'State' => { 'value' => 'CA' }
|
32
32
|
},
|
33
|
+
'Description' => { 'value' => 'Test stock item' },
|
34
|
+
'Details' => [
|
35
|
+
{
|
36
|
+
'Description' => { 'value' => 'Pair of sneakers' },
|
37
|
+
'Quantity' => { 'value' => 1 },
|
38
|
+
'UnitPrice' => { 'value' => 100.00 }
|
39
|
+
}
|
40
|
+
],
|
33
41
|
'custom' => {
|
34
42
|
'Document' => {
|
35
43
|
'DiscDate' => { 'value' => (Date.today + 10).strftime('%Y-%m-%dT00:00:00+00:00') }
|
@@ -39,6 +47,14 @@ invoice1 = MyobAcumatica::Api::Invoice.put_entity(
|
|
39
47
|
logger: logger
|
40
48
|
)
|
41
49
|
|
50
|
+
MyobAcumatica::Api::Invoice.release(
|
51
|
+
access_token: access_token,
|
52
|
+
entity: {
|
53
|
+
'id' => invoice1['id']
|
54
|
+
},
|
55
|
+
logger: logger
|
56
|
+
)
|
57
|
+
|
42
58
|
MyobAcumatica::Api::Invoice.get_by_id(
|
43
59
|
access_token: access_token,
|
44
60
|
id: invoice1['id'],
|
@@ -54,11 +70,55 @@ MyobAcumatica::Api::Invoice.get_by_keys(
|
|
54
70
|
MyobAcumatica::Api::Invoice.get_list(
|
55
71
|
access_token: access_token,
|
56
72
|
query_params: {
|
73
|
+
'$filter' => "Type eq 'Invoice'"
|
57
74
|
# '$filter' => "Status eq 'Open' and "\
|
58
75
|
# "LastModifiedDateTime gt datetimeoffset'2020-08-18T23:59:59.999+04:00'",
|
59
76
|
# '$expand' => 'Invoices',
|
60
|
-
'$skip' => 1,
|
61
|
-
'$top' => 4
|
77
|
+
# '$skip' => 1,
|
78
|
+
# '$top' => 4
|
79
|
+
},
|
80
|
+
logger: logger
|
81
|
+
)
|
82
|
+
|
83
|
+
credit_memo1 = MyobAcumatica::Api::Invoice.put_entity(
|
84
|
+
access_token: access_token,
|
85
|
+
entity: {
|
86
|
+
'Customer' => { 'value' => 'JOHNGOOD1' },
|
87
|
+
'CustomerID' => { 'value' => 'JOHNGOOD1' },
|
88
|
+
'Date' => { 'value' => Date.today.strftime('%Y-%m-%d') },
|
89
|
+
'DueDate' => { 'value' => (Date.today + 30).strftime('%Y-%m-%d') },
|
90
|
+
'Terms' => { 'value' => 'NET14DAYS' },
|
91
|
+
'Type' => { 'value' => 'Credit Memo' },
|
92
|
+
'Hold' => { 'value' => false },
|
93
|
+
'PostPeriod' => { 'value' => '08-2025' },
|
94
|
+
'BillingAddressOverride' => { 'value' => true },
|
95
|
+
'BillingAddress' => {
|
96
|
+
'AddressLine1' => { 'value' => 'Fillmore Str' },
|
97
|
+
'City' => { 'value' => 'San Francisco' },
|
98
|
+
'State' => { 'value' => 'CA' }
|
99
|
+
},
|
100
|
+
'custom' => {
|
101
|
+
'Document' => {
|
102
|
+
'DiscDate' => { 'value' => (Date.today + 10).strftime('%Y-%m-%dT00:00:00+00:00') }
|
103
|
+
}
|
104
|
+
}
|
105
|
+
},
|
106
|
+
logger: logger
|
107
|
+
)
|
108
|
+
|
109
|
+
MyobAcumatica::Api::Invoice.release(
|
110
|
+
access_token: access_token,
|
111
|
+
entity: {
|
112
|
+
'Type' => credit_memo1['Type'],
|
113
|
+
'ReferenceNbr' => credit_memo1['ReferenceNbr']
|
114
|
+
},
|
115
|
+
logger: logger
|
116
|
+
)
|
117
|
+
|
118
|
+
MyobAcumatica::Api::Invoice.get_list(
|
119
|
+
access_token: access_token,
|
120
|
+
query_params: {
|
121
|
+
'$filter' => "Type eq 'Credit Memo'"
|
62
122
|
},
|
63
123
|
logger: logger
|
64
124
|
)
|
@@ -77,12 +137,6 @@ MyobAcumatica::Api::Invoice.invoke_action(
|
|
77
137
|
logger: logger
|
78
138
|
)
|
79
139
|
|
80
|
-
# MyobAcumatica::Api::Invoice.release(
|
81
|
-
# access_token: access_token,
|
82
|
-
# entity: { 'id' => invoice1['id'] },
|
83
|
-
# logger: logger
|
84
|
-
# )
|
85
|
-
|
86
140
|
MyobAcumatica::Api::Invoice.delete_by_keys(
|
87
141
|
access_token: access_token,
|
88
142
|
keys: [invoice1['Type']['value'], invoice1['ReferenceNbr']['value']],
|
@@ -99,6 +153,7 @@ invoice2 = MyobAcumatica::Api::Invoice.put_entity(
|
|
99
153
|
'Terms' => { 'value' => 'NET14DAYS' },
|
100
154
|
'Type' => { 'value' => 'Invoice' },
|
101
155
|
'Hold' => { 'value' => false },
|
156
|
+
'PostPeriod' => { 'value' => '08-2025' },
|
102
157
|
'BillingAddressOverride' => { 'value' => true },
|
103
158
|
'BillingAddress' => {
|
104
159
|
'AddressLine1' => { 'value' => 'Fillmore Str' },
|