myob_acumatica 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 678933f096d8f4456493114fee9b10c7a441dbaff1240f3446a805e8cc477780
4
- data.tar.gz: 255125625f54ddce79e8d8498cb8bd19c44ae42fc33d75b383d9cb252c689798
3
+ metadata.gz: 13fbce76da83c644f946012fe508838d0b8a08eb2425202d6138c0dc389cbd4a
4
+ data.tar.gz: 7841a0ce98ce34f0ab35f71781a00e3e78000578f16c756d4cf90323355f2150
5
5
  SHA512:
6
- metadata.gz: ebb16230ea6a77228861d9ffa4ebf3d8f9a69134f428c370dff21bb37c4690fe2aafd118b0a445ae54b5012a599503ce9451f014df1d4444f4acf4aef3c59b55
7
- data.tar.gz: c004a8448658a209e54c42608d6759047218f4a62acfef1b26ba9803b1ef76447d354f069f9eecec8df590d070c9080026f09ca45cd8fd55e6ce5f3f596a938a
6
+ metadata.gz: 4f95a2575dbf194e812c0c6aa82d6058dbdce2cde3f8baafae8a5de5c00c87414e46d015901ba41f4d899776849977832dee6a27401eaa14b09360e801b83010
7
+ data.tar.gz: ac46af5f83b581a64f55edf70aeb4a7887962cbebd880ead202ea5e2361ce4a2dfd3de95ed2e5e255a2dc8a8f52dfeef24c6cc283c250e13c5b9a8d499adb49e
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
- # Myob Acumatica
1
+ # Ruby library for the MYOB Acumatica API
2
2
 
3
- Access the MYOB Acumatica HTTP API via Ruby
3
+ A lightweight Ruby client for accessing the MYOB Acumatica REST API via OAuth2.
4
+
5
+ ---
4
6
 
5
7
  ## Installation
6
8
 
7
- Install the gem and add to the application's Gemfile by executing:
9
+ Using Bundler:
10
+
11
+ ```bash
12
+ bundle add myob_acumatica
13
+ ```
14
+
15
+ Without Bundler:
8
16
 
9
- $ bundle add myob_acumatica
17
+ ```bash
18
+ gem install myob_acumatica
19
+ ```
20
+
21
+ ---
10
22
 
11
- If bundler is not being used to manage dependencies, install the gem by executing:
23
+ ## Setup
12
24
 
13
- $ gem install myob_acumatica
25
+ Set the following environment variables in your host application:
14
26
 
15
- ## Usage
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
- ## 1. Get an access token using the OAuth2 Authorization Code Grant Flow
37
+ ---
18
38
 
19
- ### i. Generate Authorization URL
39
+ ## OAuth2 Flow
20
40
 
21
- To initiate the OAuth2 flow, generate an authorization URL:
41
+ Get the authorization URL to initiate login:
22
42
 
23
43
  ```ruby
24
- MyobAcumatica::OAuth2.authorize_url(
25
- instance_url: ...,
26
- client_id: ...,
27
- redirect_uri: ...,
28
- scope: 'api offline'
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
- => https://{instance_url}/identity/connect/authorize?response_type=code&client_id={client_id}&redirect_uri={redirect_uri}&scope=api+offline_access
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
- Then redirect users to this URL to start the authorization process.
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
- ### ii. Exchange the authorization code for an access token
86
+ List customers:
37
87
 
38
- After the user has authorized the application, they will be redirected back to your application with an authorization code.
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
- Use this code to request an access token:
95
+ Get customer by keys:
41
96
 
42
97
  ```ruby
43
- MyobAcumatica::OAuth2.authorize_token(
44
- instance_url: ...,
45
- client_id: ...,
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
- => {"access_token":"abc",expires_in":3600,"token_type":"Bearer","refresh_token":"def","scope":"api offline_access"}
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
- ### iii. Refresh the access token using the refresh token
117
+ Create an invoice:
56
118
 
57
- If the access token expires, you can use the refresh token received during the token exchange to obtain a new access token:
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::OAuth2.refresh_token(
61
- instance_url: ENV['INSTANCE_URL'],
62
- client_id: ENV['CLIENT_ID'],
63
- client_secret: ENV['CLIENT_SECRET'],
64
- refresh_token: params[:refresh_token],
65
- logger: Logger.new($stdout)
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
- => {"access_token":"ghi",expires_in":3600,"token_type":"Bearer","refresh_token":"jkl","scope":"api offline_access"}
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
- ## 2. Hit the MYOB Accumatica API
158
+ Delete an invoice:
72
159
 
73
160
  ```ruby
74
- customers = MyobAcumatica::Customer.list(
75
- instance_url: ...,
76
- endpoint_name: 'Default',
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
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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 on GitHub at https://github.com/fast-programmer/myob_acumatica. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/fast-programmer/myob_acumatica/blob/master/CODE_OF_CONDUCT.md).
226
+ Bug reports and pull requests are welcome at:
227
+ https://github.com/fast-programmer/myob_acumatica
93
228
 
94
- ## License
229
+ Please follow the code of conduct:
230
+ https://github.com/fast-programmer/myob_acumatica/blob/master/CODE_OF_CONDUCT.md
95
231
 
96
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
232
+ ---
97
233
 
98
- ## Code of Conduct
234
+ ## License
99
235
 
100
- Everyone interacting in the MyobAcumatica project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/fast-programmer/myob_acumatica/blob/master/CODE_OF_CONDUCT.md).
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
- instance_url: ENV['INSTANCE_URL'],
21
- client_id: ENV['CLIENT_ID'],
22
- redirect_uri: ENV['REDIRECT_URI'],
23
- scope: ENV['SCOPE']
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.authorize_token(
31
- instance_url: ENV['INSTANCE_URL'],
32
- client_id: ENV['CLIENT_ID'],
33
- client_secret: ENV['CLIENT_SECRET'],
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['REDIRECT_URI'],
35
+ redirect_uri: ENV['MYOB_ACUMATICA_REDIRECT_URI'],
36
36
  logger: logger
37
37
  )
38
38
 
39
- customers = MyobAcumatica::Customer.list(
40
- instance_url: ENV['INSTANCE_URL'],
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
- query_params: { filter: 'IsActive eq true' },
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.refresh_token(
58
- instance_url: ENV['INSTANCE_URL'],
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
+ )
Binary file