Class: NewStoreApi::PaymentLinkRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/payment_link_request.rb

Overview

Creates a payment link.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

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

Constructor Details

#initialize(amount = nil, currency = nil, store_id = nil, callback_url = SKIP, customer = SKIP) ⇒ PaymentLinkRequest

Returns a new instance of PaymentLinkRequest.



58
59
60
61
62
63
64
65
# File 'lib/new_store_api/models/payment_link_request.rb', line 58

def initialize(amount = nil, currency = nil, store_id = nil,
               callback_url = SKIP, customer = SKIP)
  @amount = amount
  @callback_url = callback_url unless callback_url == SKIP
  @currency = currency
  @customer = customer unless customer == SKIP
  @store_id = store_id
end

Instance Attribute Details

#amountFloat

The amount of the payment in major units (e.g. 9.95 for $9.95). Decimal precision depends on the currency.

Returns:

  • (Float)


15
16
17
# File 'lib/new_store_api/models/payment_link_request.rb', line 15

def amount
  @amount
end

#callback_urlString

Optional merchant endpoint called when this payment link succeeds via PUT /payment-links/{payment_reference}/_success.

Returns:

  • (String)


20
21
22
# File 'lib/new_store_api/models/payment_link_request.rb', line 20

def callback_url
  @callback_url
end

#currencyString

The currency of the payment.

Returns:

  • (String)


24
25
26
# File 'lib/new_store_api/models/payment_link_request.rb', line 24

def currency
  @currency
end

#customerCustomer1

Customer object for optional risk assessment.

Returns:



28
29
30
# File 'lib/new_store_api/models/payment_link_request.rb', line 28

def customer
  @customer
end

#store_idString

The store identifier for the payment link.

Returns:

  • (String)


32
33
34
# File 'lib/new_store_api/models/payment_link_request.rb', line 32

def store_id
  @store_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/new_store_api/models/payment_link_request.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
  currency = hash.key?('currency') ? hash['currency'] : nil
  store_id = hash.key?('store_id') ? hash['store_id'] : nil
  callback_url = hash.key?('callback_url') ? hash['callback_url'] : SKIP
  customer = Customer1.from_hash(hash['customer']) if hash['customer']

  # Create object from extracted values.
  PaymentLinkRequest.new(amount,
                         currency,
                         store_id,
                         callback_url,
                         customer)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
43
# File 'lib/new_store_api/models/payment_link_request.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['callback_url'] = 'callback_url'
  @_hash['currency'] = 'currency'
  @_hash['customer'] = 'customer'
  @_hash['store_id'] = 'store_id'
  @_hash
end

.nullablesObject

An array for nullable fields



54
55
56
# File 'lib/new_store_api/models/payment_link_request.rb', line 54

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
# File 'lib/new_store_api/models/payment_link_request.rb', line 46

def self.optionals
  %w[
    callback_url
    customer
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



94
95
96
97
98
99
# File 'lib/new_store_api/models/payment_link_request.rb', line 94

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, callback_url: #{@callback_url.inspect},"\
  " currency: #{@currency.inspect}, customer: #{@customer.inspect}, store_id:"\
  " #{@store_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



87
88
89
90
91
# File 'lib/new_store_api/models/payment_link_request.rb', line 87

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, callback_url: #{@callback_url}, currency: #{@currency},"\
  " customer: #{@customer}, store_id: #{@store_id}>"
end