Class: TrophyApiClient::PointsBoost

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/types/points_boost.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, status:, start:, multiplier:, rounding:, end_: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsBoost

Parameters:

  • id (String)

    The ID of the points boost

  • name (String)

    The name of the points boost

  • status (TrophyApiClient::PointsBoostStatus)

    The status of the points boost

  • start (String)

    The start date of the points boost

  • end_ (String) (defaults to: OMIT)

    The end date of the points boost

  • multiplier (Float)

    The multiplier of the points boost

  • rounding (TrophyApiClient::PointsBoostRounding)

    The rounding method of the points boost

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/trophy_api_client/types/points_boost.rb', line 41

def initialize(id:, name:, status:, start:, multiplier:, rounding:, end_: OMIT, additional_properties: nil)
  @id = id
  @name = name
  @status = status
  @start = start
  @end_ = end_ if end_ != OMIT
  @multiplier = multiplier
  @rounding = rounding
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "name": name,
    "status": status,
    "start": start,
    "end": end_,
    "multiplier": multiplier,
    "rounding": rounding
  }.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



25
26
27
# File 'lib/trophy_api_client/types/points_boost.rb', line 25

def additional_properties
  @additional_properties
end

#end_String (readonly)

Returns The end date of the points boost.

Returns:

  • (String)

    The end date of the points boost



19
20
21
# File 'lib/trophy_api_client/types/points_boost.rb', line 19

def end_
  @end_
end

#idString (readonly)

Returns The ID of the points boost.

Returns:

  • (String)

    The ID of the points boost



11
12
13
# File 'lib/trophy_api_client/types/points_boost.rb', line 11

def id
  @id
end

#multiplierFloat (readonly)

Returns The multiplier of the points boost.

Returns:

  • (Float)

    The multiplier of the points boost



21
22
23
# File 'lib/trophy_api_client/types/points_boost.rb', line 21

def multiplier
  @multiplier
end

#nameString (readonly)

Returns The name of the points boost.

Returns:

  • (String)

    The name of the points boost



13
14
15
# File 'lib/trophy_api_client/types/points_boost.rb', line 13

def name
  @name
end

#roundingTrophyApiClient::PointsBoostRounding (readonly)

Returns The rounding method of the points boost.

Returns:



23
24
25
# File 'lib/trophy_api_client/types/points_boost.rb', line 23

def rounding
  @rounding
end

#startString (readonly)

Returns The start date of the points boost.

Returns:

  • (String)

    The start date of the points boost



17
18
19
# File 'lib/trophy_api_client/types/points_boost.rb', line 17

def start
  @start
end

#statusTrophyApiClient::PointsBoostStatus (readonly)

Returns The status of the points boost.

Returns:



15
16
17
# File 'lib/trophy_api_client/types/points_boost.rb', line 15

def status
  @status
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::PointsBoost

Deserialize a JSON object to an instance of PointsBoost

Parameters:

  • json_object (String)

Returns:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/trophy_api_client/types/points_boost.rb', line 67

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  name = parsed_json["name"]
  status = parsed_json["status"]
  start = parsed_json["start"]
  end_ = parsed_json["end"]
  multiplier = parsed_json["multiplier"]
  rounding = parsed_json["rounding"]
  new(
    id: id,
    name: name,
    status: status,
    start: start,
    end_: end_,
    multiplier: multiplier,
    rounding: rounding,
    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)


102
103
104
105
106
107
108
109
110
# File 'lib/trophy_api_client/types/points_boost.rb', line 102

def self.validate_raw(obj:)
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.status.is_a?(TrophyApiClient::PointsBoostStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
  obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
  obj.multiplier.is_a?(Float) != false || raise("Passed value for field obj.multiplier is not the expected type, validation failed.")
  obj.rounding.is_a?(TrophyApiClient::PointsBoostRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PointsBoost to a JSON object

Returns:

  • (String)


92
93
94
# File 'lib/trophy_api_client/types/points_boost.rb', line 92

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