myob_acumatica 0.1.0 → 0.1.1
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/.rubocop.yml +27 -0
- data/Gemfile.lock +2 -0
- data/README.md +189 -52
- data/examples/app.rb +114 -19
- data/examples/customer.rb +128 -0
- data/examples/dummy.pdf +0 -0
- data/examples/invoice.rb +121 -0
- data/lib/myob_acumatica/api/customer.rb +322 -0
- data/lib/myob_acumatica/api/http.rb +49 -0
- data/lib/myob_acumatica/api/invoice.rb +354 -0
- data/lib/myob_acumatica/api.rb +6 -0
- data/lib/myob_acumatica/o_auth_2/http.rb +26 -0
- data/lib/myob_acumatica/o_auth_2/token.rb +119 -0
- data/lib/myob_acumatica/version.rb +1 -1
- data/lib/myob_acumatica.rb +19 -4
- metadata +28 -7
- data/lib/myob_acumatica/customer.rb +0 -26
- data/lib/myob_acumatica/o_auth_2.rb +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe0aaf6f6fb4c58fb8b2937eb1118a1e7a322f9251b31dd326f91fb657375672
|
4
|
+
data.tar.gz: 658c2271049b09bf913158597a5d16f6d87f7fdf42d947374cd5dd6d25363c2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdccc61e8625a5d52f86e21bc80b07989b54b582e619c3b562418fe5ce5e5e5a26977c6d94e8570178d2a19be3d76e087a0eac9fb667d554b0ba90a8ee911288
|
7
|
+
data.tar.gz: 4c256621b6d1628508c0568366a1cb05cbee01fdb006c1b4ac122067fa9d66d43698628ee8e1a4e104fcf0569e6f408dc5265d535c9f088201f1fb1edfbd6115
|
data/.rubocop.yml
CHANGED
@@ -24,3 +24,30 @@ Layout/FirstHashElementIndentation:
|
|
24
24
|
|
25
25
|
Layout/HashAlignment:
|
26
26
|
EnforcedStyle: key
|
27
|
+
|
28
|
+
Style/NegatedIf:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/IfUnlessModifier:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Metrics/ModuleLength:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Metrics/AbcSize:
|
38
|
+
Max: 30
|
39
|
+
|
40
|
+
Metrics/AbcSize:
|
41
|
+
Max: 50
|
42
|
+
|
43
|
+
Metrics/CyclomaticComplexity:
|
44
|
+
Max: 50
|
45
|
+
|
46
|
+
Metrics/PerceivedComplexity:
|
47
|
+
Max: 50
|
48
|
+
|
49
|
+
Metrics/ClassLength:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
Metrics/BlockLength:
|
53
|
+
Enabled: false
|
data/Gemfile.lock
CHANGED
@@ -89,6 +89,7 @@ GEM
|
|
89
89
|
unicode-display_width (3.1.4)
|
90
90
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
91
91
|
unicode-emoji (4.0.4)
|
92
|
+
yard (0.9.37)
|
92
93
|
|
93
94
|
PLATFORMS
|
94
95
|
arm64-darwin-24
|
@@ -105,6 +106,7 @@ DEPENDENCIES
|
|
105
106
|
rspec (~> 3.0)
|
106
107
|
rubocop (~> 1.21)
|
107
108
|
sinatra (~> 4.1)
|
109
|
+
yard (~> 0.9)
|
108
110
|
|
109
111
|
BUNDLED WITH
|
110
112
|
2.3.27
|
data/README.md
CHANGED
@@ -1,100 +1,237 @@
|
|
1
|
-
#
|
1
|
+
# Ruby library for the MYOB Acumatica API
|
2
2
|
|
3
|
-
|
3
|
+
A lightweight Ruby client for accessing the MYOB Acumatica REST API via OAuth2.
|
4
|
+
|
5
|
+
---
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Using Bundler:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
bundle add myob_acumatica
|
13
|
+
```
|
14
|
+
|
15
|
+
Without Bundler:
|
8
16
|
|
9
|
-
|
17
|
+
```bash
|
18
|
+
gem install myob_acumatica
|
19
|
+
```
|
20
|
+
|
21
|
+
---
|
10
22
|
|
11
|
-
|
23
|
+
## Setup
|
12
24
|
|
13
|
-
|
25
|
+
Set the following environment variables in your host application:
|
14
26
|
|
15
|
-
|
27
|
+
```bash
|
28
|
+
MYOB_ACUMATICA_INSTANCE_NAME=your-instance.myob.com
|
29
|
+
MYOB_ACUMATICA_CLIENT_ID=your-client-id
|
30
|
+
MYOB_ACUMATICA_CLIENT_SECRET=your-client-secret
|
31
|
+
MYOB_ACUMATICA_REDIRECT_URI=http://localhost:4567/oauth2/callback
|
32
|
+
MYOB_ACUMATICA_SCOPE=api offline_access
|
33
|
+
MYOB_ACUMATICA_ENDPOINT_NAME=Default
|
34
|
+
MYOB_ACUMATICA_ENDPOINT_VERSION=22.200.001
|
35
|
+
```
|
16
36
|
|
17
|
-
|
37
|
+
---
|
18
38
|
|
19
|
-
|
39
|
+
## OAuth2 Flow
|
20
40
|
|
21
|
-
|
41
|
+
Get the authorization URL to initiate login:
|
22
42
|
|
23
43
|
```ruby
|
24
|
-
MyobAcumatica::OAuth2.authorize_url
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
44
|
+
MyobAcumatica::OAuth2::Token.authorize_url
|
45
|
+
```
|
46
|
+
|
47
|
+
Exchange the code for an access token and a refresh token
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
token = MyobAcumatica::OAuth2::Token.authorize(code: params[:code])
|
51
|
+
```
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
{
|
55
|
+
"access_token" => "...",
|
56
|
+
"expires_in" => 3600,
|
57
|
+
"token_type" => "Bearer",
|
58
|
+
"refresh_token" => "...",
|
59
|
+
"scope" => "api offline_access"
|
60
|
+
}
|
61
|
+
```
|
30
62
|
|
31
|
-
|
63
|
+
Refresh the access token when expired:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
token = MyobAcumatica::OAuth2::Token.refresh(refresh_token: token["refresh_token"])
|
32
67
|
```
|
33
68
|
|
34
|
-
|
69
|
+
---
|
70
|
+
|
71
|
+
## Customer Examples
|
72
|
+
|
73
|
+
Create or update a customer:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
MyobAcumatica::Api::Customer.put_entity(
|
77
|
+
access_token: token["access_token"],
|
78
|
+
entity: {
|
79
|
+
'CustomerID' => { 'value' => 'JOHNGOOD' },
|
80
|
+
'CustomerName' => { 'value' => 'John Good' },
|
81
|
+
'CustomerClass' => { 'value' => 'CUSTDFT' }
|
82
|
+
}
|
83
|
+
)
|
84
|
+
```
|
35
85
|
|
36
|
-
|
86
|
+
List customers:
|
37
87
|
|
38
|
-
|
88
|
+
```ruby
|
89
|
+
MyobAcumatica::Api::Customer.get_list(
|
90
|
+
access_token: token["access_token"],
|
91
|
+
query_params: { '$filter' => "Status eq 'Active'" }
|
92
|
+
)
|
93
|
+
```
|
39
94
|
|
40
|
-
|
95
|
+
Get customer by keys:
|
41
96
|
|
42
97
|
```ruby
|
43
|
-
MyobAcumatica::
|
44
|
-
|
45
|
-
|
46
|
-
client_secret: ...,
|
47
|
-
code: params['code'],
|
48
|
-
redirect_uri: ...,
|
98
|
+
MyobAcumatica::Api::Customer.get_by_keys(
|
99
|
+
access_token: token["access_token"],
|
100
|
+
keys: ['JOHNGOOD']
|
49
101
|
)
|
102
|
+
```
|
50
103
|
|
51
|
-
|
104
|
+
Delete a customer:
|
105
|
+
|
106
|
+
```ruby
|
107
|
+
MyobAcumatica::Api::Customer.delete_by_keys(
|
108
|
+
access_token: token["access_token"],
|
109
|
+
keys: ['JOHNGOOD']
|
110
|
+
)
|
52
111
|
```
|
53
112
|
|
113
|
+
---
|
114
|
+
|
115
|
+
## Invoice Examples
|
54
116
|
|
55
|
-
|
117
|
+
Create an invoice:
|
56
118
|
|
57
|
-
|
119
|
+
```ruby
|
120
|
+
MyobAcumatica::Api::Invoice.put_entity(
|
121
|
+
access_token: token["access_token"],
|
122
|
+
entity: {
|
123
|
+
'CustomerID' => { 'value' => 'JOHNGOOD' },
|
124
|
+
'Date' => { 'value' => '2025-06-06' },
|
125
|
+
'Details' => [
|
126
|
+
{
|
127
|
+
'InventoryID' => { 'value' => 'CONSULTING' },
|
128
|
+
'Quantity' => { 'value' => 2 },
|
129
|
+
'UnitPrice' => { 'value' => 150.0 }
|
130
|
+
}
|
131
|
+
]
|
132
|
+
}
|
133
|
+
)
|
134
|
+
```
|
135
|
+
|
136
|
+
List invoices:
|
58
137
|
|
59
138
|
```ruby
|
60
|
-
MyobAcumatica::
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
139
|
+
MyobAcumatica::Api::Invoice.get_list(
|
140
|
+
access_token: token["access_token"],
|
141
|
+
query_params: {
|
142
|
+
'$filter' => "Status eq 'Open'",
|
143
|
+
'$top' => 10,
|
144
|
+
'$select' => 'InvoiceNbr,CustomerID,Status,Date'
|
145
|
+
}
|
66
146
|
)
|
147
|
+
```
|
148
|
+
|
149
|
+
Get invoice by ID:
|
67
150
|
|
68
|
-
|
151
|
+
```ruby
|
152
|
+
MyobAcumatica::Api::Invoice.get_by_id(
|
153
|
+
access_token: token["access_token"],
|
154
|
+
id: '00000000-0000-0000-0000-000000000000'
|
155
|
+
)
|
69
156
|
```
|
70
157
|
|
71
|
-
|
158
|
+
Delete an invoice:
|
72
159
|
|
73
160
|
```ruby
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
endpoint_version: ...,
|
78
|
-
access_token: token['access_token'],
|
79
|
-
query_params: { filter: 'IsActive eq true' },
|
80
|
-
logger: Logger.new($stdout)
|
161
|
+
MyobAcumatica::Api::Invoice.delete_by_id(
|
162
|
+
access_token: token["access_token"],
|
163
|
+
id: '00000000-0000-0000-0000-000000000000'
|
81
164
|
)
|
82
165
|
```
|
83
166
|
|
167
|
+
---
|
168
|
+
|
169
|
+
## Documentation
|
170
|
+
|
171
|
+
See full API reference and usage examples: [rubydoc.info/gems/myob_acumatica](https://www.rubydoc.info/gems/myob_acumatica)
|
172
|
+
|
173
|
+
---
|
174
|
+
|
84
175
|
## Development
|
85
176
|
|
86
|
-
|
177
|
+
### 1. Clone the repo
|
178
|
+
|
179
|
+
```bash
|
180
|
+
git clone https://github.com/fast-programmer/myob_acumatica.git
|
181
|
+
cd myob_acumatica
|
182
|
+
bundle install
|
183
|
+
```
|
184
|
+
|
185
|
+
### 2. Create a `.env` file
|
186
|
+
|
187
|
+
```env
|
188
|
+
MYOB_ACUMATICA_INSTANCE_NAME=your-instance.myob.com
|
189
|
+
MYOB_ACUMATICA_CLIENT_ID=your-client-id
|
190
|
+
MYOB_ACUMATICA_CLIENT_SECRET=your-client-secret
|
191
|
+
MYOB_ACUMATICA_REDIRECT_URI=http://localhost:4567/oauth2/callback
|
192
|
+
MYOB_ACUMATICA_SCOPE=api offline_access
|
193
|
+
MYOB_ACUMATICA_ENDPOINT_NAME=Default
|
194
|
+
MYOB_ACUMATICA_ENDPOINT_VERSION=22.200.001
|
195
|
+
```
|
196
|
+
|
197
|
+
### 3. Run the Sinatra example app
|
198
|
+
|
199
|
+
This test app helps acquire an OAuth token and inspect customer data.
|
200
|
+
|
201
|
+
```bash
|
202
|
+
bundle exec ruby examples/app.rb
|
203
|
+
```
|
204
|
+
|
205
|
+
Visit in your browser:
|
206
|
+
|
207
|
+
- http://localhost:4567/oauth2/authorize — start login
|
208
|
+
- http://localhost:4567/oauth2/callback — receive tokens and fetch customer list
|
209
|
+
|
210
|
+
### 4. Open an interactive shell
|
87
211
|
|
88
|
-
|
212
|
+
```bash
|
213
|
+
bin/console
|
214
|
+
```
|
215
|
+
|
216
|
+
Try this command with your token:
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
MyobAcumatica::Api::Customer.get_list(access_token: token["access_token"])
|
220
|
+
```
|
221
|
+
|
222
|
+
---
|
89
223
|
|
90
224
|
## Contributing
|
91
225
|
|
92
|
-
Bug reports and pull requests are welcome
|
226
|
+
Bug reports and pull requests are welcome at:
|
227
|
+
https://github.com/fast-programmer/myob_acumatica
|
93
228
|
|
94
|
-
|
229
|
+
Please follow the code of conduct:
|
230
|
+
https://github.com/fast-programmer/myob_acumatica/blob/master/CODE_OF_CONDUCT.md
|
95
231
|
|
96
|
-
|
232
|
+
---
|
97
233
|
|
98
|
-
##
|
234
|
+
## License
|
99
235
|
|
100
|
-
|
236
|
+
MIT — see the LICENSE
|
237
|
+
https://opensource.org/licenses/MIT
|
data/examples/app.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'myob_acumatica'
|
4
|
-
|
5
3
|
require 'sinatra/base'
|
6
4
|
require 'dotenv'
|
7
5
|
|
6
|
+
require 'myob_acumatica'
|
7
|
+
|
8
8
|
Dotenv.load
|
9
9
|
|
10
10
|
module MyobAcumaticIntegration
|
@@ -16,32 +16,31 @@ module MyobAcumaticIntegration
|
|
16
16
|
end
|
17
17
|
|
18
18
|
get '/oauth2/authorize' do
|
19
|
-
authorize_url = MyobAcumatica::OAuth2.authorize_url(
|
20
|
-
|
21
|
-
client_id: ENV['
|
22
|
-
redirect_uri: ENV['
|
23
|
-
scope: ENV['
|
19
|
+
authorize_url = MyobAcumatica::OAuth2::Token.authorize_url(
|
20
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
21
|
+
client_id: ENV['MYOB_ACUMATICA_CLIENT_ID'],
|
22
|
+
redirect_uri: ENV['MYOB_ACUMATICA_REDIRECT_URI'],
|
23
|
+
scope: ENV['MYOB_ACUMATICA_SCOPE']
|
24
24
|
)
|
25
25
|
|
26
26
|
redirect authorize_url
|
27
27
|
end
|
28
28
|
|
29
29
|
get '/oauth2/callback' do
|
30
|
-
response = MyobAcumatica::OAuth2.
|
31
|
-
|
32
|
-
client_id: ENV['
|
33
|
-
client_secret: ENV['
|
30
|
+
response = MyobAcumatica::OAuth2::Token.authorize(
|
31
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
32
|
+
client_id: ENV['MYOB_ACUMATICA_CLIENT_ID'],
|
33
|
+
client_secret: ENV['MYOB_ACUMATICA_CLIENT_SECRET'],
|
34
34
|
code: params[:code],
|
35
|
-
redirect_uri: ENV['
|
35
|
+
redirect_uri: ENV['MYOB_ACUMATICA_REDIRECT_URI'],
|
36
36
|
logger: logger
|
37
37
|
)
|
38
38
|
|
39
|
-
customers = MyobAcumatica::Customer.
|
40
|
-
|
41
|
-
endpoint_name: ENV['ENDPOINT_NAME'],
|
42
|
-
endpoint_version: ENV['ENDPOINT_VERSION'],
|
39
|
+
customers = MyobAcumatica::Api::Customer.get_list(
|
40
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
43
41
|
access_token: response['access_token'],
|
44
|
-
|
42
|
+
endpoint_name: ENV['MYOB_ACUMATICA_ENDPOINT_NAME'],
|
43
|
+
endpoint_version: ENV['MYOB_ACUMATICA_ENDPOINT_VERSION'],
|
45
44
|
logger: Logger.new($stdout)
|
46
45
|
)
|
47
46
|
|
@@ -54,8 +53,8 @@ module MyobAcumaticIntegration
|
|
54
53
|
end
|
55
54
|
|
56
55
|
get '/oauth2/refresh' do
|
57
|
-
response = MyobAcumatica::OAuth2.
|
58
|
-
|
56
|
+
response = MyobAcumatica::OAuth2::Token.refresh(
|
57
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
59
58
|
client_id: ENV['CLIENT_ID'],
|
60
59
|
client_secret: ENV['CLIENT_SECRET'],
|
61
60
|
refresh_token: params[:refresh_token],
|
@@ -70,6 +69,102 @@ module MyobAcumaticIntegration
|
|
70
69
|
}.to_json
|
71
70
|
end
|
72
71
|
|
72
|
+
# get '/customers' do
|
73
|
+
# timestamp = (Time.now - 1 * 3600).utc.strftime('%Y-%m-%dT%H:%M:%S.%L+00:00')
|
74
|
+
# filter = "Status eq 'Active' and LastModifiedDateTime gt datetimeoffset'#{timestamp}'"
|
75
|
+
|
76
|
+
# customers = MyobAcumatica::Api::Customer.get_list(
|
77
|
+
# instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
78
|
+
# access_token: params['access_token'],
|
79
|
+
# query_params: {
|
80
|
+
# '$select' => 'CustomerID, CustomerName, LastModifiedDateTime',
|
81
|
+
# '$filter' => filter,
|
82
|
+
# '$expand' => 'Contacts',
|
83
|
+
# '$skip' => 0,
|
84
|
+
# '$top' => 2
|
85
|
+
# },
|
86
|
+
# endpoint_name: ENV['MYOB_ACUMATICA_ENDPOINT_NAME'],
|
87
|
+
# endpoint_version: ENV['MYOB_ACUMATICA_ENDPOINT_VERSION'],
|
88
|
+
# logger: Logger.new($stdout)
|
89
|
+
# )
|
90
|
+
|
91
|
+
# content_type :json
|
92
|
+
|
93
|
+
# {
|
94
|
+
# customers: customers
|
95
|
+
# }.to_json
|
96
|
+
# end
|
97
|
+
|
98
|
+
get '/customers' do
|
99
|
+
page_size = 1
|
100
|
+
skip = 0
|
101
|
+
|
102
|
+
customer_enum = Enumerator.new do |yielder|
|
103
|
+
customers = MyobAcumatica::Api::Customer.get_list(
|
104
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
105
|
+
access_token: params['access_token'],
|
106
|
+
query_params: {
|
107
|
+
'$top' => page_size,
|
108
|
+
'$skip' => skip
|
109
|
+
}
|
110
|
+
)
|
111
|
+
|
112
|
+
while customers.size == page_size
|
113
|
+
yielder << customers
|
114
|
+
skip += page_size
|
115
|
+
|
116
|
+
customers = MyobAcumatica::Api::Customer.get_list(
|
117
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
118
|
+
access_token: params['access_token'],
|
119
|
+
query_params: {
|
120
|
+
'$top' => page_size,
|
121
|
+
'$skip' => skip
|
122
|
+
}
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
yielder << customers if customers.any?
|
127
|
+
end
|
128
|
+
|
129
|
+
customers = customer_enum.flat_map(&:itself)
|
130
|
+
|
131
|
+
content_type :json
|
132
|
+
|
133
|
+
{ customers: customers }.to_json
|
134
|
+
end
|
135
|
+
|
136
|
+
get '/sales_invoices' do
|
137
|
+
sales_invoices = MyobAcumatica::Api::SalesInvoice.get_list(
|
138
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
139
|
+
access_token: params['access_token'],
|
140
|
+
endpoint_name: ENV['MYOB_ACUMATICA_ENDPOINT_NAME'],
|
141
|
+
endpoint_version: ENV['MYOB_ACUMATICA_ENDPOINT_VERSION'],
|
142
|
+
logger: Logger.new($stdout)
|
143
|
+
)
|
144
|
+
|
145
|
+
content_type :json
|
146
|
+
|
147
|
+
{
|
148
|
+
sales_invoices: sales_invoices
|
149
|
+
}.to_json
|
150
|
+
end
|
151
|
+
|
152
|
+
get '/invoices' do
|
153
|
+
invoices = MyobAcumatica::Api::Invoice.get_list(
|
154
|
+
instance_name: ENV['MYOB_ACUMATICA_INSTANCE_NAME'],
|
155
|
+
access_token: params['access_token'],
|
156
|
+
endpoint_name: ENV['MYOB_ACUMATICA_ENDPOINT_NAME'],
|
157
|
+
endpoint_version: ENV['MYOB_ACUMATICA_ENDPOINT_VERSION'],
|
158
|
+
logger: Logger.new($stdout)
|
159
|
+
)
|
160
|
+
|
161
|
+
content_type :json
|
162
|
+
|
163
|
+
{
|
164
|
+
invoices: invoices
|
165
|
+
}.to_json
|
166
|
+
end
|
167
|
+
|
73
168
|
run! if app_file == $PROGRAM_NAME
|
74
169
|
end
|
75
170
|
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'logger'
|
5
|
+
require 'byebug'
|
6
|
+
require 'dotenv/load'
|
7
|
+
require 'cgi'
|
8
|
+
|
9
|
+
require 'myob_acumatica'
|
10
|
+
|
11
|
+
access_token = ENV['MYOB_ACUMATICA_ACCESS_TOKEN']
|
12
|
+
logger = Logger.new($stdout)
|
13
|
+
|
14
|
+
MyobAcumatica::Api::Customer.get_ad_hoc_schema(
|
15
|
+
access_token: access_token,
|
16
|
+
logger: logger
|
17
|
+
)
|
18
|
+
|
19
|
+
customer1 = MyobAcumatica::Api::Customer.put_entity(
|
20
|
+
access_token: access_token,
|
21
|
+
entity: {
|
22
|
+
'CustomerID' => { 'value' => 'JOHNGOOD' },
|
23
|
+
'CustomerName' => { 'value' => 'John Good' },
|
24
|
+
'CustomerClass' => { 'value' => 'CUSTDFT' },
|
25
|
+
'MainContact' => {
|
26
|
+
'Email' => { 'value' => 'demo@gmail.com' },
|
27
|
+
'Address' => {
|
28
|
+
'AddressLine1' => { 'value' => '4030 Lake Washington Blvd NE' },
|
29
|
+
'AddressLine2' => { 'value' => 'Suite 100' },
|
30
|
+
'City' => { 'value' => 'Kirkland' },
|
31
|
+
'State' => { 'value' => 'WA' },
|
32
|
+
'PostalCode' => { 'value' => '98033' },
|
33
|
+
'Country' => { 'value' => 'US' }
|
34
|
+
}
|
35
|
+
}
|
36
|
+
},
|
37
|
+
logger: logger
|
38
|
+
)
|
39
|
+
|
40
|
+
customer1 = MyobAcumatica::Api::Customer.put_entity(
|
41
|
+
access_token: access_token,
|
42
|
+
entity: {
|
43
|
+
'CustomerID' => { 'value' => customer1['CustomerID']['value'] },
|
44
|
+
'CustomerName' => { 'value' => 'John Good Updated' }
|
45
|
+
},
|
46
|
+
logger: logger
|
47
|
+
)
|
48
|
+
|
49
|
+
customer1 = MyobAcumatica::Api::Customer.get_by_keys(
|
50
|
+
access_token: access_token,
|
51
|
+
keys: [customer1['CustomerID']['value']],
|
52
|
+
logger: logger
|
53
|
+
)
|
54
|
+
|
55
|
+
# MyobAcumatica::Api::Customer.invoke_action(
|
56
|
+
# access_token: access_token,
|
57
|
+
# action_name: 'CreateContactFromCustomer',
|
58
|
+
# entity: {
|
59
|
+
# 'CustomerID' => { 'value' => 'JOHNGOOD' }
|
60
|
+
# },
|
61
|
+
# parameters: {
|
62
|
+
# 'FirstName' => { 'value' => 'John' },
|
63
|
+
# 'LastName' => { 'value' => 'Smith' },
|
64
|
+
# 'JobTitle' => { 'value' => 'Director' },
|
65
|
+
# 'Email' => { 'value' => 'john.smith@example.com' },
|
66
|
+
# 'ContactClass' => { 'value' => 'DEFAULT' }
|
67
|
+
# },
|
68
|
+
# logger: logger
|
69
|
+
# )
|
70
|
+
|
71
|
+
MyobAcumatica::Api::Customer.put_file(
|
72
|
+
access_token: access_token,
|
73
|
+
keys: [customer1['CustomerID']['value']],
|
74
|
+
file_path: 'examples/dummy.pdf',
|
75
|
+
logger: logger
|
76
|
+
)
|
77
|
+
|
78
|
+
MyobAcumatica::Api::Customer.get_by_id(
|
79
|
+
access_token: access_token,
|
80
|
+
id: customer1['id'],
|
81
|
+
logger: logger
|
82
|
+
)
|
83
|
+
|
84
|
+
MyobAcumatica::Api::Customer.get_list(
|
85
|
+
access_token: access_token,
|
86
|
+
query_params: {
|
87
|
+
'$select' => 'CustomerID, CustomerName, LastModifiedDateTime',
|
88
|
+
'$filter' => "Status eq 'Active' and "\
|
89
|
+
"LastModifiedDateTime gt datetimeoffset'2020-08-18T23:59:59.999+04:00'",
|
90
|
+
'$expand' => 'Contacts',
|
91
|
+
'$skip' => 2,
|
92
|
+
'$top' => 3
|
93
|
+
},
|
94
|
+
logger: logger
|
95
|
+
)
|
96
|
+
|
97
|
+
MyobAcumatica::Api::Customer.delete_by_id(
|
98
|
+
access_token: access_token,
|
99
|
+
id: customer1['id'],
|
100
|
+
logger: logger
|
101
|
+
)
|
102
|
+
|
103
|
+
customer2 = MyobAcumatica::Api::Customer.put_entity(
|
104
|
+
access_token: access_token,
|
105
|
+
entity: {
|
106
|
+
'CustomerID' => { 'value' => 'STEVEYELLOW' },
|
107
|
+
'CustomerName' => { 'value' => 'Steve Yellow' },
|
108
|
+
'CustomerClass' => { 'value' => 'CUSTDFT' },
|
109
|
+
'MainContact' => {
|
110
|
+
'Email' => { 'value' => 'demo@gmail.com' },
|
111
|
+
'Address' => {
|
112
|
+
'AddressLine1' => { 'value' => '2030 Lake Washington Blvd NE' },
|
113
|
+
'AddressLine2' => { 'value' => 'Suite 100' },
|
114
|
+
'City' => { 'value' => 'Kirkland' },
|
115
|
+
'State' => { 'value' => 'WA' },
|
116
|
+
'PostalCode' => { 'value' => '98033' },
|
117
|
+
'Country' => { 'value' => 'US' }
|
118
|
+
}
|
119
|
+
}
|
120
|
+
},
|
121
|
+
logger: logger
|
122
|
+
)
|
123
|
+
|
124
|
+
MyobAcumatica::Api::Customer.delete_by_keys(
|
125
|
+
access_token: access_token,
|
126
|
+
keys: [customer2['CustomerID']['value']],
|
127
|
+
logger: logger
|
128
|
+
)
|
data/examples/dummy.pdf
ADDED
Binary file
|