Class: StickyIoRestfulApiV2025731::PrepaidProfileOneOf1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb

Overview

PrepaidProfileOneOf1 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(is_subscription:, is_cancel_immediate:, is_refund_allowed:, is_initial_shipping_on_restart:, created_at:, updated_at:, terms:, additional_properties: nil) ⇒ PrepaidProfileOneOf1

Returns a new instance of PrepaidProfileOneOf1.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 66

def initialize(is_subscription:, is_cancel_immediate:, is_refund_allowed:,
               is_initial_shipping_on_restart:, created_at:, updated_at:,
               terms:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @is_subscription = is_subscription
  @is_cancel_immediate = is_cancel_immediate
  @is_refund_allowed = is_refund_allowed
  @is_initial_shipping_on_restart = is_initial_shipping_on_restart
  @created_at = created_at
  @updated_at = updated_at
  @terms = terms
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atString

TODO: Write general description for this method

Returns:

  • (String)


30
31
32
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 30

def created_at
  @created_at
end

#is_cancel_immediateInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 18

def is_cancel_immediate
  @is_cancel_immediate
end

#is_initial_shipping_on_restartInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 26

def is_initial_shipping_on_restart
  @is_initial_shipping_on_restart
end

#is_refund_allowedInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 22

def is_refund_allowed
  @is_refund_allowed
end

#is_subscriptionInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 14

def is_subscription
  @is_subscription
end

#termsArray[Term]

TODO: Write general description for this method

Returns:



38
39
40
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 38

def terms
  @terms
end

#updated_atString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 34

def updated_at
  @updated_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 83

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  is_subscription =
    hash.key?('is_subscription') ? hash['is_subscription'] : nil
  is_cancel_immediate =
    hash.key?('is_cancel_immediate') ? hash['is_cancel_immediate'] : nil
  is_refund_allowed =
    hash.key?('is_refund_allowed') ? hash['is_refund_allowed'] : nil
  is_initial_shipping_on_restart =
    hash.key?('is_initial_shipping_on_restart') ? hash['is_initial_shipping_on_restart'] : nil
  created_at = hash.key?('created_at') ? hash['created_at'] : nil
  updated_at = hash.key?('updated_at') ? hash['updated_at'] : nil
  # Parameter is an array, so we need to iterate through it
  terms = nil
  unless hash['terms'].nil?
    terms = []
    hash['terms'].each do |structure|
      terms << (Term.from_hash(structure) if structure)
    end
  end

  terms = nil unless hash.key?('terms')

  # 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.
  PrepaidProfileOneOf1.new(is_subscription: is_subscription,
                           is_cancel_immediate: is_cancel_immediate,
                           is_refund_allowed: is_refund_allowed,
                           is_initial_shipping_on_restart: is_initial_shipping_on_restart,
                           created_at: created_at,
                           updated_at: updated_at,
                           terms: terms,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['is_subscription'] = 'is_subscription'
  @_hash['is_cancel_immediate'] = 'is_cancel_immediate'
  @_hash['is_refund_allowed'] = 'is_refund_allowed'
  @_hash['is_initial_shipping_on_restart'] =
    'is_initial_shipping_on_restart'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['terms'] = 'terms'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
63
64
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 60

def self.nullables
  %w[
    updated_at
  ]
end

.optionalsObject

An array for optional fields



55
56
57
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 55

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 128

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.is_subscription,
                            ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_cancel_immediate,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_refund_allowed,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.is_initial_shipping_on_restart,
                              ->(val) { val.instance_of? Integer }) and
        APIHelper.valid_type?(value.created_at,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.updated_at,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.terms,
                              ->(val) { Term.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['is_subscription'],
                          ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_cancel_immediate'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_refund_allowed'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['is_initial_shipping_on_restart'],
                            ->(val) { val.instance_of? Integer }) and
      APIHelper.valid_type?(value['created_at'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['updated_at'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['terms'],
                            ->(val) { Term.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true)
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



183
184
185
186
187
188
189
190
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 183

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} is_subscription: #{@is_subscription.inspect}, is_cancel_immediate:"\
  " #{@is_cancel_immediate.inspect}, is_refund_allowed: #{@is_refund_allowed.inspect},"\
  " is_initial_shipping_on_restart: #{@is_initial_shipping_on_restart.inspect}, created_at:"\
  " #{@created_at.inspect}, updated_at: #{@updated_at.inspect}, terms: #{@terms.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



173
174
175
176
177
178
179
180
# File 'lib/sticky_io_restful_api_v2025731/models/prepaid_profile_one_of1.rb', line 173

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} is_subscription: #{@is_subscription}, is_cancel_immediate:"\
  " #{@is_cancel_immediate}, is_refund_allowed: #{@is_refund_allowed},"\
  " is_initial_shipping_on_restart: #{@is_initial_shipping_on_restart}, created_at:"\
  " #{@created_at}, updated_at: #{@updated_at}, terms: #{@terms}, additional_properties:"\
  " #{@additional_properties}>"
end