Class: TrophyApiClient::AdminPointsBoost
- Inherits:
-
Object
- Object
- TrophyApiClient::AdminPointsBoost
- Defined in:
- lib/trophy_api_client/types/admin_points_boost.rb
Overview
A points boost as returned from admin endpoints.
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 (YYYY-MM-DD) or null if no end date.
-
#id ⇒ String
readonly
The UUID of the boost.
-
#multiplier ⇒ Float
readonly
The points multiplier.
-
#name ⇒ String
readonly
The name of the boost.
-
#rounding ⇒ TrophyApiClient::AdminPointsBoostRounding
readonly
How boosted points are rounded.
-
#start ⇒ String
readonly
The start date (YYYY-MM-DD).
-
#status ⇒ TrophyApiClient::AdminPointsBoostStatus
readonly
The status of the boost.
-
#user_attributes ⇒ Array<TrophyApiClient::AdminPointsBoostUserAttributesItem>
readonly
User attribute filters applied to the boost.
-
#user_id ⇒ String
readonly
The customer ID of the user the boost was created for, or null for global/attribute-filtered boosts.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ TrophyApiClient::AdminPointsBoost
Deserialize a JSON object to an instance of AdminPointsBoost.
-
.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(id:, name:, status:, start:, multiplier:, rounding:, end_: OMIT, user_id: OMIT, user_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsBoost constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of AdminPointsBoost to a JSON object.
Constructor Details
#initialize(id:, name:, status:, start:, multiplier:, rounding:, end_: OMIT, user_id: OMIT, user_attributes: OMIT, additional_properties: nil) ⇒ TrophyApiClient::AdminPointsBoost
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 53 def initialize(id:, name:, status:, start:, multiplier:, rounding:, end_: OMIT, user_id: OMIT, user_attributes: OMIT, additional_properties: nil) @id = id @name = name @status = status @start = start @end_ = end_ if end_ != OMIT @multiplier = multiplier @rounding = rounding @user_id = user_id if user_id != OMIT @user_attributes = user_attributes if user_attributes != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "name": name, "status": status, "start": start, "end": end_, "multiplier": multiplier, "rounding": rounding, "userId": user_id, "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.
33 34 35 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 33 def additional_properties @additional_properties end |
#end_ ⇒ String (readonly)
Returns The end date (YYYY-MM-DD) or null if no end date.
21 22 23 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 21 def end_ @end_ end |
#id ⇒ String (readonly)
Returns The UUID of the boost.
13 14 15 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 13 def id @id end |
#multiplier ⇒ Float (readonly)
Returns The points multiplier.
23 24 25 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 23 def multiplier @multiplier end |
#name ⇒ String (readonly)
Returns The name of the boost.
15 16 17 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 15 def name @name end |
#rounding ⇒ TrophyApiClient::AdminPointsBoostRounding (readonly)
Returns How boosted points are rounded.
25 26 27 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 25 def rounding @rounding end |
#start ⇒ String (readonly)
Returns The start date (YYYY-MM-DD).
19 20 21 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 19 def start @start end |
#status ⇒ TrophyApiClient::AdminPointsBoostStatus (readonly)
Returns The status of the boost.
17 18 19 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 17 def status @status end |
#user_attributes ⇒ Array<TrophyApiClient::AdminPointsBoostUserAttributesItem> (readonly)
Returns User attribute filters applied to the boost. Only present for non-user-specific boosts (i.e. when ‘userId` is null). Empty array if no filters are set.
31 32 33 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 31 def user_attributes @user_attributes end |
#user_id ⇒ String (readonly)
Returns The customer ID of the user the boost was created for, or null for global/attribute-filtered boosts.
28 29 30 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 28 def user_id @user_id end |
Class Method Details
.from_json(json_object:) ⇒ TrophyApiClient::AdminPointsBoost
Deserialize a JSON object to an instance of AdminPointsBoost
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 84 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"] user_id = parsed_json["userId"] user_attributes = parsed_json["userAttributes"]&.map do |item| item = item.to_json TrophyApiClient::AdminPointsBoostUserAttributesItem.from_json(json_object: item) end new( id: id, name: name, status: status, start: start, end_: end_, multiplier: multiplier, rounding: rounding, user_id: user_id, 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.
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 126 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::AdminPointsBoostStatus) != 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::AdminPointsBoostRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.") obj.user_id&.is_a?(String) != false || raise("Passed value for field obj.user_id 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 AdminPointsBoost to a JSON object
116 117 118 |
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 116 def to_json(*_args) @_field_set&.to_json end |