Class: NewDemoApiClient::TradeoffModel

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scale:, raw_data:, discarded_raw_data:, areas:, additional_properties: nil) ⇒ NewDemoApiClient::TradeoffModel

Parameters:

  • scale (NewDemoApiClient::Scale)

    Describes the revenue range of the data whose points represent the trade off.

  • raw_data (Array<Hash{String => Float}>)

    Raw data points used to generate the scaling model. Dictionary of the two metrics, x then y.

  • discarded_raw_data (Array<Hash{String => Float}>)

    Additional raw data points which were not used in the model fit due to oulier status. Dictionary of the two metrics, x then y.

  • areas (Array<NewDemoApiClient::Area>)

    Areas representing the range of the scaling model. The x-y coordinates describe a surface containing 1 - alpha share of the data points.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



38
39
40
41
42
43
44
45
# File 'lib/test_sdk/types/tradeoff_model.rb', line 38

def initialize(scale:, raw_data:, discarded_raw_data:, areas:, additional_properties: nil)
  @scale = scale
  @raw_data = raw_data
  @discarded_raw_data = discarded_raw_data
  @areas = areas
  @additional_properties = additional_properties
  @_field_set = { "scale": scale, "raw_data": raw_data, "discarded_raw_data": discarded_raw_data, "areas": areas }
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



22
23
24
# File 'lib/test_sdk/types/tradeoff_model.rb', line 22

def additional_properties
  @additional_properties
end

#areasArray<NewDemoApiClient::Area> (readonly)

Returns Areas representing the range of the scaling model. The x-y coordinates describe a surface containing 1 - alpha share of the data points.

Returns:

  • (Array<NewDemoApiClient::Area>)

    Areas representing the range of the scaling model. The x-y coordinates describe a surface containing 1 - alpha share of the data points.



20
21
22
# File 'lib/test_sdk/types/tradeoff_model.rb', line 20

def areas
  @areas
end

#discarded_raw_dataArray<Hash{String => Float}> (readonly)

Returns Additional raw data points which were not used in the model fit due to oulier status. Dictionary of the two metrics, x then y.

Returns:

  • (Array<Hash{String => Float}>)

    Additional raw data points which were not used in the model fit due to oulier status. Dictionary of the two metrics, x then y.



17
18
19
# File 'lib/test_sdk/types/tradeoff_model.rb', line 17

def discarded_raw_data
  @discarded_raw_data
end

#raw_dataArray<Hash{String => Float}> (readonly)

Returns Raw data points used to generate the scaling model. Dictionary of the two metrics, x then y.

Returns:

  • (Array<Hash{String => Float}>)

    Raw data points used to generate the scaling model. Dictionary of the two metrics, x then y.



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

def raw_data
  @raw_data
end

#scaleNewDemoApiClient::Scale (readonly)

Returns Describes the revenue range of the data whose points represent the trade off.

Returns:



11
12
13
# File 'lib/test_sdk/types/tradeoff_model.rb', line 11

def scale
  @scale
end

Class Method Details

.from_json(json_object:) ⇒ NewDemoApiClient::TradeoffModel

Deserialize a JSON object to an instance of TradeoffModel

Parameters:

  • json_object (String)

Returns:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/test_sdk/types/tradeoff_model.rb', line 51

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["scale"].nil?
    scale = nil
  else
    scale = parsed_json["scale"].to_json
    scale = NewDemoApiClient::Scale.from_json(json_object: scale)
  end
  raw_data = parsed_json["raw_data"]
  discarded_raw_data = parsed_json["discarded_raw_data"]
  areas = parsed_json["areas"]&.map do |item|
    item = item.to_json
    NewDemoApiClient::Area.from_json(json_object: item)
  end
  new(
    scale: scale,
    raw_data: raw_data,
    discarded_raw_data: discarded_raw_data,
    areas: areas,
    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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


88
89
90
91
92
93
# File 'lib/test_sdk/types/tradeoff_model.rb', line 88

def self.validate_raw(obj:)
  NewDemoApiClient::Scale.validate_raw(obj: obj.scale)
  obj.raw_data.is_a?(Array) != false || raise("Passed value for field obj.raw_data is not the expected type, validation failed.")
  obj.discarded_raw_data.is_a?(Array) != false || raise("Passed value for field obj.discarded_raw_data is not the expected type, validation failed.")
  obj.areas.is_a?(Array) != false || raise("Passed value for field obj.areas is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TradeoffModel to a JSON object

Returns:

  • (String)


78
79
80
# File 'lib/test_sdk/types/tradeoff_model.rb', line 78

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