class Beaver::TransactionDetails

TransactionDetails Model.

Attributes

discount[RW]

TODO: Write general description for this method @return [String]

itemized_receipt[RW]

TODO: Write general description for this method @return [List of ItemizedReceipt]

note[RW]

TODO: Write general description for this method @return [String]

purchase_order_id[RW]

TODO: Write general description for this method @return [String]

receipt_uri[RW]

TODO: Write general description for this method @return [String]

service_address[RW]

TODO: Write general description for this method @return [AddressRbits]

shipping_address[RW]

TODO: Write general description for this method @return [AddressRbits]

shipping_info[RW]

TODO: Write general description for this method @return [List of ShippingInfo]

terms_text[RW]

TODO: Write general description for this method @return [String]

terms_uri[RW]

TODO: Write general description for this method @return [String]

Public Class Methods

from_hash(hash) click to toggle source

Creates an instance of the object from a hash.

# File lib/beaver/models/transaction_details.rb, line 88
def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  discount = hash['discount']
  # Parameter is an array, so we need to iterate through it
  itemized_receipt = nil
  unless hash['itemized_receipt'].nil?
    itemized_receipt = []
    hash['itemized_receipt'].each do |structure|
      itemized_receipt << (ItemizedReceipt.from_hash(structure) if structure)
    end
  end
  note = hash['note']
  purchase_order_id = hash['purchase_order_id']
  receipt_uri = hash['receipt_uri']
  service_address = AddressRbits.from_hash(hash['service_address']) if
    hash['service_address']
  shipping_address = AddressRbits.from_hash(hash['shipping_address']) if
    hash['shipping_address']
  # Parameter is an array, so we need to iterate through it
  shipping_info = nil
  unless hash['shipping_info'].nil?
    shipping_info = []
    hash['shipping_info'].each do |structure|
      shipping_info << (ShippingInfo.from_hash(structure) if structure)
    end
  end
  terms_text = hash['terms_text']
  terms_uri = hash['terms_uri']

  # Create object from extracted values.
  TransactionDetails.new(discount,
                         itemized_receipt,
                         note,
                         purchase_order_id,
                         receipt_uri,
                         service_address,
                         shipping_address,
                         shipping_info,
                         terms_text,
                         terms_uri)
end
names() click to toggle source

A mapping from model property names to API property names.

# File lib/beaver/models/transaction_details.rb, line 50
def self.names
  @_hash = {} if @_hash.nil?
  @_hash['discount'] = 'discount'
  @_hash['itemized_receipt'] = 'itemized_receipt'
  @_hash['note'] = 'note'
  @_hash['purchase_order_id'] = 'purchase_order_id'
  @_hash['receipt_uri'] = 'receipt_uri'
  @_hash['service_address'] = 'service_address'
  @_hash['shipping_address'] = 'shipping_address'
  @_hash['shipping_info'] = 'shipping_info'
  @_hash['terms_text'] = 'terms_text'
  @_hash['terms_uri'] = 'terms_uri'
  @_hash
end
new(discount = nil, itemized_receipt = nil, note = nil, purchase_order_id = nil, receipt_uri = nil, service_address = nil, shipping_address = nil, shipping_info = nil, terms_text = nil, terms_uri = nil) click to toggle source
# File lib/beaver/models/transaction_details.rb, line 65
def initialize(discount = nil,
               itemized_receipt = nil,
               note = nil,
               purchase_order_id = nil,
               receipt_uri = nil,
               service_address = nil,
               shipping_address = nil,
               shipping_info = nil,
               terms_text = nil,
               terms_uri = nil)
  @discount = discount
  @itemized_receipt = itemized_receipt
  @note = note
  @purchase_order_id = purchase_order_id
  @receipt_uri = receipt_uri
  @service_address = service_address
  @shipping_address = shipping_address
  @shipping_info = shipping_info
  @terms_text = terms_text
  @terms_uri = terms_uri
end