Class: NewStoreApi::CardDetails
- Defined in:
- lib/new_store_api/models/card_details.rb
Overview
Card-specific payment details.
Instance Attribute Summary collapse
-
#card_brand ⇒ String
The card brand, for example
VisaorMastercard. -
#card_last4 ⇒ String
The last four digits of the card number.
-
#merchant_account ⇒ String
The merchant account at the payment provider that settled this payment.
-
#origin ⇒ String
How the card payment was taken, for example
terminalorapple_tap_to_pay. -
#reference ⇒ String
The payment provider's reference for this payment, for example the PSP reference.
-
#terminal_receipt ⇒ Object
Raw terminal receipt data captured at the point of sale, when available.
-
#wallet ⇒ String
The wallet used to present the card, for example
apple_payorgoogle_pay.
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(reference = nil, card_brand = SKIP, card_last4 = SKIP, merchant_account = SKIP, origin = SKIP, terminal_receipt = SKIP, wallet = SKIP) ⇒ CardDetails
constructor
A new instance of CardDetails.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(reference = nil, card_brand = SKIP, card_last4 = SKIP, merchant_account = SKIP, origin = SKIP, terminal_receipt = SKIP, wallet = SKIP) ⇒ CardDetails
Returns a new instance of CardDetails.
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/new_store_api/models/card_details.rb', line 82 def initialize(reference = nil, card_brand = SKIP, card_last4 = SKIP, merchant_account = SKIP, origin = SKIP, terminal_receipt = SKIP, wallet = SKIP) @card_brand = card_brand unless card_brand == SKIP @card_last4 = card_last4 unless card_last4 == SKIP @merchant_account = merchant_account unless merchant_account == SKIP @origin = origin unless origin == SKIP @reference = reference @terminal_receipt = terminal_receipt unless terminal_receipt == SKIP @wallet = wallet unless wallet == SKIP end |
Instance Attribute Details
#card_brand ⇒ String
The card brand, for example Visa or Mastercard.
14 15 16 |
# File 'lib/new_store_api/models/card_details.rb', line 14 def card_brand @card_brand end |
#card_last4 ⇒ String
The last four digits of the card number.
18 19 20 |
# File 'lib/new_store_api/models/card_details.rb', line 18 def card_last4 @card_last4 end |
#merchant_account ⇒ String
The merchant account at the payment provider that settled this payment. Applies to Adyen only.
23 24 25 |
# File 'lib/new_store_api/models/card_details.rb', line 23 def merchant_account @merchant_account end |
#origin ⇒ String
How the card payment was taken, for example terminal or
apple_tap_to_pay.
28 29 30 |
# File 'lib/new_store_api/models/card_details.rb', line 28 def origin @origin end |
#reference ⇒ String
The payment provider's reference for this payment, for example the PSP reference.
33 34 35 |
# File 'lib/new_store_api/models/card_details.rb', line 33 def reference @reference end |
#terminal_receipt ⇒ Object
Raw terminal receipt data captured at the point of sale, when available. Applies to Adyen only.
38 39 40 |
# File 'lib/new_store_api/models/card_details.rb', line 38 def terminal_receipt @terminal_receipt end |
#wallet ⇒ String
The wallet used to present the card, for example apple_pay or
google_pay.
43 44 45 |
# File 'lib/new_store_api/models/card_details.rb', line 43 def wallet @wallet end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/new_store_api/models/card_details.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. reference = hash.key?('reference') ? hash['reference'] : nil card_brand = hash.key?('card_brand') ? hash['card_brand'] : SKIP card_last4 = hash.key?('card_last4') ? hash['card_last4'] : SKIP merchant_account = hash.key?('merchant_account') ? hash['merchant_account'] : SKIP origin = hash.key?('origin') ? hash['origin'] : SKIP terminal_receipt = hash.key?('terminal_receipt') ? hash['terminal_receipt'] : SKIP wallet = hash.key?('wallet') ? hash['wallet'] : SKIP # Create object from extracted values. CardDetails.new(reference, card_brand, card_last4, merchant_account, origin, terminal_receipt, wallet) end |
.names ⇒ Object
A mapping from model property names to API property names.
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/new_store_api/models/card_details.rb', line 46 def self.names @_hash = {} if @_hash.nil? @_hash['card_brand'] = 'card_brand' @_hash['card_last4'] = 'card_last4' @_hash['merchant_account'] = 'merchant_account' @_hash['origin'] = 'origin' @_hash['reference'] = 'reference' @_hash['terminal_receipt'] = 'terminal_receipt' @_hash['wallet'] = 'wallet' @_hash end |
.nullables ⇒ Object
An array for nullable fields
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/new_store_api/models/card_details.rb', line 71 def self.nullables %w[ card_brand card_last4 merchant_account origin terminal_receipt wallet ] end |
.optionals ⇒ Object
An array for optional fields
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/new_store_api/models/card_details.rb', line 59 def self.optionals %w[ card_brand card_last4 merchant_account origin terminal_receipt wallet ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/new_store_api/models/card_details.rb', line 121 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.reference, ->(val) { val.instance_of? String }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['reference'], ->(val) { val.instance_of? String }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
142 143 144 145 146 147 148 |
# File 'lib/new_store_api/models/card_details.rb', line 142 def inspect class_name = self.class.name.split('::').last "<#{class_name} card_brand: #{@card_brand.inspect}, card_last4: #{@card_last4.inspect},"\ " merchant_account: #{@merchant_account.inspect}, origin: #{@origin.inspect}, reference:"\ " #{@reference.inspect}, terminal_receipt: #{@terminal_receipt.inspect}, wallet:"\ " #{@wallet.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
134 135 136 137 138 139 |
# File 'lib/new_store_api/models/card_details.rb', line 134 def to_s class_name = self.class.name.split('::').last "<#{class_name} card_brand: #{@card_brand}, card_last4: #{@card_last4}, merchant_account:"\ " #{@merchant_account}, origin: #{@origin}, reference: #{@reference}, terminal_receipt:"\ " #{@terminal_receipt}, wallet: #{@wallet}>" end |