Class: TrophyApiClient::CreatedAdminPointsSystem

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

Overview

A points system returned from the creation endpoint. Extends AdminPointsSystem

with optional sub-entity arrays that are present when those sub-entities were
included in the creation request.

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, key:, description:, status:, levels: OMIT, boosts: OMIT, triggers: OMIT, badge: OMIT, max_points: OMIT, additional_properties: nil) ⇒ TrophyApiClient::CreatedAdminPointsSystem

Parameters:

  • levels (Array<TrophyApiClient::AdminPointsLevel>) (defaults to: OMIT)

    Levels created alongside the system. Present when levels were provided in the request.

  • boosts (Array<TrophyApiClient::AdminPointsBoost>) (defaults to: OMIT)

    Boosts created alongside the system. Present when boosts were provided in the request.

  • triggers (Array<TrophyApiClient::AdminPointsTrigger>) (defaults to: OMIT)

    Triggers created alongside the system. Present when triggers were provided in the request.

  • id (String)

    The UUID of the points system.

  • name (String)

    The points system name.

  • key (String)

    The points system key.

  • description (String)

    The points system description.

  • status (TrophyApiClient::AdminPointsSystemStatus)

    The points system status.

  • badge (TrophyApiClient::AdminPointsSystemBadge) (defaults to: OMIT)

    The badge for the points system.

  • max_points (Integer) (defaults to: OMIT)

    The maximum points a user can earn.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



62
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/created_admin_points_system.rb', line 62

def initialize(id:, name:, key:, description:, status:, levels: OMIT, boosts: OMIT, triggers: OMIT, badge: OMIT,
               max_points: OMIT, additional_properties: nil)
  @levels = levels if levels != OMIT
  @boosts = boosts if boosts != OMIT
  @triggers = triggers if triggers != OMIT
  @id = id
  @name = name
  @key = key
  @description = description
  @status = status
  @badge = badge if badge != OMIT
  @max_points = max_points if max_points != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "levels": levels,
    "boosts": boosts,
    "triggers": triggers,
    "id": id,
    "name": name,
    "key": key,
    "description": description,
    "status": status,
    "badge": badge,
    "maxPoints": max_points
  }.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



40
41
42
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 40

def additional_properties
  @additional_properties
end

#badgeTrophyApiClient::AdminPointsSystemBadge (readonly)

Returns The badge for the points system.

Returns:



36
37
38
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 36

def badge
  @badge
end

#boostsArray<TrophyApiClient::AdminPointsBoost> (readonly)

Returns Boosts created alongside the system. Present when boosts were provided in the request.

Returns:



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

def boosts
  @boosts
end

#descriptionString (readonly)

Returns The points system description.

Returns:

  • (String)

    The points system description.



32
33
34
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 32

def description
  @description
end

#idString (readonly)

Returns The UUID of the points system.

Returns:

  • (String)

    The UUID of the points system.



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

def id
  @id
end

#keyString (readonly)

Returns The points system key.

Returns:

  • (String)

    The points system key.



30
31
32
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 30

def key
  @key
end

#levelsArray<TrophyApiClient::AdminPointsLevel> (readonly)

Returns Levels created alongside the system. Present when levels were provided in the request.

Returns:



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

def levels
  @levels
end

#max_pointsInteger (readonly)

Returns The maximum points a user can earn.

Returns:

  • (Integer)

    The maximum points a user can earn.



38
39
40
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 38

def max_points
  @max_points
end

#nameString (readonly)

Returns The points system name.

Returns:

  • (String)

    The points system name.



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

def name
  @name
end

#statusTrophyApiClient::AdminPointsSystemStatus (readonly)

Returns The points system status.

Returns:



34
35
36
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 34

def status
  @status
end

#triggersArray<TrophyApiClient::AdminPointsTrigger> (readonly)

Returns Triggers created alongside the system. Present when triggers were provided in the request.

Returns:



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

def triggers
  @triggers
end

Class Method Details

.from_json(json_object:) ⇒ TrophyApiClient::CreatedAdminPointsSystem

Deserialize a JSON object to an instance of CreatedAdminPointsSystem

Parameters:

  • json_object (String)

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 95

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  levels = parsed_json["levels"]&.map do |item|
    item = item.to_json
    TrophyApiClient::AdminPointsLevel.from_json(json_object: item)
  end
  boosts = parsed_json["boosts"]&.map do |item|
    item = item.to_json
    TrophyApiClient::AdminPointsBoost.from_json(json_object: item)
  end
  triggers = parsed_json["triggers"]&.map do |item|
    item = item.to_json
    TrophyApiClient::AdminPointsTrigger.from_json(json_object: item)
  end
  id = parsed_json["id"]
  name = parsed_json["name"]
  key = parsed_json["key"]
  description = parsed_json["description"]
  status = parsed_json["status"]
  if parsed_json["badge"].nil?
    badge = nil
  else
    badge = parsed_json["badge"].to_json
    badge = TrophyApiClient::AdminPointsSystemBadge.from_json(json_object: badge)
  end
  max_points = parsed_json["maxPoints"]
  new(
    levels: levels,
    boosts: boosts,
    triggers: triggers,
    id: id,
    name: name,
    key: key,
    description: description,
    status: status,
    badge: badge,
    max_points: max_points,
    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)


150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 150

def self.validate_raw(obj:)
  obj.levels&.is_a?(Array) != false || raise("Passed value for field obj.levels is not the expected type, validation failed.")
  obj.boosts&.is_a?(Array) != false || raise("Passed value for field obj.boosts is not the expected type, validation failed.")
  obj.triggers&.is_a?(Array) != false || raise("Passed value for field obj.triggers is not the expected type, validation failed.")
  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.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
  obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.status.is_a?(TrophyApiClient::AdminPointsSystemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
  obj.badge.nil? || TrophyApiClient::AdminPointsSystemBadge.validate_raw(obj: obj.badge)
  obj.max_points&.is_a?(Integer) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreatedAdminPointsSystem to a JSON object

Returns:

  • (String)


140
141
142
# File 'lib/trophy_api_client/types/created_admin_points_system.rb', line 140

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