Class: UnivapayClientSdk::RefundCreateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/refund_create_request.rb

Overview

Request body for creating a refund against a successful charge. Konbini and bank transfer charges cannot be refunded.

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:, currency:, reason: SKIP, message: SKIP, metadata: SKIP, additional_properties: nil) ⇒ RefundCreateRequest

Returns a new instance of RefundCreateRequest.



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 63

def initialize(amount:, currency:, reason: SKIP, message: SKIP,
               metadata: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @amount = amount
  @currency = currency
  @reason = reason unless reason == SKIP
  @message = message unless message == SKIP
  @metadata =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountInteger

Amount to refund in the smallest currency unit. Must be greater than 0 and not exceed the charged amount. Partial refunds are supported for most payment methods.

Returns:

  • (Integer)


17
18
19
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 17

def amount
  @amount
end

#currencyString

ISO-4217 currency code. Must exactly match the currency of the original charge.

Returns:

  • (String)


22
23
24
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 22

def currency
  @currency
end

#messageString

Optional free-text note about the reason for the refund.

Returns:

  • (String)


32
33
34
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 32

def message
  @message
end

#metadataGenericMetadata

A free-form dictionary for custom metadata.

Returns:



36
37
38
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 36

def 
  @metadata
end

#reasonRefundReasonRequest

The reason for the refund (merchant-settable values). duplicate: A duplicate charge was made. fraud: The charge is fraudulent. customer_request: The customer requested the refund.

Returns:



28
29
30
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 28

def reason
  @reason
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 77

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
  reason = hash.key?('reason') ? hash['reason'] : SKIP
  message = hash.key?('message') ? hash['message'] : SKIP
   = GenericMetadata.from_hash(hash['metadata']) if hash['metadata']

  # 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.
  RefundCreateRequest.new(amount: amount,
                          currency: currency,
                          reason: reason,
                          message: message,
                          metadata: ,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['reason'] = 'reason'
  @_hash['message'] = 'message'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



59
60
61
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 59

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 50

def self.optionals
  %w[
    reason
    message
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
116
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 111

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, currency: #{@currency.inspect}, reason:"\
  " #{@reason.inspect}, message: #{@message.inspect}, metadata: #{@metadata.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
# File 'lib/univapay_client_sdk/models/refund_create_request.rb', line 104

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, currency: #{@currency}, reason: #{@reason}, message:"\
  " #{@message}, metadata: #{@metadata}, additional_properties: #{@additional_properties}>"
end