myob_acumatica 0.1.1 → 0.1.3
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/Gemfile.lock +1 -1
- data/README.md +106 -38
- data/examples/invoice.rb +64 -9
- data/examples/payment.rb +255 -0
- data/lib/myob_acumatica/api/payment.rb +506 -0
- data/lib/myob_acumatica/version.rb +1 -1
- data/lib/myob_acumatica.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f5ec6ddaf89cf216541bfa7a9fdd1a6192a784f55b01010a62a888f4847135
|
4
|
+
data.tar.gz: b0e1f317f5f1b72d4606f2b8220503ef8896fbfcb64da9c5c008d28ceacde648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f5694a5494e9a8452f68de3bd4e65cc0514e9b8455c9cc04b70bfd41dfc723c1f151ec4c27c1a72ec2e5c69694952a05ff88251b511c6f4ad7a8dde18513d96
|
7
|
+
data.tar.gz: ae673387e1f6423664fa246d3d5c8f9309127b1233aa5da648e5e89570211f51656535e4c15b22675d9f1c682a9f452092035afb5a1b5c3f994601ff8f2a75d6
|
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' },
|
data/examples/payment.rb
ADDED
@@ -0,0 +1,255 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'logger'
|
5
|
+
require 'date'
|
6
|
+
require 'dotenv/load'
|
7
|
+
require 'myob_acumatica'
|
8
|
+
|
9
|
+
access_token = ENV['MYOB_ACUMATICA_ACCESS_TOKEN']
|
10
|
+
logger = Logger.new($stdout)
|
11
|
+
|
12
|
+
MyobAcumatica::Api::Payment.get_ad_hoc_schema(
|
13
|
+
access_token: access_token,
|
14
|
+
logger: logger
|
15
|
+
)
|
16
|
+
|
17
|
+
MyobAcumatica::Api::Customer.put_entity(
|
18
|
+
access_token: access_token,
|
19
|
+
entity: {
|
20
|
+
'CustomerID' => { 'value' => 'JOHNGOODPAYER' },
|
21
|
+
'CustomerName' => { 'value' => 'John Good PAYER' },
|
22
|
+
'CustomerClass' => { 'value' => 'CUSTDFT' },
|
23
|
+
'MainContact' => {
|
24
|
+
'Email' => { 'value' => 'demo@gmail.com' },
|
25
|
+
'Address' => {
|
26
|
+
'AddressLine1' => { 'value' => '4030 Lake Washington Blvd NE' },
|
27
|
+
'AddressLine2' => { 'value' => 'Suite 100' },
|
28
|
+
'City' => { 'value' => 'Kirkland' },
|
29
|
+
'State' => { 'value' => 'WA' },
|
30
|
+
'PostalCode' => { 'value' => '98033' },
|
31
|
+
'Country' => { 'value' => 'US' }
|
32
|
+
}
|
33
|
+
}
|
34
|
+
},
|
35
|
+
logger: logger
|
36
|
+
)
|
37
|
+
|
38
|
+
invoice1 = MyobAcumatica::Api::Invoice.put_entity(
|
39
|
+
access_token: access_token,
|
40
|
+
entity: {
|
41
|
+
'Customer' => { 'value' => 'JOHNGOODPAYER' },
|
42
|
+
'Date' => { 'value' => Date.today.strftime('%Y-%m-%d') },
|
43
|
+
'DueDate' => { 'value' => (Date.today + 30).strftime('%Y-%m-%d') },
|
44
|
+
'Terms' => { 'value' => 'NET14DAYS' },
|
45
|
+
'Hold' => { 'value' => false },
|
46
|
+
'PostPeriod' => { 'value' => '08-2025' },
|
47
|
+
'BillingAddressOverride' => { 'value' => true },
|
48
|
+
'BillingAddress' => {
|
49
|
+
'AddressLine1' => { 'value' => 'Fillmore Str' },
|
50
|
+
'City' => { 'value' => 'San Francisco' },
|
51
|
+
'State' => { 'value' => 'CA' }
|
52
|
+
},
|
53
|
+
'Description' => { 'value' => 'Test stock item' },
|
54
|
+
'Details' => [
|
55
|
+
{
|
56
|
+
'Description' => { 'value' => 'Pair of sneakers' },
|
57
|
+
'Quantity' => { 'value' => 1 },
|
58
|
+
'UnitPrice' => { 'value' => 100.00 }
|
59
|
+
}
|
60
|
+
],
|
61
|
+
'custom' => {
|
62
|
+
'Document' => {
|
63
|
+
'DiscDate' => { 'value' => (Date.today + 10).strftime('%Y-%m-%dT00:00:00+00:00') }
|
64
|
+
}
|
65
|
+
}
|
66
|
+
},
|
67
|
+
logger: logger
|
68
|
+
)
|
69
|
+
|
70
|
+
puts "Created invoice: #{invoice1['ReferenceNbr']['value']}"
|
71
|
+
|
72
|
+
MyobAcumatica::Api::Invoice.release(
|
73
|
+
access_token: access_token,
|
74
|
+
entity: {
|
75
|
+
'id' => invoice1['id']
|
76
|
+
},
|
77
|
+
logger: logger
|
78
|
+
)
|
79
|
+
|
80
|
+
payment45 = MyobAcumatica::Api::Payment.put_entity(
|
81
|
+
access_token: access_token,
|
82
|
+
entity: {
|
83
|
+
'CustomerID' => { 'value' => 'JOHNGOODPAYER' },
|
84
|
+
'ApplicationDate' => { 'value' => '2025-05-6' },
|
85
|
+
'PostPeriod' => { 'value' => '11-2025' },
|
86
|
+
'Branch' => { 'value' => 'MAIN' },
|
87
|
+
'PaymentMethod' => { 'value' => 'CASH' },
|
88
|
+
'CashAccount' => { 'value' => 'CASHACCC' },
|
89
|
+
'Hold' => { 'value' => true },
|
90
|
+
'Applications' => [
|
91
|
+
{
|
92
|
+
'DocType' => { 'value' => 'Invoice' },
|
93
|
+
'ReferenceNbr' => { 'value' => invoice1['ReferenceNbr']['value'] },
|
94
|
+
'AmountPaid' => { 'value' => 45.0 },
|
95
|
+
'Apply' => { 'value' => true }
|
96
|
+
}
|
97
|
+
]
|
98
|
+
},
|
99
|
+
logger: logger
|
100
|
+
)
|
101
|
+
|
102
|
+
MyobAcumatica::Api::Payment.put_entity(
|
103
|
+
access_token: access_token,
|
104
|
+
entity: {
|
105
|
+
'id' => payment45['id'],
|
106
|
+
'Hold' => { 'value' => false }
|
107
|
+
},
|
108
|
+
logger: logger
|
109
|
+
)
|
110
|
+
|
111
|
+
MyobAcumatica::Api::Payment.release_payment(
|
112
|
+
access_token: access_token,
|
113
|
+
entity: { 'id' => payment45['id'] },
|
114
|
+
logger: logger
|
115
|
+
)
|
116
|
+
|
117
|
+
payment55 = MyobAcumatica::Api::Payment.put_entity(
|
118
|
+
access_token: access_token,
|
119
|
+
entity: {
|
120
|
+
'CustomerID' => { 'value' => 'JOHNGOODPAYER' },
|
121
|
+
'CustomerLocationID' => { 'value' => 'MAIN' },
|
122
|
+
'ApplicationDate' => { 'value' => '2025-05-6' },
|
123
|
+
'PostPeriod' => { 'value' => '11-2025' },
|
124
|
+
'Branch' => { 'value' => 'MAIN' },
|
125
|
+
'PaymentMethod' => { 'value' => 'CASH' },
|
126
|
+
'CashAccount' => { 'value' => 'CASHACCC' },
|
127
|
+
'Hold' => { 'value' => false },
|
128
|
+
'Applications' => [
|
129
|
+
{
|
130
|
+
'DocType' => { 'value' => 'Invoice' },
|
131
|
+
'ReferenceNbr' => { 'value' => invoice1['ReferenceNbr']['value'] },
|
132
|
+
'AmountPaid' => { 'value' => 55.0 },
|
133
|
+
'Apply' => { 'value' => true }
|
134
|
+
}
|
135
|
+
]
|
136
|
+
},
|
137
|
+
logger: logger
|
138
|
+
)
|
139
|
+
|
140
|
+
MyobAcumatica::Api::Payment.invoke_action(
|
141
|
+
access_token: access_token,
|
142
|
+
action_name: 'ReleasePayment',
|
143
|
+
entity: { 'id' => payment55['id'] },
|
144
|
+
logger: logger
|
145
|
+
)
|
146
|
+
|
147
|
+
MyobAcumatica::Api::Payment.get_by_id(
|
148
|
+
access_token: access_token,
|
149
|
+
id: payment45['id'],
|
150
|
+
logger: logger
|
151
|
+
)
|
152
|
+
|
153
|
+
MyobAcumatica::Api::Payment.get_by_keys(
|
154
|
+
access_token: access_token,
|
155
|
+
keys: [payment55['Type']['value'], payment55['ReferenceNbr']['value']],
|
156
|
+
logger: logger
|
157
|
+
)
|
158
|
+
|
159
|
+
MyobAcumatica::Api::Payment.get_list(
|
160
|
+
access_token: access_token,
|
161
|
+
query_params: {
|
162
|
+
'$filter' => "Type eq 'Payment'"
|
163
|
+
},
|
164
|
+
logger: logger
|
165
|
+
)
|
166
|
+
|
167
|
+
MyobAcumatica::Api::Payment.put_file(
|
168
|
+
access_token: access_token,
|
169
|
+
keys: [payment45['Type']['value'], payment45['ReferenceNbr']['value']],
|
170
|
+
file_path: 'examples/dummy.pdf',
|
171
|
+
logger: logger
|
172
|
+
)
|
173
|
+
|
174
|
+
# cc_pay = MyobAcumatica::Api::Payment.put_entity(
|
175
|
+
# access_token: access_token,
|
176
|
+
# entity: {
|
177
|
+
# 'Type' => { 'value' => 'Payment' },
|
178
|
+
# 'CustomerID' => { 'value' => customer['CustomerID'] },
|
179
|
+
# 'ApplicationDate' => { 'value' => '2025-05-6' },
|
180
|
+
# 'PostPeriod' => { 'value' => '11-2025' },
|
181
|
+
# 'Branch' => { 'value' => 'MAIN' },
|
182
|
+
# 'PaymentMethod' => { 'value' => 'CCARD' },
|
183
|
+
# 'CashAccount' => { 'value' => 'CASHACCOUNT' },
|
184
|
+
# 'Hold' => { 'value' => false }
|
185
|
+
# },
|
186
|
+
# logger: logger
|
187
|
+
# )
|
188
|
+
|
189
|
+
# MyobAcumatica::Api::Payment.card_operation(
|
190
|
+
# access_token: access_token,
|
191
|
+
# entity: {
|
192
|
+
# 'ReferenceNbr' => { 'value' => cc_pay['ReferenceNbr']['value'] }
|
193
|
+
# },
|
194
|
+
# parameters: {
|
195
|
+
# 'Operation' => { 'value' => 'Authorize' },
|
196
|
+
# 'Amount' => { 'value' => 60.0 }
|
197
|
+
# },
|
198
|
+
# logger: logger
|
199
|
+
# )
|
200
|
+
|
201
|
+
# MyobAcumatica::Api::Payment.capture_credit_card_payment(
|
202
|
+
# access_token: access_token,
|
203
|
+
# entity: {
|
204
|
+
# 'ReferenceNbr' => { 'value' => cc_pay['ReferenceNbr']['value'] }
|
205
|
+
# },
|
206
|
+
# parameters: {
|
207
|
+
# 'Amount' => { 'value' => 60.0 }
|
208
|
+
# },
|
209
|
+
# logger: logger
|
210
|
+
# )
|
211
|
+
|
212
|
+
# MyobAcumatica::Api::Payment.release_payment(
|
213
|
+
# access_token: access_token,
|
214
|
+
# entity: {
|
215
|
+
# 'ReferenceNbr' => { 'value' => cc_pay['ReferenceNbr']['value'] }
|
216
|
+
# },
|
217
|
+
# logger: logger
|
218
|
+
# )
|
219
|
+
|
220
|
+
# voidable = MyobAcumatica::Api::Payment.put_entity(
|
221
|
+
# access_token: access_token,
|
222
|
+
# entity: {
|
223
|
+
# 'Type' => { 'value' => 'Payment' },
|
224
|
+
# 'CustomerID' => { 'value' => customer['CustomerID'] },
|
225
|
+
# 'ApplicationDate' => { 'value' => Date.today.strftime('%Y-%m-%d') },
|
226
|
+
# 'PaymentMethod' => { 'value' => cash_method },
|
227
|
+
# 'CashAccount' => { 'value' => cash_account },
|
228
|
+
# 'Hold' => { 'value' => true }
|
229
|
+
# },
|
230
|
+
# logger: logger
|
231
|
+
# )
|
232
|
+
|
233
|
+
# MyobAcumatica::Api::Payment.void_payment(
|
234
|
+
# access_token: access_token,
|
235
|
+
# entity: { 'ReferenceNbr' => { 'value' => voidable['ReferenceNbr']['value'] } },
|
236
|
+
# logger: logger
|
237
|
+
# )
|
238
|
+
|
239
|
+
# MyobAcumatica::Api::Payment.void_card_payment(
|
240
|
+
# access_token: access_token,
|
241
|
+
# entity: { 'ReferenceNbr' => { 'value' => cc_pay['ReferenceNbr']['value'] } },
|
242
|
+
# logger: logger
|
243
|
+
# )
|
244
|
+
|
245
|
+
MyobAcumatica::Api::Payment.delete_by_keys(
|
246
|
+
access_token: access_token,
|
247
|
+
keys: [payment55['Type']['value'], payment55['ReferenceNbr']['value']],
|
248
|
+
logger: logger
|
249
|
+
)
|
250
|
+
|
251
|
+
MyobAcumatica::Api::Payment.delete_by_id(
|
252
|
+
access_token: access_token,
|
253
|
+
id: payment45['id'],
|
254
|
+
logger: logger
|
255
|
+
)
|
@@ -0,0 +1,506 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MyobAcumatica
|
4
|
+
module Api
|
5
|
+
# Provides methods to interact with the Payment API endpoints.
|
6
|
+
|
7
|
+
module Payment
|
8
|
+
module_function
|
9
|
+
|
10
|
+
# Deletes a payment by ID.
|
11
|
+
#
|
12
|
+
# @example Delete a payment by ID
|
13
|
+
# MyobAcumatica::Api::Payment.delete_by_id(
|
14
|
+
# access_token: access_token,
|
15
|
+
# id: payment['id'],
|
16
|
+
# logger: logger
|
17
|
+
# )
|
18
|
+
#
|
19
|
+
# @param access_token [String] OAuth2 access token.
|
20
|
+
# @param id [String] Unique payment ID.
|
21
|
+
# @param instance_name [String] The instance name.
|
22
|
+
# @param endpoint_name [String] The endpoint name.
|
23
|
+
# @param endpoint_version [String] The endpoint version.
|
24
|
+
# @param logger [Logger, nil] Optional logger.
|
25
|
+
# @return [nil]
|
26
|
+
def delete_by_id(access_token:, id:,
|
27
|
+
instance_name: INSTANCE_NAME,
|
28
|
+
endpoint_name: ENDPOINT_NAME,
|
29
|
+
endpoint_version: ENDPOINT_VERSION,
|
30
|
+
logger: nil)
|
31
|
+
Http.request(
|
32
|
+
instance_name: instance_name,
|
33
|
+
access_token: access_token,
|
34
|
+
method: :delete,
|
35
|
+
endpoint_name: endpoint_name,
|
36
|
+
endpoint_version: endpoint_version,
|
37
|
+
path: "Payment/#{id}",
|
38
|
+
logger: logger
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Deletes a payment by composite keys.
|
43
|
+
#
|
44
|
+
# @example Delete a payment by keys
|
45
|
+
# MyobAcumatica::Api::Payment.delete_by_keys(
|
46
|
+
# access_token: access_token,
|
47
|
+
# keys: [payment['Type']['value'], payment['ReferenceNbr']['value']],
|
48
|
+
# logger: logger
|
49
|
+
# )
|
50
|
+
#
|
51
|
+
# @param access_token [String] OAuth2 access token.
|
52
|
+
# @param keys [Array<String>] Keys uniquely identifying the payment.
|
53
|
+
# @param instance_name [String] The instance name.
|
54
|
+
# @param endpoint_name [String] The endpoint name.
|
55
|
+
# @param endpoint_version [String] The endpoint version.
|
56
|
+
# @param logger [Logger, nil] Optional logger.
|
57
|
+
# @return [nil]
|
58
|
+
def delete_by_keys(access_token:, keys:,
|
59
|
+
instance_name: INSTANCE_NAME,
|
60
|
+
endpoint_name: ENDPOINT_NAME,
|
61
|
+
endpoint_version: ENDPOINT_VERSION,
|
62
|
+
logger: nil)
|
63
|
+
Http.request(
|
64
|
+
instance_name: instance_name,
|
65
|
+
access_token: access_token,
|
66
|
+
method: :delete,
|
67
|
+
endpoint_name: endpoint_name,
|
68
|
+
endpoint_version: endpoint_version,
|
69
|
+
path: "Payment/#{keys.join('/')}",
|
70
|
+
logger: logger
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieves the ad-hoc schema for the payment endpoint.
|
75
|
+
#
|
76
|
+
# @example Retrieve ad-hoc schema
|
77
|
+
# MyobAcumatica::Api::Payment.get_ad_hoc_schema(
|
78
|
+
# access_token: access_token,
|
79
|
+
# logger: logger
|
80
|
+
# )
|
81
|
+
#
|
82
|
+
# @param access_token [String] OAuth2 access token.
|
83
|
+
# @param instance_name [String] The instance name.
|
84
|
+
# @param endpoint_name [String] The endpoint name.
|
85
|
+
# @param endpoint_version [String] The endpoint version.
|
86
|
+
# @param logger [Logger, nil] Optional logger.
|
87
|
+
# @return [Hash] Ad-hoc schema.
|
88
|
+
def get_ad_hoc_schema(access_token:,
|
89
|
+
instance_name: INSTANCE_NAME,
|
90
|
+
endpoint_name: ENDPOINT_NAME,
|
91
|
+
endpoint_version: ENDPOINT_VERSION,
|
92
|
+
logger: nil)
|
93
|
+
Http.request(
|
94
|
+
instance_name: instance_name,
|
95
|
+
access_token: access_token,
|
96
|
+
method: :get,
|
97
|
+
endpoint_name: endpoint_name,
|
98
|
+
endpoint_version: endpoint_version,
|
99
|
+
path: 'Payment/$adHocSchema',
|
100
|
+
logger: logger
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Retrieves a payment by unique ID.
|
105
|
+
#
|
106
|
+
# @example Get payment by ID
|
107
|
+
# MyobAcumatica::Api::Payment.get_by_id(
|
108
|
+
# access_token: access_token,
|
109
|
+
# id: payment['id'],
|
110
|
+
# logger: logger
|
111
|
+
# )
|
112
|
+
#
|
113
|
+
# @param access_token [String] OAuth2 access token.
|
114
|
+
# @param id [String] Unique payment ID.
|
115
|
+
# @param query_params [Hash] Optional query parameters.
|
116
|
+
# @param instance_name [String] The instance name.
|
117
|
+
# @param endpoint_name [String] The endpoint name.
|
118
|
+
# @param endpoint_version [String] The endpoint version.
|
119
|
+
# @param logger [Logger, nil] Optional logger.
|
120
|
+
# @return [Hash] The payment.
|
121
|
+
def get_by_id(access_token:, id:, query_params: {},
|
122
|
+
instance_name: INSTANCE_NAME,
|
123
|
+
endpoint_name: ENDPOINT_NAME,
|
124
|
+
endpoint_version: ENDPOINT_VERSION,
|
125
|
+
logger: nil)
|
126
|
+
Http.request(
|
127
|
+
instance_name: instance_name,
|
128
|
+
access_token: access_token,
|
129
|
+
method: :get,
|
130
|
+
endpoint_name: endpoint_name,
|
131
|
+
endpoint_version: endpoint_version,
|
132
|
+
path: "Payment/#{id}",
|
133
|
+
query_params: query_params,
|
134
|
+
logger: logger
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
138
|
+
# Retrieves a payment by composite keys.
|
139
|
+
#
|
140
|
+
# @example Get payment by keys
|
141
|
+
# MyobAcumatica::Api::Payment.get_by_keys(
|
142
|
+
# access_token: access_token,
|
143
|
+
# keys: [payment['Type']['value'], payment['ReferenceNbr']['value']],
|
144
|
+
# logger: logger
|
145
|
+
# )
|
146
|
+
#
|
147
|
+
# @param access_token [String] OAuth2 access token.
|
148
|
+
# @param keys [Array<String>] Keys uniquely identifying the payment.
|
149
|
+
# @param query_params [Hash] Optional query parameters.
|
150
|
+
# @param instance_name [String] The instance name.
|
151
|
+
# @param endpoint_name [String] The endpoint name.
|
152
|
+
# @param endpoint_version [String] The endpoint version.
|
153
|
+
# @param logger [Logger, nil] Optional logger.
|
154
|
+
# @return [Hash] The payment.
|
155
|
+
def get_by_keys(access_token:, keys:, query_params: {},
|
156
|
+
instance_name: INSTANCE_NAME,
|
157
|
+
endpoint_name: ENDPOINT_NAME,
|
158
|
+
endpoint_version: ENDPOINT_VERSION,
|
159
|
+
logger: nil)
|
160
|
+
Http.request(
|
161
|
+
instance_name: instance_name,
|
162
|
+
access_token: access_token,
|
163
|
+
method: :get,
|
164
|
+
endpoint_name: endpoint_name,
|
165
|
+
endpoint_version: endpoint_version,
|
166
|
+
path: "Payment/#{keys.join('/')}",
|
167
|
+
query_params: query_params,
|
168
|
+
logger: logger
|
169
|
+
)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Retrieves a list of payments.
|
173
|
+
#
|
174
|
+
# @example List payments of type 'Payment'
|
175
|
+
# MyobAcumatica::Api::Payment.get_list(
|
176
|
+
# access_token: access_token,
|
177
|
+
# query_params: { '$filter' => "Type eq 'Payment'" },
|
178
|
+
# logger: logger
|
179
|
+
# )
|
180
|
+
#
|
181
|
+
# @param access_token [String] OAuth2 access token.
|
182
|
+
# @param query_params [Hash] Optional query parameters.
|
183
|
+
# @param instance_name [String] The instance name.
|
184
|
+
# @param endpoint_name [String] The endpoint name.
|
185
|
+
# @param endpoint_version [String] The endpoint version.
|
186
|
+
# @param logger [Logger, nil] Optional logger.
|
187
|
+
# @return [Array<Hash>] List of payments.
|
188
|
+
def get_list(access_token:, query_params: {},
|
189
|
+
instance_name: INSTANCE_NAME,
|
190
|
+
endpoint_name: ENDPOINT_NAME,
|
191
|
+
endpoint_version: ENDPOINT_VERSION,
|
192
|
+
logger: nil)
|
193
|
+
Http.request(
|
194
|
+
instance_name: instance_name,
|
195
|
+
access_token: access_token,
|
196
|
+
method: :get,
|
197
|
+
endpoint_name: endpoint_name,
|
198
|
+
endpoint_version: endpoint_version,
|
199
|
+
path: 'Payment',
|
200
|
+
query_params: query_params,
|
201
|
+
logger: logger
|
202
|
+
)
|
203
|
+
end
|
204
|
+
|
205
|
+
# Creates or updates a payment entity.
|
206
|
+
#
|
207
|
+
# @example Create a new payment
|
208
|
+
# payment = MyobAcumatica::Api::Payment.put_entity(
|
209
|
+
# access_token: access_token,
|
210
|
+
# entity: {
|
211
|
+
# 'CustomerID' => { 'value' => 'JOHNGOODPAYER' },
|
212
|
+
# 'ApplicationDate' => { 'value' => '2025-05-6' },
|
213
|
+
# 'PaymentMethod' => { 'value' => 'CASH' },
|
214
|
+
# 'CashAccount' => { 'value' => 'CASHACCC' },
|
215
|
+
# 'Hold' => { 'value' => false }
|
216
|
+
# },
|
217
|
+
# logger: logger
|
218
|
+
# )
|
219
|
+
#
|
220
|
+
# @param access_token [String] OAuth2 access token.
|
221
|
+
# @param entity [Hash] Payment entity.
|
222
|
+
# @param query_params [Hash] Optional query parameters.
|
223
|
+
# @param instance_name [String] The instance name.
|
224
|
+
# @param endpoint_name [String] The endpoint name.
|
225
|
+
# @param endpoint_version [String] The endpoint version.
|
226
|
+
# @param logger [Logger, nil] Optional logger.
|
227
|
+
# @return [Hash] Created or updated payment.
|
228
|
+
def put_entity(access_token:, entity:, query_params: {},
|
229
|
+
instance_name: INSTANCE_NAME,
|
230
|
+
endpoint_name: ENDPOINT_NAME,
|
231
|
+
endpoint_version: ENDPOINT_VERSION,
|
232
|
+
logger: nil)
|
233
|
+
Http.request(
|
234
|
+
instance_name: instance_name,
|
235
|
+
access_token: access_token,
|
236
|
+
method: :put,
|
237
|
+
endpoint_name: endpoint_name,
|
238
|
+
endpoint_version: endpoint_version,
|
239
|
+
path: 'Payment',
|
240
|
+
body: entity,
|
241
|
+
query_params: query_params,
|
242
|
+
logger: logger
|
243
|
+
)
|
244
|
+
end
|
245
|
+
|
246
|
+
# Uploads a file to a payment record.
|
247
|
+
#
|
248
|
+
# @example Upload a PDF to a payment
|
249
|
+
# MyobAcumatica::Api::Payment.put_file(
|
250
|
+
# access_token: access_token,
|
251
|
+
# keys: [payment['Type']['value'], payment['ReferenceNbr']['value']],
|
252
|
+
# file_path: 'examples/dummy.pdf',
|
253
|
+
# logger: logger
|
254
|
+
# )
|
255
|
+
#
|
256
|
+
# @param access_token [String] OAuth2 access token.
|
257
|
+
# @param keys [Array<String>] Keys identifying the payment.
|
258
|
+
# @param file_path [String] Path to the file.
|
259
|
+
# @param instance_name [String] The instance name.
|
260
|
+
# @param endpoint_name [String] The endpoint name.
|
261
|
+
# @param endpoint_version [String] The endpoint version.
|
262
|
+
# @param logger [Logger, nil] Optional logger.
|
263
|
+
# @raise [MyobAcumatica::Error] If upload link not found.
|
264
|
+
# @return [nil]
|
265
|
+
def put_file(access_token:, keys:, file_path:,
|
266
|
+
instance_name: INSTANCE_NAME,
|
267
|
+
endpoint_name: ENDPOINT_NAME,
|
268
|
+
endpoint_version: ENDPOINT_VERSION,
|
269
|
+
logger: nil)
|
270
|
+
payment = get_by_keys(
|
271
|
+
access_token: access_token,
|
272
|
+
keys: keys,
|
273
|
+
instance_name: instance_name,
|
274
|
+
logger: logger
|
275
|
+
)
|
276
|
+
put_url_template = payment.dig('_links', 'files:put')
|
277
|
+
raise MyobAcumatica::Error, 'files:put link not found' unless put_url_template
|
278
|
+
|
279
|
+
filename = File.basename(file_path)
|
280
|
+
path = put_url_template.gsub('{filename}', filename)
|
281
|
+
Http.request(
|
282
|
+
instance_name: instance_name,
|
283
|
+
access_token: access_token,
|
284
|
+
method: :put,
|
285
|
+
endpoint_name: endpoint_name,
|
286
|
+
endpoint_version: endpoint_version,
|
287
|
+
path: path,
|
288
|
+
body: File.binread(file_path),
|
289
|
+
content_type: 'application/octet-stream',
|
290
|
+
logger: logger
|
291
|
+
)
|
292
|
+
end
|
293
|
+
|
294
|
+
# Invokes a custom action on a payment.
|
295
|
+
#
|
296
|
+
# @example Release a payment via invoke_action
|
297
|
+
# MyobAcumatica::Api::Payment.invoke_action(
|
298
|
+
# access_token: access_token,
|
299
|
+
# action_name: 'ReleasePayment',
|
300
|
+
# entity: { 'id' => payment['id'] },
|
301
|
+
# logger: logger
|
302
|
+
# )
|
303
|
+
#
|
304
|
+
# @param access_token [String] OAuth2 access token.
|
305
|
+
# @param action_name [String] Action name.
|
306
|
+
# @param entity [Hash] Payment entity.
|
307
|
+
# @param parameters [Hash] Optional parameters.
|
308
|
+
# @param instance_name [String] The instance name.
|
309
|
+
# @param endpoint_name [String] The endpoint name.
|
310
|
+
# @param endpoint_version [String] The endpoint version.
|
311
|
+
# @param logger [Logger, nil] Optional logger.
|
312
|
+
# @return [Hash, nil] Action response.
|
313
|
+
def invoke_action(access_token:, action_name:, entity:, parameters: {},
|
314
|
+
instance_name: INSTANCE_NAME,
|
315
|
+
endpoint_name: ENDPOINT_NAME,
|
316
|
+
endpoint_version: ENDPOINT_VERSION,
|
317
|
+
logger: nil)
|
318
|
+
Http.request(
|
319
|
+
instance_name: instance_name,
|
320
|
+
access_token: access_token,
|
321
|
+
method: :post,
|
322
|
+
endpoint_name: endpoint_name,
|
323
|
+
endpoint_version: endpoint_version,
|
324
|
+
path: "Payment/#{action_name}",
|
325
|
+
body: { 'entity' => entity, 'parameters' => parameters },
|
326
|
+
logger: logger
|
327
|
+
)
|
328
|
+
end
|
329
|
+
|
330
|
+
# Captures a credit card payment.
|
331
|
+
#
|
332
|
+
# @example Capture an authorised credit card payment
|
333
|
+
# MyobAcumatica::Api::Payment.capture_credit_card_payment(
|
334
|
+
# access_token: access_token,
|
335
|
+
# entity: { 'ReferenceNbr' => { 'value' => payment['ReferenceNbr']['value'] } },
|
336
|
+
# parameters: { 'Amount' => { 'value' => 60.0 } },
|
337
|
+
# logger: logger
|
338
|
+
# )
|
339
|
+
#
|
340
|
+
# @param access_token [String] OAuth2 access token.
|
341
|
+
# @param entity [Hash] Payment entity.
|
342
|
+
# @param parameters [Hash] Optional parameters.
|
343
|
+
# @param instance_name [String] The instance name.
|
344
|
+
# @param endpoint_name [String] The endpoint name.
|
345
|
+
# @param endpoint_version [String] The endpoint version.
|
346
|
+
# @param logger [Logger, nil] Optional logger.
|
347
|
+
# @return [Hash] Response from the capture action.
|
348
|
+
def capture_credit_card_payment(access_token:, entity:, parameters: {},
|
349
|
+
instance_name: INSTANCE_NAME,
|
350
|
+
endpoint_name: ENDPOINT_NAME,
|
351
|
+
endpoint_version: ENDPOINT_VERSION,
|
352
|
+
logger: nil)
|
353
|
+
Http.request(
|
354
|
+
instance_name: instance_name,
|
355
|
+
access_token: access_token,
|
356
|
+
method: :post,
|
357
|
+
endpoint_name: endpoint_name,
|
358
|
+
endpoint_version: endpoint_version,
|
359
|
+
path: 'Payment/CaptureCreditCardPayment',
|
360
|
+
body: { 'entity' => entity, 'parameters' => parameters },
|
361
|
+
logger: logger
|
362
|
+
)
|
363
|
+
end
|
364
|
+
|
365
|
+
# Performs a card operation such as Authorize or Capture.
|
366
|
+
#
|
367
|
+
# @example Authorise a card payment
|
368
|
+
# MyobAcumatica::Api::Payment.card_operation(
|
369
|
+
# access_token: access_token,
|
370
|
+
# entity: { 'ReferenceNbr' => { 'value' => payment['ReferenceNbr']['value'] } },
|
371
|
+
# parameters: {
|
372
|
+
# 'Operation' => { 'value' => 'Authorize' },
|
373
|
+
# 'Amount' => { 'value' => 60.0 }
|
374
|
+
# },
|
375
|
+
# logger: logger
|
376
|
+
# )
|
377
|
+
#
|
378
|
+
# @param access_token [String] OAuth2 access token.
|
379
|
+
# @param entity [Hash] Payment entity.
|
380
|
+
# @param parameters [Hash] Operation parameters.
|
381
|
+
# @param instance_name [String] The instance name.
|
382
|
+
# @param endpoint_name [String] The endpoint name.
|
383
|
+
# @param endpoint_version [String] The endpoint version.
|
384
|
+
# @param logger [Logger, nil] Optional logger.
|
385
|
+
# @return [Hash] Response from the card operation.
|
386
|
+
def card_operation(access_token:, entity:, parameters: {},
|
387
|
+
instance_name: INSTANCE_NAME,
|
388
|
+
endpoint_name: ENDPOINT_NAME,
|
389
|
+
endpoint_version: ENDPOINT_VERSION,
|
390
|
+
logger: nil)
|
391
|
+
Http.request(
|
392
|
+
instance_name: instance_name,
|
393
|
+
access_token: access_token,
|
394
|
+
method: :post,
|
395
|
+
endpoint_name: endpoint_name,
|
396
|
+
endpoint_version: endpoint_version,
|
397
|
+
path: 'Payment/CardOperation',
|
398
|
+
body: { 'entity' => entity, 'parameters' => parameters },
|
399
|
+
logger: logger
|
400
|
+
)
|
401
|
+
end
|
402
|
+
|
403
|
+
# Releases a payment.
|
404
|
+
#
|
405
|
+
# @example Release a payment
|
406
|
+
# MyobAcumatica::Api::Payment.release_payment(
|
407
|
+
# access_token: access_token,
|
408
|
+
# entity: { 'id' => payment['id'] },
|
409
|
+
# logger: logger
|
410
|
+
# )
|
411
|
+
#
|
412
|
+
# @param access_token [String] OAuth2 access token.
|
413
|
+
# @param entity [Hash] Payment entity.
|
414
|
+
# @param parameters [Hash] Optional parameters.
|
415
|
+
# @param instance_name [String] The instance name.
|
416
|
+
# @param endpoint_name [String] The endpoint name.
|
417
|
+
# @param endpoint_version [String] The endpoint version.
|
418
|
+
# @param logger [Logger, nil] Optional logger.
|
419
|
+
# @return [Hash] Response from the release action.
|
420
|
+
def release_payment(access_token:, entity:, parameters: {},
|
421
|
+
instance_name: INSTANCE_NAME,
|
422
|
+
endpoint_name: ENDPOINT_NAME,
|
423
|
+
endpoint_version: ENDPOINT_VERSION,
|
424
|
+
logger: nil)
|
425
|
+
Http.request(
|
426
|
+
instance_name: instance_name,
|
427
|
+
access_token: access_token,
|
428
|
+
method: :post,
|
429
|
+
endpoint_name: endpoint_name,
|
430
|
+
endpoint_version: endpoint_version,
|
431
|
+
path: 'Payment/ReleasePayment',
|
432
|
+
body: { 'entity' => entity, 'parameters' => parameters },
|
433
|
+
logger: logger
|
434
|
+
)
|
435
|
+
end
|
436
|
+
|
437
|
+
# Voids a card payment.
|
438
|
+
#
|
439
|
+
# @example Void a credit card payment
|
440
|
+
# MyobAcumatica::Api::Payment.void_card_payment(
|
441
|
+
# access_token: access_token,
|
442
|
+
# entity: { 'ReferenceNbr' => { 'value' => payment['ReferenceNbr']['value'] } },
|
443
|
+
# logger: logger
|
444
|
+
# )
|
445
|
+
#
|
446
|
+
# @param access_token [String] OAuth2 access token.
|
447
|
+
# @param entity [Hash] Payment entity.
|
448
|
+
# @param parameters [Hash] Optional parameters.
|
449
|
+
# @param instance_name [String] The instance name.
|
450
|
+
# @param endpoint_name [String] The endpoint name.
|
451
|
+
# @param endpoint_version [String] The endpoint version.
|
452
|
+
# @param logger [Logger, nil] Optional logger.
|
453
|
+
# @return [Hash] Response from the void card payment action.
|
454
|
+
def void_card_payment(access_token:, entity:, parameters: {},
|
455
|
+
instance_name: INSTANCE_NAME,
|
456
|
+
endpoint_name: ENDPOINT_NAME,
|
457
|
+
endpoint_version: ENDPOINT_VERSION,
|
458
|
+
logger: nil)
|
459
|
+
Http.request(
|
460
|
+
instance_name: instance_name,
|
461
|
+
access_token: access_token,
|
462
|
+
method: :post,
|
463
|
+
endpoint_name: endpoint_name,
|
464
|
+
endpoint_version: endpoint_version,
|
465
|
+
path: 'Payment/VoidCardPayment',
|
466
|
+
body: { 'entity' => entity, 'parameters' => parameters },
|
467
|
+
logger: logger
|
468
|
+
)
|
469
|
+
end
|
470
|
+
|
471
|
+
# Voids a payment.
|
472
|
+
#
|
473
|
+
# @example Void a payment
|
474
|
+
# MyobAcumatica::Api::Payment.void_payment(
|
475
|
+
# access_token: access_token,
|
476
|
+
# entity: { 'ReferenceNbr' => { 'value' => payment['ReferenceNbr']['value'] } },
|
477
|
+
# logger: logger
|
478
|
+
# )
|
479
|
+
#
|
480
|
+
# @param access_token [String] OAuth2 access token.
|
481
|
+
# @param entity [Hash] Payment entity.
|
482
|
+
# @param parameters [Hash] Optional parameters.
|
483
|
+
# @param instance_name [String] The instance name.
|
484
|
+
# @param endpoint_name [String] The endpoint name.
|
485
|
+
# @param endpoint_version [String] The endpoint version.
|
486
|
+
# @param logger [Logger, nil] Optional logger.
|
487
|
+
# @return [Hash] Response from the void payment action.
|
488
|
+
def void_payment(access_token:, entity:, parameters: {},
|
489
|
+
instance_name: INSTANCE_NAME,
|
490
|
+
endpoint_name: ENDPOINT_NAME,
|
491
|
+
endpoint_version: ENDPOINT_VERSION,
|
492
|
+
logger: nil)
|
493
|
+
Http.request(
|
494
|
+
instance_name: instance_name,
|
495
|
+
access_token: access_token,
|
496
|
+
method: :post,
|
497
|
+
endpoint_name: endpoint_name,
|
498
|
+
endpoint_version: endpoint_version,
|
499
|
+
path: 'Payment/VoidPayment',
|
500
|
+
body: { 'entity' => entity, 'parameters' => parameters },
|
501
|
+
logger: logger
|
502
|
+
)
|
503
|
+
end
|
504
|
+
end
|
505
|
+
end
|
506
|
+
end
|
data/lib/myob_acumatica.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myob_acumatica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Mikulasev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -156,11 +156,13 @@ files:
|
|
156
156
|
- examples/customer.rb
|
157
157
|
- examples/dummy.pdf
|
158
158
|
- examples/invoice.rb
|
159
|
+
- examples/payment.rb
|
159
160
|
- lib/myob_acumatica.rb
|
160
161
|
- lib/myob_acumatica/api.rb
|
161
162
|
- lib/myob_acumatica/api/customer.rb
|
162
163
|
- lib/myob_acumatica/api/http.rb
|
163
164
|
- lib/myob_acumatica/api/invoice.rb
|
165
|
+
- lib/myob_acumatica/api/payment.rb
|
164
166
|
- lib/myob_acumatica/o_auth_2/http.rb
|
165
167
|
- lib/myob_acumatica/o_auth_2/token.rb
|
166
168
|
- lib/myob_acumatica/version.rb
|
@@ -172,6 +174,7 @@ metadata:
|
|
172
174
|
source_code_uri: https://github.com/fast-programmer/myob_acumatica
|
173
175
|
changelog_uri: https://github.com/fast-programmer/myob_acumatica/blob/master/CHANGELOG.md
|
174
176
|
homepage_uri: https://github.com/fast-programmer/myob_acumatica
|
177
|
+
documentation_uri: https://www.rubydoc.info/gems/myob_acumatica
|
175
178
|
post_install_message:
|
176
179
|
rdoc_options: []
|
177
180
|
require_paths:
|