Class: TrophyApiClient::CreatedPointsBoost

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

Overview

A successfully created points boost returned from the create endpoint.

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:, user_id:, end_: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatedPointsBoost

Parameters:

  • The UUID of the created boost.

  • The name of the boost.

  • The status of the boost.

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

  • (defaults to: OMIT)

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

  • The points multiplier.

  • How boosted points are rounded.

  • The customer ID of the user the boost was created for.

  • (defaults to: nil)

    Additional properties unmapped to the current class definition



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 45

def initialize(id:, name:, status:, start:, multiplier:, rounding:, user_id:, end_: 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
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "name": name,
    "status": status,
    "start": start,
    "end": end_,
    "multiplier": multiplier,
    "rounding": rounding,
    "userId": user_id
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • Additional properties unmapped to the current class definition



28
29
30
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 28

def additional_properties
  @additional_properties
end

#end_String (readonly)

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

Returns:

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



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

def end_
  @end_
end

#idString (readonly)

Returns The UUID of the created boost.

Returns:

  • The UUID of the created boost.



12
13
14
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 12

def id
  @id
end

#multiplierFloat (readonly)

Returns The points multiplier.

Returns:

  • The points multiplier.



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

def multiplier
  @multiplier
end

#nameString (readonly)

Returns The name of the boost.

Returns:

  • The name of the boost.



14
15
16
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 14

def name
  @name
end

#roundingTrophyApiClient::CreatedPointsBoostRounding (readonly)

Returns How boosted points are rounded.

Returns:

  • How boosted points are rounded.



24
25
26
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 24

def rounding
  @rounding
end

#startString (readonly)

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

Returns:

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



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

def start
  @start
end

#statusTrophyApiClient::CreatedPointsBoostStatus (readonly)

Returns The status of the boost.

Returns:

  • The status of the boost.



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

def status
  @status
end

#user_idString (readonly)

Returns The customer ID of the user the boost was created for.

Returns:

  • The customer ID of the user the boost was created for.



26
27
28
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 26

def user_id
  @user_id
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::CreatedPointsBoost

Deserialize a JSON object to an instance of CreatedPointsBoost

Parameters:

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 74

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"]
  new(
    id: id,
    name: name,
    status: status,
    start: start,
    end_: end_,
    multiplier: multiplier,
    rounding: rounding,
    user_id: user_id,
    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:

Returns:



111
112
113
114
115
116
117
118
119
120
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 111

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::CreatedPointsBoostStatus) != 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::CreatedPointsBoostRounding) != 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.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreatedPointsBoost to a JSON object

Returns:



101
102
103
# File 'lib/trophy_api_client/types/created_points_boost.rb', line 101

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