Class: AlphaCard::Order

Inherits:
Resource show all
Defined in:
lib/alpha_card/resources/order.rb

Overview

Implementation of Alpha Card Services Order object. Contains all the information about order (id, description, etc).

Constant Summary collapse

ORIGIN_TRANSACTION_VARIABLES =

Original AlphaCard transaction variables names

{
  id: :orderid,
  description: :orderdescription,
  po_number: :ponumber,
  ip_address: :ipaddress
}.freeze

Instance Method Summary collapse

Methods included from Attribute

included

Instance Method Details

#attributes_for_requestHash

Overloaded method to return all the attributes from the sale + billing + shipping objects.

Examples:

billing = AlphaCard::Billing.new(email: '[email protected]')
shipping = AlphaCard::Shipping.new(first_name: 'John', last_name: 'Doe')
order = AlphaCard::Order.new(id: '1', billing: billing, shipping: shipping)
order.attributes_for_request

#=>  { orderid: '1', email: '[email protected]', shipping_first_name: 'John', shipping_last_name: 'Doe' }

Returns:

  • (Hash)

    Filled attributes with the original Alpha Card Services transaction variables names.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/alpha_card/resources/order.rb', line 40

def attributes_for_request(*)
  attributes = filled_attributes.dup

  billing = attributes.delete(:billing)
  attributes.merge!(billing.attributes_for_request) if billing

  shipping = attributes.delete(:shipping)
  attributes.merge!(shipping.attributes_for_request) if shipping

  super(attributes)
end