Class: AdvancedBilling::ACHAgreement

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/ach_agreement.rb

Overview

(Optional) If passed, the proof of the authorized ACH agreement terms will be persisted.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(agreement_terms: SKIP, authorizer_first_name: SKIP, authorizer_last_name: SKIP, ip_address: SKIP, additional_properties: {}) ⇒ ACHAgreement



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/advanced_billing/models/ach_agreement.rb', line 58

def initialize(agreement_terms: SKIP, authorizer_first_name: SKIP,
               authorizer_last_name: SKIP, ip_address: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @agreement_terms = agreement_terms unless agreement_terms == SKIP
  @authorizer_first_name = authorizer_first_name unless authorizer_first_name == SKIP
  @authorizer_last_name = authorizer_last_name unless authorizer_last_name == SKIP
  @ip_address = ip_address unless ip_address == SKIP
end

Instance Attribute Details

#agreement_termsString

(Required when providing ACH agreement params) The ACH authorization agreement terms.



16
17
18
# File 'lib/advanced_billing/models/ach_agreement.rb', line 16

def agreement_terms
  @agreement_terms
end

#authorizer_first_nameString

(Required when providing ACH agreement params) The first name of the person authorizing the ACH agreement.



21
22
23
# File 'lib/advanced_billing/models/ach_agreement.rb', line 21

def authorizer_first_name
  @authorizer_first_name
end

#authorizer_last_nameString

(Required when providing ACH agreement params) The last name of the person authorizing the ACH agreement.



26
27
28
# File 'lib/advanced_billing/models/ach_agreement.rb', line 26

def authorizer_last_name
  @authorizer_last_name
end

#ip_addressString

(Required when providing ACH agreement params) The IP address of the person authorizing the ACH agreement.



31
32
33
# File 'lib/advanced_billing/models/ach_agreement.rb', line 31

def ip_address
  @ip_address
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/models/ach_agreement.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  agreement_terms =
    hash.key?('agreement_terms') ? hash['agreement_terms'] : SKIP
  authorizer_first_name =
    hash.key?('authorizer_first_name') ? hash['authorizer_first_name'] : SKIP
  authorizer_last_name =
    hash.key?('authorizer_last_name') ? hash['authorizer_last_name'] : SKIP
  ip_address = hash.key?('ip_address') ? hash['ip_address'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  ACHAgreement.new(agreement_terms: agreement_terms,
                   authorizer_first_name: authorizer_first_name,
                   authorizer_last_name: authorizer_last_name,
                   ip_address: ip_address,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/ach_agreement.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['agreement_terms'] = 'agreement_terms'
  @_hash['authorizer_first_name'] = 'authorizer_first_name'
  @_hash['authorizer_last_name'] = 'authorizer_last_name'
  @_hash['ip_address'] = 'ip_address'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/advanced_billing/models/ach_agreement.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
# File 'lib/advanced_billing/models/ach_agreement.rb', line 44

def self.optionals
  %w[
    agreement_terms
    authorizer_first_name
    authorizer_last_name
    ip_address
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.



98
99
100
101
102
103
104
# File 'lib/advanced_billing/models/ach_agreement.rb', line 98

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



115
116
117
118
119
120
# File 'lib/advanced_billing/models/ach_agreement.rb', line 115

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} agreement_terms: #{@agreement_terms.inspect}, authorizer_first_name:"\
  " #{@authorizer_first_name.inspect}, authorizer_last_name: #{@authorizer_last_name.inspect},"\
  " ip_address: #{@ip_address.inspect}, additional_properties: #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



107
108
109
110
111
112
# File 'lib/advanced_billing/models/ach_agreement.rb', line 107

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} agreement_terms: #{@agreement_terms}, authorizer_first_name:"\
  " #{@authorizer_first_name}, authorizer_last_name: #{@authorizer_last_name}, ip_address:"\
  " #{@ip_address}, additional_properties: #{get_additional_properties}>"
end