Class: TrophyApiClient::CreatePointsBoostRequestItem
- Inherits:
-
Object
- Object
- TrophyApiClient::CreatePointsBoostRequestItem
- 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
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#end_ ⇒ String
readonly
The end date of the boost (YYYY-MM-DD).
-
#multiplier ⇒ Float
readonly
The points multiplier.
-
#name ⇒ String
readonly
The name of the boost.
-
#rounding ⇒ TrophyApiClient::CreatePointsBoostRequestItemRounding
readonly
How to round the boosted points.
-
#start ⇒ String
readonly
The start date of the boost (YYYY-MM-DD).
-
#user_attributes ⇒ Array<TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem>
readonly
User attribute filters for the boost.
-
#user_id ⇒ String
readonly
The ID of the user to create a boost for.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::CreatePointsBoostRequestItem
Deserialize a JSON object to an instance of CreatePointsBoostRequestItem.
-
.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.
Instance Method Summary collapse
- #initialize(name:, start:, multiplier:, user_id: OMIT, end_: OMIT, rounding: OMIT, user_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsBoostRequestItem constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CreatePointsBoostRequestItem to a JSON object.
Constructor Details
#initialize(name:, start:, multiplier:, user_id: OMIT, end_: OMIT, rounding: OMIT, user_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatePointsBoostRequestItem
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_properties ⇒ OpenStruct (readonly)
Returns 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.
22 23 24 |
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 22 def end_ @end_ end |
#multiplier ⇒ Float (readonly)
Returns 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 |
#name ⇒ String (readonly)
Returns 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 |
#rounding ⇒ TrophyApiClient::CreatePointsBoostRequestItemRounding (readonly)
Returns How to round the boosted points. Defaults to ‘down’.
27 28 29 |
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 27 def rounding @rounding end |
#start ⇒ String (readonly)
Returns 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_attributes ⇒ Array<TrophyApiClient::CreatePointsBoostRequestItemUserAttributesItem> (readonly)
Returns User attribute filters for the boost. Cannot be provided when ‘userId` is set.
29 30 31 |
# File 'lib/trophy_api_client/types/create_points_boost_request_item.rb', line 29 def user_attributes @user_attributes end |
#user_id ⇒ String (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.
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
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.
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
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 |