Class: Avatax::Api::Transactions

Inherits:
Base
  • Object
show all
Defined in:
lib/avatax/api/transactions.rb

Overview

Transactions client

Instance Attribute Summary

Attributes inherited from Base

#connection

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Avatax::Api::Base

Instance Method Details

#adjust(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Adjust a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



65
66
67
# File 'lib/avatax/api/transactions.rb', line 65

def adjust(company_code, transaction_code, args = {})
  post_for(:adjust, company_code, transaction_code, args)
end

#all(company_code, args = {}) ⇒ Avatax::Response

Get all transactions within a company.

Parameters:

  • company_code (String)

    The company_code in avatax.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

Raises:

  • (ArgumentError)

See Also:



16
17
18
19
20
21
# File 'lib/avatax/api/transactions.rb', line 16

def all(company_code, args = {})
  raise ArgumentError, 'company_code is required' if company_code.blank?

  resp = connection.get "/api/v2/companies/#{company_code}/transactions/", args
  handle_response(resp)
end

#change_code(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Change a transaction code

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The current avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



78
79
80
# File 'lib/avatax/api/transactions.rb', line 78

def change_code(company_code, transaction_code, args = {})
  post_for(:changecode, company_code, transaction_code, args)
end

#commit(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Commit a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The current avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



91
92
93
94
# File 'lib/avatax/api/transactions.rb', line 91

def commit(company_code, transaction_code, args = {})
  args.reverse_merge!(commit: true)
  post_for(:commit, company_code, transaction_code, args)
end

#create(args = {}) ⇒ Avatax::Response

Create a transaction

Parameters:

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



156
157
158
159
# File 'lib/avatax/api/transactions.rb', line 156

def create(args = {})
  resp = connection.post '/api/v2/transactions/create', args
  handle_response(resp)
end

#create_or_adjust(args = {}) ⇒ Avatax::Response

Create or Adjust a transaction if transaction already exists.

Parameters:

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



168
169
170
171
# File 'lib/avatax/api/transactions.rb', line 168

def create_or_adjust(args = {})
  resp = connection.post '/api/v2/transactions/createoradjust', args
  handle_response(resp)
end

#find_by_code(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Get a transaction by code

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

Raises:

  • (ArgumentError)

See Also:



32
33
34
35
36
37
38
# File 'lib/avatax/api/transactions.rb', line 32

def find_by_code(company_code, transaction_code, args = {})
  raise ArgumentError, 'company_code is required' if company_code.blank?
  raise ArgumentError, 'transaction_code is required' if transaction_code.blank?

  resp = connection.get "/api/v2/companies/#{company_code}/transactions/#{transaction_code}", args
  handle_response(resp)
end

#find_by_id(transaction_id, args = {}) ⇒ Avatax::Response

Get a transaction by code

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The avatax transaction ID.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

Raises:

  • (ArgumentError)

See Also:



49
50
51
52
53
54
# File 'lib/avatax/api/transactions.rb', line 49

def find_by_id(transaction_id, args = {})
  raise ArgumentError, 'transaction_id is required' if transaction_id.blank?

  resp = connection.get "/api/v2/transactions/#{transaction_id}", args
  handle_response(resp)
end

#lock(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Lock a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



182
183
184
185
# File 'lib/avatax/api/transactions.rb', line 182

def lock(company_code, transaction_code, args = {})
  args.reverse_merge!(isLocked: true)
  post_for(:lock, company_code, transaction_code, args)
end

#refund(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Refund a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The current avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



145
146
147
# File 'lib/avatax/api/transactions.rb', line 145

def refund(company_code, transaction_code, args = {})
  post_for(:refund, company_code, transaction_code, args)
end

#settle(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Settle a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The current avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



105
106
107
# File 'lib/avatax/api/transactions.rb', line 105

def settle(company_code, transaction_code, args = {})
  post_for(:settle, company_code, transaction_code, args)
end

#verify(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Verify a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The current avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



118
119
120
# File 'lib/avatax/api/transactions.rb', line 118

def verify(company_code, transaction_code, args = {})
  post_for(:verify, company_code, transaction_code, args)
end

#void(company_code, transaction_code, args = {}) ⇒ Avatax::Response

Void a transaction

Parameters:

  • company_code (String)

    The company_code in avatax.

  • transaction_code (String)

    The current avatax transaction code.

  • args (Hash) (defaults to: {})

    Arguments for avatax.

Returns:

See Also:



131
132
133
134
# File 'lib/avatax/api/transactions.rb', line 131

def void(company_code, transaction_code, args = {})
  args.reverse_merge!(code: Avatax::Code::DOC_VOIDED)
  post_for(:void, company_code, transaction_code, args)
end