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

#to_hash, #to_json

Constructor Details

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

Returns a new instance of 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: {})
  @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

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#agreement_termsString

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

Returns:

  • (String)


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.

Returns:

  • (String)


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.

Returns:

  • (String)


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.

Returns:

  • (String)


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.
  names.each_value { |k| hash.delete(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: hash)
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.

Parameters:

  • The (ACHAgreement | Hash)

    value against the validation is performed.



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