Class: TrophyApiClient::AdminPointsBoost

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:

  • id (String)

    The UUID of the boost.

  • name (String)

    The name of the boost.

  • status (TrophyApiClient::AdminPointsBoostStatus)

    The status of the boost.

  • start (String)

    The start date (YYYY-MM-DD).

  • end_ (String) (defaults to: OMIT)

    The end date (YYYY-MM-DD) or null if no end date.

  • multiplier (Float)

    The points multiplier.

  • rounding (TrophyApiClient::AdminPointsBoostRounding)

    How boosted points are rounded.

  • user_id (String) (defaults to: OMIT)

    The customer ID of the user the boost was created for, or null for global/attribute-filtered boosts.

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

    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.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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.

Returns:

  • (String)

    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

#idString (readonly)

Returns The UUID of the boost.

Returns:

  • (String)

    The UUID of the boost.



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

def id
  @id
end

#multiplierFloat (readonly)

Returns The points multiplier.

Returns:

  • (Float)

    The points multiplier.



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

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/types/admin_points_boost.rb', line 15

def name
  @name
end

#roundingTrophyApiClient::AdminPointsBoostRounding (readonly)

Returns How boosted points are rounded.

Returns:



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

def rounding
  @rounding
end

#startString (readonly)

Returns The start date (YYYY-MM-DD).

Returns:

  • (String)

    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

#statusTrophyApiClient::AdminPointsBoostStatus (readonly)

Returns The status of the boost.

Returns:



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

def status
  @status
end

#user_attributesArray<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.

Returns:



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

def user_attributes
  @user_attributes
end

#user_idString (readonly)

Returns The customer ID of the user the boost was created for, or null for global/attribute-filtered boosts.

Returns:

  • (String)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


116
117
118
# File 'lib/trophy_api_client/types/admin_points_boost.rb', line 116

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