Class: TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem

Inherits:
Object
  • Object
show all
Defined in:
lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id:, name:, start:, multiplier:, end_: OMIT, rounding: OMIT, additional_properties: nil) ⇒ TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem

Parameters:

  • user_id (String)

    The ID of the user to create a boost for.

  • name (String)

    The name of the boost.

  • start (String)

    The start date of the boost (YYYY-MM-DD).

  • end_ (String) (defaults to: OMIT)

    The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.

  • multiplier (Float)

    The points multiplier. Must be greater than 0, not equal to 1, and less than 100.

  • rounding (TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding) (defaults to: OMIT)

    How to round the boosted points. Defaults to ‘down’.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

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



26
27
28
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 26

def additional_properties
  @additional_properties
end

#end_String (readonly)

Returns The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.

Returns:

  • (String)

    The end date of the boost (YYYY-MM-DD). If null, the boost has no end date.



19
20
21
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 19

def end_
  @end_
end

#multiplierFloat (readonly)

Returns The points multiplier. Must be greater than 0, not equal to 1, and less than 100.

Returns:

  • (Float)

    The points multiplier. Must be greater than 0, not equal to 1, and less than 100.



22
23
24
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 22

def multiplier
  @multiplier
end

#nameString (readonly)

Returns The name of the boost.

Returns:

  • (String)

    The name of the boost.



15
16
17
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 15

def name
  @name
end

#roundingTrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding (readonly)

Returns How to round the boosted points. Defaults to ‘down’.

Returns:



24
25
26
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 24

def rounding
  @rounding
end

#startString (readonly)

Returns The start date of the boost (YYYY-MM-DD).

Returns:

  • (String)

    The start date of the boost (YYYY-MM-DD).



17
18
19
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 17

def start
  @start
end

#user_idString (readonly)

Returns The ID of the user to create a boost for.

Returns:

  • (String)

    The ID of the user to create a boost for.



13
14
15
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 13

def user_id
  @user_id
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItem

Deserialize a JSON object to an instance of CreatePointsBoostsRequestBoostsItem



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 66

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


99
100
101
102
103
104
105
106
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 99

def self.validate_raw(obj:)
  obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_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.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::Admin::Points::Boosts::CreatePointsBoostsRequestBoostsItemRounding) != 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 CreatePointsBoostsRequestBoostsItem to a JSON object

Returns:

  • (String)


89
90
91
# File 'lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb', line 89

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