Class: TrophyApiClient::PointsAward

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id: OMIT, awarded: OMIT, date: OMIT, total: OMIT, trigger: OMIT, boosts: OMIT, additional_properties: nil) ⇒ TrophyApiClient::PointsAward

Parameters:

  • id (String) (defaults to: OMIT)

    The ID of the trigger award

  • awarded (Integer) (defaults to: OMIT)

    The points awarded by this trigger

  • date (String) (defaults to: OMIT)

    The date these points were awarded, in ISO 8601 format.

  • total (Integer) (defaults to: OMIT)

    The user’s total points after this award occurred.

  • trigger (TrophyApiClient::PointsTrigger) (defaults to: OMIT)
  • boosts (Array<TrophyApiClient::PointsBoost>) (defaults to: OMIT)

    Array of points boosts that applied to this award.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/trophy_api_client/types/points_award.rb', line 38

def initialize(id: OMIT, awarded: OMIT, date: OMIT, total: OMIT, trigger: OMIT, boosts: OMIT,
               additional_properties: nil)
  @id = id if id != OMIT
  @awarded = awarded if awarded != OMIT
  @date = date if date != OMIT
  @total = total if total != OMIT
  @trigger = trigger if trigger != OMIT
  @boosts = boosts if boosts != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "id": id,
    "awarded": awarded,
    "date": date,
    "total": total,
    "trigger": trigger,
    "boosts": boosts
  }.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



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

def additional_properties
  @additional_properties
end

#awardedInteger (readonly)

Returns The points awarded by this trigger.

Returns:

  • (Integer)

    The points awarded by this trigger



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

def awarded
  @awarded
end

#boostsArray<TrophyApiClient::PointsBoost> (readonly)

Returns Array of points boosts that applied to this award.

Returns:



21
22
23
# File 'lib/trophy_api_client/types/points_award.rb', line 21

def boosts
  @boosts
end

#dateString (readonly)

Returns The date these points were awarded, in ISO 8601 format.

Returns:

  • (String)

    The date these points were awarded, in ISO 8601 format.



15
16
17
# File 'lib/trophy_api_client/types/points_award.rb', line 15

def date
  @date
end

#idString (readonly)

Returns The ID of the trigger award.

Returns:

  • (String)

    The ID of the trigger award



11
12
13
# File 'lib/trophy_api_client/types/points_award.rb', line 11

def id
  @id
end

#totalInteger (readonly)

Returns The user’s total points after this award occurred.

Returns:

  • (Integer)

    The user’s total points after this award occurred.



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

def total
  @total
end

#triggerTrophyApiClient::PointsTrigger (readonly)



19
20
21
# File 'lib/trophy_api_client/types/points_award.rb', line 19

def trigger
  @trigger
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::PointsAward

Deserialize a JSON object to an instance of PointsAward

Parameters:

  • json_object (String)

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/trophy_api_client/types/points_award.rb', line 63

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  id = parsed_json["id"]
  awarded = parsed_json["awarded"]
  date = parsed_json["date"]
  total = parsed_json["total"]
  if parsed_json["trigger"].nil?
    trigger = nil
  else
    trigger = parsed_json["trigger"].to_json
    trigger = TrophyApiClient::PointsTrigger.from_json(json_object: trigger)
  end
  boosts = parsed_json["boosts"]&.map do |item|
    item = item.to_json
    TrophyApiClient::PointsBoost.from_json(json_object: item)
  end
  new(
    id: id,
    awarded: awarded,
    date: date,
    total: total,
    trigger: trigger,
    boosts: boosts,
    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)


104
105
106
107
108
109
110
111
# File 'lib/trophy_api_client/types/points_award.rb', line 104

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.awarded&.is_a?(Integer) != false || raise("Passed value for field obj.awarded is not the expected type, validation failed.")
  obj.date&.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
  obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
  obj.trigger.nil? || TrophyApiClient::PointsTrigger.validate_raw(obj: obj.trigger)
  obj.boosts&.is_a?(Array) != false || raise("Passed value for field obj.boosts is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PointsAward to a JSON object

Returns:

  • (String)


94
95
96
# File 'lib/trophy_api_client/types/points_award.rb', line 94

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