Class: NewDemoApiClient::Area

Inherits:
Object
  • Object
show all
Defined in:
lib/test_sdk/types/area.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alpha:, x:, y:, additional_properties: nil) ⇒ NewDemoApiClient::Area



29
30
31
32
33
34
35
# File 'lib/test_sdk/types/area.rb', line 29

def initialize(alpha:, x:, y:, additional_properties: nil)
  @alpha = alpha
  @x = x
  @y = y
  @additional_properties = additional_properties
  @_field_set = { "alpha": alpha, "x": x, "y": y }
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



16
17
18
# File 'lib/test_sdk/types/area.rb', line 16

def additional_properties
  @additional_properties
end

#alphaFloat (readonly)



10
11
12
# File 'lib/test_sdk/types/area.rb', line 10

def alpha
  @alpha
end

#xArray<Float> (readonly)



12
13
14
# File 'lib/test_sdk/types/area.rb', line 12

def x
  @x
end

#yArray<Float> (readonly)



14
15
16
# File 'lib/test_sdk/types/area.rb', line 14

def y
  @y
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::Area

Deserialize a JSON object to an instance of Area



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/test_sdk/types/area.rb', line 41

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  alpha = parsed_json["alpha"]
  x = parsed_json["x"]
  y = parsed_json["y"]
  new(
    alpha: alpha,
    x: x,
    y: y,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


68
69
70
71
72
# File 'lib/test_sdk/types/area.rb', line 68

def self.validate_raw(obj:)
  obj.alpha.is_a?(Float) != false || raise("Passed value for field obj.alpha is not the expected type, validation failed.")
  obj.x.is_a?(Array) != false || raise("Passed value for field obj.x is not the expected type, validation failed.")
  obj.y.is_a?(Array) != false || raise("Passed value for field obj.y is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Area to a JSON object



58
59
60
# File 'lib/test_sdk/types/area.rb', line 58

def to_json(*_args)
  @_field_set&.to_json
end