Class: ApiReference::PaymentMethod
- Defined in:
- lib/api_reference/models/payment_method.rb
Overview
A payment method represents a customer's stored payment instrument held with an external payment provider (such as Adyen or Stripe). The serialization is intentionally minimal for now; provider-pulled details (e.g. card display metadata) will be added over time.
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
The time at which the payment method was created.
-
#customer_id ⇒ String
The ID of the Orb customer this payment method is attached to.
-
#default ⇒ TrueClass | FalseClass
Whether this is the customer's default payment method.
-
#external_payment_method_id ⇒ String
The identifier of this payment method in the external payment provider.
-
#id ⇒ String
The Orb-assigned unique identifier for the payment method.
-
#payment_method_type ⇒ PaymentMethodType
The type of the underlying payment instrument, e.g.
-
#provider_type ⇒ String
The external payment provider this method belongs to, derived from the linked payment gateway connection (e.g.
adyenorstripe).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(id:, payment_method_type:, provider_type:, external_payment_method_id:, customer_id:, default:, created_at:, additional_properties: nil) ⇒ PaymentMethod
constructor
A new instance of PaymentMethod.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, payment_method_type:, provider_type:, external_payment_method_id:, customer_id:, default:, created_at:, additional_properties: nil) ⇒ PaymentMethod
Returns a new instance of PaymentMethod.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/api_reference/models/payment_method.rb', line 72 def initialize(id:, payment_method_type:, provider_type:, external_payment_method_id:, customer_id:, default:, created_at:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @payment_method_type = payment_method_type @provider_type = provider_type @external_payment_method_id = external_payment_method_id @customer_id = customer_id @default = default @created_at = created_at @additional_properties = additional_properties end |
Instance Attribute Details
#created_at ⇒ DateTime
The time at which the payment method was created.
45 46 47 |
# File 'lib/api_reference/models/payment_method.rb', line 45 def created_at @created_at end |
#customer_id ⇒ String
The ID of the Orb customer this payment method is attached to.
37 38 39 |
# File 'lib/api_reference/models/payment_method.rb', line 37 def customer_id @customer_id end |
#default ⇒ TrueClass | FalseClass
Whether this is the customer's default payment method.
41 42 43 |
# File 'lib/api_reference/models/payment_method.rb', line 41 def default @default end |
#external_payment_method_id ⇒ String
The identifier of this payment method in the external payment provider.
33 34 35 |
# File 'lib/api_reference/models/payment_method.rb', line 33 def external_payment_method_id @external_payment_method_id end |
#id ⇒ String
The Orb-assigned unique identifier for the payment method.
18 19 20 |
# File 'lib/api_reference/models/payment_method.rb', line 18 def id @id end |
#payment_method_type ⇒ PaymentMethodType
The type of the underlying payment instrument, e.g. card or
us_bank_account.
23 24 25 |
# File 'lib/api_reference/models/payment_method.rb', line 23 def payment_method_type @payment_method_type end |
#provider_type ⇒ String
The external payment provider this method belongs to, derived from the
linked payment gateway connection (e.g. adyen or stripe). Null if the
connection has been removed.
29 30 31 |
# File 'lib/api_reference/models/payment_method.rb', line 29 def provider_type @provider_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/api_reference/models/payment_method.rb', line 89 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil payment_method_type = hash.key?('payment_method_type') ? hash['payment_method_type'] : nil provider_type = hash.key?('provider_type') ? hash['provider_type'] : nil external_payment_method_id = hash.key?('external_payment_method_id') ? hash['external_payment_method_id'] : nil customer_id = hash.key?('customer_id') ? hash['customer_id'] : nil default = hash.key?('default') ? hash['default'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. PaymentMethod.new(id: id, payment_method_type: payment_method_type, provider_type: provider_type, external_payment_method_id: external_payment_method_id, customer_id: customer_id, default: default, created_at: created_at, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/api_reference/models/payment_method.rb', line 48 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['payment_method_type'] = 'payment_method_type' @_hash['provider_type'] = 'provider_type' @_hash['external_payment_method_id'] = 'external_payment_method_id' @_hash['customer_id'] = 'customer_id' @_hash['default'] = 'default' @_hash['created_at'] = 'created_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
66 67 68 69 70 |
# File 'lib/api_reference/models/payment_method.rb', line 66 def self.nullables %w[ provider_type ] end |
.optionals ⇒ Object
An array for optional fields
61 62 63 |
# File 'lib/api_reference/models/payment_method.rb', line 61 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/api_reference/models/payment_method.rb', line 129 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.payment_method_type, ->(val) { PaymentMethodType.validate(val) }) and APIHelper.valid_type?(value.provider_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.external_payment_method_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.customer_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.default, ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value.created_at, ->(val) { val.instance_of? DateTime }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['payment_method_type'], ->(val) { PaymentMethodType.validate(val) }) and APIHelper.valid_type?(value['provider_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['external_payment_method_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['customer_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['default'], ->(val) { val.instance_of? TrueClass or val.instance_of? FalseClass }) and APIHelper.valid_type?(value['created_at'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
179 180 181 182 183 184 185 186 |
# File 'lib/api_reference/models/payment_method.rb', line 179 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, payment_method_type: #{@payment_method_type.inspect},"\ " provider_type: #{@provider_type.inspect}, external_payment_method_id:"\ " #{@external_payment_method_id.inspect}, customer_id: #{@customer_id.inspect}, default:"\ " #{@default.inspect}, created_at: #{@created_at.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_custom_created_at ⇒ Object
123 124 125 |
# File 'lib/api_reference/models/payment_method.rb', line 123 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
170 171 172 173 174 175 176 |
# File 'lib/api_reference/models/payment_method.rb', line 170 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, payment_method_type: #{@payment_method_type}, provider_type:"\ " #{@provider_type}, external_payment_method_id: #{@external_payment_method_id},"\ " customer_id: #{@customer_id}, default: #{@default}, created_at: #{@created_at},"\ " additional_properties: #{@additional_properties}>" end |