Class: AuthorizeNet::ARB::Subscription

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/authorize_net/arb/subscription.rb

Overview

Models an ARB subscription.

Defined Under Namespace

Modules: IntervalUnits, Status

Constant Summary collapse

UNLIMITED_OCCURRENCES =

Use this constant for the value of total_occurrences to get a subscription with no end.

9999

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Model

#initialize, #to_a

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def amount
  @amount
end

#billing_addressObject

Returns the value of attribute billing_address.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def billing_address
  @billing_address
end

#credit_cardObject

Returns the value of attribute credit_card.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def credit_card
  @credit_card
end

#customerObject

Returns the value of attribute customer.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def customer
  @customer
end

#descriptionObject

Returns the value of attribute description.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def description
  @description
end

#invoice_numberObject

Returns the value of attribute invoice_number.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def invoice_number
  @invoice_number
end

#lengthObject

Returns the value of attribute length.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def length
  @length
end

#nameObject

Returns the value of attribute name.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def name
  @name
end

#shipping_addressObject

Returns the value of attribute shipping_address.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def shipping_address
  @shipping_address
end

#start_dateObject

Returns the value of attribute start_date.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def start_date
  @start_date
end

#subscription_idObject

Returns the value of attribute subscription_id.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def subscription_id
  @subscription_id
end

#total_occurrencesObject

Returns the value of attribute total_occurrences.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def total_occurrences
  @total_occurrences
end

#trial_amountObject

Returns the value of attribute trial_amount.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def trial_amount
  @trial_amount
end

#trial_occurrencesObject

Returns the value of attribute trial_occurrences.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def trial_occurrences
  @trial_occurrences
end

#unitObject

Returns the value of attribute unit.



24
25
26
# File 'lib/authorize_net/arb/subscription.rb', line 24

def unit
  @unit
end

Instance Method Details

#to_hashObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/authorize_net/arb/subscription.rb', line 47

def to_hash
  hash = {
    subscription_name: @name,
    subscription_length: @length,
    subscription_unit: @unit,
    subscription_start_date: @start_date,
    subscription_total_occurrences: @total_occurrences,
    subscription_trial_occurrences: @trial_occurrences,
    subscription_amount: @amount,
    subscription_trial_amount: @trial_amount,
    invoice_num: @invoice_number,
    description: @description,
    subscription_id: @subscription_id
  }
  hash.merge!(@credit_card.to_hash) unless @credit_card.nil?
  hash.merge!(@billing_address.to_hash) unless @billing_address.nil?
  hash.merge!(@shipping_address.to_hash) unless @shipping_address.nil?
  hash.merge!(@customer.to_hash) unless @customer.nil?
  hash.delete_if { |_k, v| v.nil? }
end