Class: AvataxClient::Request::Address
- Defined in:
- lib/avatax_client/request/address.rb
Overview
Handles modeling of Address when performing requests (create / update)
Class Method Summary collapse
-
.collection_to_body(addresses = []) ⇒ Hash
Transform a colleciton of Address into a format compatible with Avatax.
Instance Method Summary collapse
-
#to_body ⇒ Hash
Transform Hash into a version compatible with Avatax.
Methods included from AvataxClient::ReverseCoercion
Class Method Details
.collection_to_body(addresses = []) ⇒ Hash
Transform a colleciton of AvataxClient::Request::Address into a format compatible with Avatax.
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_body ⇒ Hash
Transform Hash into a version compatible with Avatax. Removes ‘label` attribute from hash, as it is used as the parent key in `addresses: {}`.
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 |