Module: MyobAcumatica::Api::Tax
- Defined in:
- lib/myob_acumatica/api/tax.rb
Overview
Provides methods to interact with the Tax API endpoints.
Class Method Summary collapse
-
.delete_by_id(access_token:, id:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ nil
Deletes a tax record by its session UUID.
-
.delete_by_keys(access_token:, keys:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ nil
Deletes a tax record by composite keys.
-
.get_ad_hoc_schema(access_token:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Retrieves the ad-hoc schema (custom fields) for the Tax entity.
-
.get_by_id(access_token:, id:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Retrieves a tax record by its session UUID.
-
.get_by_keys(access_token:, keys:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Retrieves a tax record by composite keys.
-
.get_list(access_token:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Array<Hash>
Retrieves a list of tax records with optional filtering and paging.
-
.invoke_action(access_token:, action_name:, entity:, parameters: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash?
Invokes a custom action on a tax record.
-
.put_entity(access_token:, entity:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Creates or updates a tax record.
-
.put_file(access_token:, keys:, file_path:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ nil
Attaches a file to a tax record.
Class Method Details
.delete_by_id(access_token:, id:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ nil
Deletes a tax record by its session UUID.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/myob_acumatica/api/tax.rb', line 26 def delete_by_id(access_token:, id:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :delete, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: "Tax/#{id}", logger: logger ) end |
.delete_by_keys(access_token:, keys:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ nil
Deletes a tax record by composite keys.
Keys are ordered values of the record’s key fields. For Tax this is typically the TaxID (and if applicable, other key parts defined by the endpoint contract).
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/myob_acumatica/api/tax.rb', line 63 def delete_by_keys(access_token:, keys:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :delete, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: "Tax/#{keys.join('/')}", logger: logger ) end |
.get_ad_hoc_schema(access_token:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Retrieves the ad-hoc schema (custom fields) for the Tax entity.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/myob_acumatica/api/tax.rb', line 94 def get_ad_hoc_schema(access_token:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :get, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: 'Tax/$adHocSchema', logger: logger ) end |
.get_by_id(access_token:, id:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Retrieves a tax record by its session UUID.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/myob_acumatica/api/tax.rb', line 129 def get_by_id(access_token:, id:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :get, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: "Tax/#{id}", query_params: query_params, logger: logger ) end |
.get_by_keys(access_token:, keys:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Retrieves a tax record by composite keys.
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/myob_acumatica/api/tax.rb', line 165 def get_by_keys(access_token:, keys:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :get, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: "Tax/#{keys.join('/')}", query_params: query_params, logger: logger ) end |
.get_list(access_token:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Array<Hash>
Retrieves a list of tax records with optional filtering and paging.
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/myob_acumatica/api/tax.rb', line 200 def get_list(access_token:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :get, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: 'Tax', query_params: query_params, logger: logger ) end |
.invoke_action(access_token:, action_name:, entity:, parameters: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash?
Invokes a custom action on a tax record.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/myob_acumatica/api/tax.rb', line 238 def invoke_action(access_token:, action_name:, entity:, parameters: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :post, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: "Tax/#{action_name}", body: { 'entity' => entity, 'parameters' => parameters }, logger: logger ) end |
.put_entity(access_token:, entity:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ Hash
Creates or updates a tax record.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/myob_acumatica/api/tax.rb', line 277 def put_entity(access_token:, entity:, query_params: {}, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) Http.request( instance_name: instance_name, access_token: access_token, method: :put, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: 'Tax', body: entity, query_params: query_params, logger: logger ) end |
.put_file(access_token:, keys:, file_path:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) ⇒ nil
Attaches a file to a tax record. Uses the entity’s files:put link to construct the upload path, then uploads the binary content.
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/myob_acumatica/api/tax.rb', line 316 def put_file(access_token:, keys:, file_path:, instance_name: INSTANCE_NAME, endpoint_name: ENDPOINT_NAME, endpoint_version: ENDPOINT_VERSION, logger: nil) entity = get_by_keys( access_token: access_token, keys: keys, instance_name: instance_name, endpoint_name: endpoint_name, endpoint_version: endpoint_version, logger: logger ) put_template = entity.dig('_links', 'files:put') raise MyobAcumatica::Error, 'files:put link not found' unless put_template filename = File.basename(file_path) path = put_template.gsub('{filename}', filename) Http.request( instance_name: instance_name, access_token: access_token, method: :put, endpoint_name: endpoint_name, endpoint_version: endpoint_version, path: path, body: File.binread(file_path), content_type: 'application/octet-stream', logger: logger ) end |