Class: Paid::Tier

Inherits:
Object
  • Object
show all
Defined in:
lib/paid_ruby/types/tier.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lower_bound: OMIT, upper_bound: OMIT, price: OMIT, additional_properties: nil) ⇒ Paid::Tier

Parameters:

  • lower_bound (Float) (defaults to: OMIT)
  • upper_bound (Float) (defaults to: OMIT)
  • price (Float) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



26
27
28
29
30
31
32
33
34
# File 'lib/paid_ruby/types/tier.rb', line 26

def initialize(lower_bound: OMIT, upper_bound: OMIT, price: OMIT, additional_properties: nil)
  @lower_bound = lower_bound if lower_bound != OMIT
  @upper_bound = upper_bound if upper_bound != OMIT
  @price = price if price != OMIT
  @additional_properties = additional_properties
  @_field_set = { "lowerBound": lower_bound, "upperBound": upper_bound, "price": price }.reject do | _k, v |
  v == OMIT
end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



14
15
16
# File 'lib/paid_ruby/types/tier.rb', line 14

def additional_properties
  @additional_properties
end

#lower_boundFloat (readonly)

Returns:

  • (Float)


8
9
10
# File 'lib/paid_ruby/types/tier.rb', line 8

def lower_bound
  @lower_bound
end

#priceFloat (readonly)

Returns:

  • (Float)


12
13
14
# File 'lib/paid_ruby/types/tier.rb', line 12

def price
  @price
end

#upper_boundFloat (readonly)

Returns:

  • (Float)


10
11
12
# File 'lib/paid_ruby/types/tier.rb', line 10

def upper_bound
  @upper_bound
end

Class Method Details

.from_json(json_object:) ⇒ Paid::Tier

Parameters:

  • json_object (String)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/paid_ruby/types/tier.rb', line 39

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  lower_bound = parsed_json["lowerBound"]
  upper_bound = parsed_json["upperBound"]
  price = parsed_json["price"]
  new(
    lower_bound: lower_bound,
    upper_bound: upper_bound,
    price: price,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Parameters:

  • obj (Object)

Returns:

  • (Void)


64
65
66
67
68
# File 'lib/paid_ruby/types/tier.rb', line 64

def self.validate_raw(obj:)
  obj.lower_bound&.is_a?(Float) != false || raise("Passed value for field obj.lower_bound is not the expected type, validation failed.")
  obj.upper_bound&.is_a?(Float) != false || raise("Passed value for field obj.upper_bound is not the expected type, validation failed.")
  obj.price&.is_a?(Float) != false || raise("Passed value for field obj.price is not the expected type, validation failed.")
end

Instance Method Details

#to_jsonString

Returns:

  • (String)


55
56
57
# File 'lib/paid_ruby/types/tier.rb', line 55

def to_json
  @_field_set&.to_json
end