Class: AdvancedBilling::RefundSuccess

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/refund_success.rb

Overview

RefundSuccess Model.

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(refund_id:, gateway_transaction_id:, product_id:, additional_properties: {}) ⇒ RefundSuccess

Returns a new instance of RefundSuccess.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/advanced_billing/models/refund_success.rb', line 43

def initialize(refund_id:, gateway_transaction_id:, product_id:,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @refund_id = refund_id
  @gateway_transaction_id = gateway_transaction_id
  @product_id = product_id
end

Instance Attribute Details

#gateway_transaction_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/advanced_billing/models/refund_success.rb', line 18

def gateway_transaction_id
  @gateway_transaction_id
end

#product_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/refund_success.rb', line 22

def product_id
  @product_id
end

#refund_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/refund_success.rb', line 14

def refund_id
  @refund_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/advanced_billing/models/refund_success.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  refund_id = hash.key?('refund_id') ? hash['refund_id'] : nil
  gateway_transaction_id =
    hash.key?('gateway_transaction_id') ? hash['gateway_transaction_id'] : nil
  product_id = hash.key?('product_id') ? hash['product_id'] : nil

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  RefundSuccess.new(refund_id: refund_id,
                    gateway_transaction_id: gateway_transaction_id,
                    product_id: product_id,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/advanced_billing/models/refund_success.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['refund_id'] = 'refund_id'
  @_hash['gateway_transaction_id'] = 'gateway_transaction_id'
  @_hash['product_id'] = 'product_id'
  @_hash
end

.nullablesObject

An array for nullable fields



39
40
41
# File 'lib/advanced_billing/models/refund_success.rb', line 39

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
# File 'lib/advanced_billing/models/refund_success.rb', line 34

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (RefundSuccess | Hash)

    value against the validation is performed.



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.refund_id,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.gateway_transaction_id,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.product_id,
                              ->(val) { val.instance_of? Integer })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['refund_id'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['gateway_transaction_id'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['product_id'],
                            ->(val) { val.instance_of? Integer })
  )
end