Class: AvataxClient::Request::Address

Inherits:
Base
  • Object
show all
Defined in:
lib/avatax_client/request/address.rb

Overview

Handles modeling of Address when performing requests (create / update)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AvataxClient::ReverseCoercion

included

Class Method Details

.collection_to_body(addresses = []) ⇒ Hash

Transform a colleciton of AvataxClient::Request::Address into a format compatible with Avatax.

Parameters:

Returns:

  • (Hash)


22
23
24
# File 'lib/avatax_client/request/address.rb', line 22

def collection_to_body(addresses = [])
  addresses.reduce({}) { |a, e| a.merge!(e.to_body) }
end

Instance Method Details

#to_bodyHash

Transform Hash into a version compatible with Avatax. Removes ‘label` attribute from hash, as it is used as the parent key in `addresses: {}`.

Returns:

  • (Hash)


32
33
34
35
36
37
38
39
40
# File 'lib/avatax_client/request/address.rb', line 32

def to_body
  hash = super

  label = hash[:label]
  hash.delete(:label)
  hash = { label => hash }

  hash
end