Class: PaypalServerSdk::PaymentTokenResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/payment_token_response.rb

Overview

Full representation of a saved payment token.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id: SKIP, customer: SKIP, payment_source: SKIP, links: SKIP) ⇒ PaymentTokenResponse

Returns a new instance of PaymentTokenResponse.



53
54
55
56
57
58
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 53

def initialize(id: SKIP, customer: SKIP, payment_source: SKIP, links: SKIP)
  @id = id unless id == SKIP
  @customer = customer unless customer == SKIP
  @payment_source = payment_source unless payment_source == SKIP
  @links = links unless links == SKIP
end

Instance Attribute Details

#customerCustomerRequest

Customer in merchant’s or partner’s system of records.

Returns:



18
19
20
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 18

def customer
  @customer
end

#idString

The PayPal-generated ID for the vault token.

Returns:

  • (String)


14
15
16
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 14

def id
  @id
end

An array of related [HATEOAS links](/api/rest/responses/#hateoas).

Returns:



26
27
28
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 26

def links
  @links
end

#payment_sourcePaymentTokenResponsePaymentSource

The vaulted payment method details.



22
23
24
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 22

def payment_source
  @payment_source
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 61

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  customer = CustomerRequest.from_hash(hash['customer']) if hash['customer']
  payment_source = PaymentTokenResponsePaymentSource.from_hash(hash['payment_source']) if
    hash['payment_source']
  # Parameter is an array, so we need to iterate through it
  links = nil
  unless hash['links'].nil?
    links = []
    hash['links'].each do |structure|
      links << (LinkDescription.from_hash(structure) if structure)
    end
  end

  links = SKIP unless hash.key?('links')

  # Create object from extracted values.
  PaymentTokenResponse.new(id: id,
                           customer: customer,
                           payment_source: payment_source,
                           links: links)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['customer'] = 'customer'
  @_hash['payment_source'] = 'payment_source'
  @_hash['links'] = 'links'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/paypal_server_sdk/models/payment_token_response.rb', line 39

def self.optionals
  %w[
    id
    customer
    payment_source
    links
  ]
end