Class: TrophyApiClient::CreatePointsBoostRequestItem

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

Overview

A points boost to create. May optionally target a specific user via ‘userId` or

filter by user attributes via `userAttributes`. These two fields are mutually
exclusive.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, start:, multiplier:, user_id: OMIT, end_: OMIT, rounding: OMIT, user_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsBoostRequestItem

Parameters:

  • user_id (String) (defaults to: OMIT)

    The ID of the user to create a boost for. Mutually exclusive with ‘userAttributes` — providing `userAttributes` when `userId` is set will result in an error. Omit for a global boost.

  • 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::CreatePointsBoostRequestItemRounding) (defaults to: OMIT)

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

  • user_attributes (Array<TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem>) (defaults to: OMIT)

    User attribute filters for the boost. Cannot be provided when ‘userId` is set.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

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



31
32
33
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 31

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.



22
23
24
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 22

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.



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

def multiplier
  @multiplier
end

#nameString (readonly)

Returns The name of the boost.

Returns:

  • (String)

    The name of the boost.



18
19
20
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 18

def name
  @name
end

#roundingTrophyApiClient::CreatePointsBoostRequestItemRounding (readonly)

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

Returns:



27
28
29
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 27

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).



20
21
22
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 20

def start
  @start
end

#user_attributesArray<TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem> (readonly)

Returns User attribute filters for the boost. Cannot be provided when ‘userId` is set.

Returns:



29
30
31
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 29

def user_attributes
  @user_attributes
end

#user_idString (readonly)

Returns The ID of the user to create a boost for. Mutually exclusive with ‘userAttributes` — providing `userAttributes` when `userId` is set will result in an error. Omit for a global boost.

Returns:

  • (String)

    The ID of the user to create a boost for. Mutually exclusive with ‘userAttributes` — providing `userAttributes` when `userId` is set will result in an error. Omit for a global boost.



16
17
18
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 16

def user_id
  @user_id
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::CreatePointsBoostRequestItem

Deserialize a JSON object to an instance of CreatePointsBoostRequestItem

Parameters:

  • json_object (String)

Returns:



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 77

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"]
  user_attributes = parsed_json["userAttributes"]&.map do |item|
    item = item.to_json
    TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem.from_json(json_object: item)
  end
  new(
    user_id: user_id,
    name: name,
    start: start,
    end_: end_,
    multiplier: multiplier,
    rounding: rounding,
    user_attributes: user_attributes,
    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)


115
116
117
118
119
120
121
122
123
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 115

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::CreatePointsBoostRequestItemRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.")
  obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreatePointsBoostRequestItem to a JSON object

Returns:

  • (String)


105
106
107
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 105

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