trophy_api_client 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/admin/attributes/client.rb +368 -0
- data/lib/trophy_api_client/admin/client.rb +21 -0
- data/lib/trophy_api_client/admin/leaderboards/client.rb +371 -0
- data/lib/trophy_api_client/admin/metrics/client.rb +366 -0
- data/lib/trophy_api_client/types/admin_attribute.rb +81 -0
- data/lib/trophy_api_client/types/admin_attribute_type.rb +9 -0
- data/lib/trophy_api_client/types/admin_leaderboard.rb +171 -0
- data/lib/trophy_api_client/types/admin_leaderboard_rank_by.rb +10 -0
- data/lib/trophy_api_client/types/admin_leaderboard_run_unit.rb +10 -0
- data/lib/trophy_api_client/types/admin_leaderboard_status.rb +11 -0
- data/lib/trophy_api_client/types/create_attribute_request_item.rb +76 -0
- data/lib/trophy_api_client/types/create_attribute_request_item_type.rb +9 -0
- data/lib/trophy_api_client/types/create_attributes_request.rb +7 -0
- data/lib/trophy_api_client/types/create_attributes_response.rb +74 -0
- data/lib/trophy_api_client/types/create_leaderboard_request_item.rb +171 -0
- data/lib/trophy_api_client/types/create_leaderboard_request_item_rank_by.rb +10 -0
- data/lib/trophy_api_client/types/create_leaderboard_request_item_run_unit.rb +11 -0
- data/lib/trophy_api_client/types/create_leaderboard_request_item_status.rb +13 -0
- data/lib/trophy_api_client/types/create_leaderboards_request.rb +7 -0
- data/lib/trophy_api_client/types/create_leaderboards_response.rb +74 -0
- data/lib/trophy_api_client/types/create_metric_request_item.rb +87 -0
- data/lib/trophy_api_client/types/create_metric_request_item_unit_type.rb +9 -0
- data/lib/trophy_api_client/types/create_metrics_request.rb +7 -0
- data/lib/trophy_api_client/types/create_metrics_response.rb +74 -0
- data/lib/trophy_api_client/types/created_metric.rb +88 -0
- data/lib/trophy_api_client/types/created_metric_unit_type.rb +9 -0
- data/lib/trophy_api_client/types/delete_attributes_response.rb +75 -0
- data/lib/trophy_api_client/types/delete_leaderboards_response.rb +75 -0
- data/lib/trophy_api_client/types/delete_metrics_response.rb +75 -0
- data/lib/trophy_api_client/types/delete_points_boosts_response.rb +2 -2
- data/lib/trophy_api_client/types/list_attributes_response.rb +7 -0
- data/lib/trophy_api_client/types/list_leaderboards_response.rb +7 -0
- data/lib/trophy_api_client/types/list_metrics_response.rb +7 -0
- data/lib/trophy_api_client/types/metric_response.rb +2 -17
- data/lib/trophy_api_client/types/update_attribute_request_item.rb +69 -0
- data/lib/trophy_api_client/types/update_attributes_request.rb +7 -0
- data/lib/trophy_api_client/types/update_attributes_response.rb +75 -0
- data/lib/trophy_api_client/types/update_leaderboard_request_item.rb +179 -0
- data/lib/trophy_api_client/types/update_leaderboard_request_item_rank_by.rb +11 -0
- data/lib/trophy_api_client/types/update_leaderboard_request_item_run_unit.rb +9 -0
- data/lib/trophy_api_client/types/update_leaderboard_request_item_status.rb +12 -0
- data/lib/trophy_api_client/types/update_leaderboards_request.rb +7 -0
- data/lib/trophy_api_client/types/update_leaderboards_response.rb +75 -0
- data/lib/trophy_api_client/types/update_metric_request_item.rb +86 -0
- data/lib/trophy_api_client/types/update_metric_request_item_unit_type.rb +9 -0
- data/lib/trophy_api_client/types/update_metrics_request.rb +7 -0
- data/lib/trophy_api_client/types/update_metrics_response.rb +75 -0
- data/lib/trophy_api_client/users/client.rb +2 -2
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +51 -12
- metadata +45 -3
- data/lib/trophy_api_client/types/metric_status.rb +0 -9
- data/lib/trophy_api_client/types/notification_type.rb +0 -11
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "create_attribute_request_item_type"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
# An attribute to create.
|
|
9
|
+
class CreateAttributeRequestItem
|
|
10
|
+
# @return [String] The attribute name.
|
|
11
|
+
attr_reader :name
|
|
12
|
+
# @return [String] The attribute key. Only alphanumeric characters, hyphens, and underscores are
|
|
13
|
+
# permitted.
|
|
14
|
+
attr_reader :key
|
|
15
|
+
# @return [TrophyApiClient::CreateAttributeRequestItemType] The attribute type.
|
|
16
|
+
attr_reader :type
|
|
17
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
18
|
+
attr_reader :additional_properties
|
|
19
|
+
# @return [Object]
|
|
20
|
+
attr_reader :_field_set
|
|
21
|
+
protected :_field_set
|
|
22
|
+
|
|
23
|
+
OMIT = Object.new
|
|
24
|
+
|
|
25
|
+
# @param name [String] The attribute name.
|
|
26
|
+
# @param key [String] The attribute key. Only alphanumeric characters, hyphens, and underscores are
|
|
27
|
+
# permitted.
|
|
28
|
+
# @param type [TrophyApiClient::CreateAttributeRequestItemType] The attribute type.
|
|
29
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
30
|
+
# @return [TrophyApiClient::CreateAttributeRequestItem]
|
|
31
|
+
def initialize(name:, key:, type:, additional_properties: nil)
|
|
32
|
+
@name = name
|
|
33
|
+
@key = key
|
|
34
|
+
@type = type
|
|
35
|
+
@additional_properties = additional_properties
|
|
36
|
+
@_field_set = { "name": name, "key": key, "type": type }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Deserialize a JSON object to an instance of CreateAttributeRequestItem
|
|
40
|
+
#
|
|
41
|
+
# @param json_object [String]
|
|
42
|
+
# @return [TrophyApiClient::CreateAttributeRequestItem]
|
|
43
|
+
def self.from_json(json_object:)
|
|
44
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
45
|
+
parsed_json = JSON.parse(json_object)
|
|
46
|
+
name = parsed_json["name"]
|
|
47
|
+
key = parsed_json["key"]
|
|
48
|
+
type = parsed_json["type"]
|
|
49
|
+
new(
|
|
50
|
+
name: name,
|
|
51
|
+
key: key,
|
|
52
|
+
type: type,
|
|
53
|
+
additional_properties: struct
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Serialize an instance of CreateAttributeRequestItem to a JSON object
|
|
58
|
+
#
|
|
59
|
+
# @return [String]
|
|
60
|
+
def to_json(*_args)
|
|
61
|
+
@_field_set&.to_json
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
65
|
+
# hash and check each fields type against the current object's property
|
|
66
|
+
# definitions.
|
|
67
|
+
#
|
|
68
|
+
# @param obj [Object]
|
|
69
|
+
# @return [Void]
|
|
70
|
+
def self.validate_raw(obj:)
|
|
71
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
72
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
73
|
+
obj.type.is_a?(TrophyApiClient::CreateAttributeRequestItemType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "admin_attribute"
|
|
4
|
+
require_relative "admin_issue"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# Response containing created attributes and any per-item issues.
|
|
10
|
+
class CreateAttributesResponse
|
|
11
|
+
# @return [Array<TrophyApiClient::AdminAttribute>] Array of successfully created attributes.
|
|
12
|
+
attr_reader :created
|
|
13
|
+
# @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during attribute creation.
|
|
14
|
+
attr_reader :issues
|
|
15
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
attr_reader :additional_properties
|
|
17
|
+
# @return [Object]
|
|
18
|
+
attr_reader :_field_set
|
|
19
|
+
protected :_field_set
|
|
20
|
+
|
|
21
|
+
OMIT = Object.new
|
|
22
|
+
|
|
23
|
+
# @param created [Array<TrophyApiClient::AdminAttribute>] Array of successfully created attributes.
|
|
24
|
+
# @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during attribute creation.
|
|
25
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
|
+
# @return [TrophyApiClient::CreateAttributesResponse]
|
|
27
|
+
def initialize(created:, issues:, additional_properties: nil)
|
|
28
|
+
@created = created
|
|
29
|
+
@issues = issues
|
|
30
|
+
@additional_properties = additional_properties
|
|
31
|
+
@_field_set = { "created": created, "issues": issues }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Deserialize a JSON object to an instance of CreateAttributesResponse
|
|
35
|
+
#
|
|
36
|
+
# @param json_object [String]
|
|
37
|
+
# @return [TrophyApiClient::CreateAttributesResponse]
|
|
38
|
+
def self.from_json(json_object:)
|
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
40
|
+
parsed_json = JSON.parse(json_object)
|
|
41
|
+
created = parsed_json["created"]&.map do |item|
|
|
42
|
+
item = item.to_json
|
|
43
|
+
TrophyApiClient::AdminAttribute.from_json(json_object: item)
|
|
44
|
+
end
|
|
45
|
+
issues = parsed_json["issues"]&.map do |item|
|
|
46
|
+
item = item.to_json
|
|
47
|
+
TrophyApiClient::AdminIssue.from_json(json_object: item)
|
|
48
|
+
end
|
|
49
|
+
new(
|
|
50
|
+
created: created,
|
|
51
|
+
issues: issues,
|
|
52
|
+
additional_properties: struct
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Serialize an instance of CreateAttributesResponse to a JSON object
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
def to_json(*_args)
|
|
60
|
+
@_field_set&.to_json
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
64
|
+
# hash and check each fields type against the current object's property
|
|
65
|
+
# definitions.
|
|
66
|
+
#
|
|
67
|
+
# @param obj [Object]
|
|
68
|
+
# @return [Void]
|
|
69
|
+
def self.validate_raw(obj:)
|
|
70
|
+
obj.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
71
|
+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "create_leaderboard_request_item_status"
|
|
4
|
+
require_relative "create_leaderboard_request_item_rank_by"
|
|
5
|
+
require_relative "create_leaderboard_request_item_run_unit"
|
|
6
|
+
require "ostruct"
|
|
7
|
+
require "json"
|
|
8
|
+
|
|
9
|
+
module TrophyApiClient
|
|
10
|
+
# A leaderboard to create.
|
|
11
|
+
class CreateLeaderboardRequestItem
|
|
12
|
+
# @return [String] The leaderboard name.
|
|
13
|
+
attr_reader :name
|
|
14
|
+
# @return [String] The leaderboard key. Only alphanumeric characters, hyphens, and underscores are
|
|
15
|
+
# permitted.
|
|
16
|
+
attr_reader :key
|
|
17
|
+
# @return [String] The leaderboard description.
|
|
18
|
+
attr_reader :description
|
|
19
|
+
# @return [TrophyApiClient::CreateLeaderboardRequestItemStatus] The initial user-facing status. Defaults to `inactive`. Use `scheduled` for
|
|
20
|
+
# leaderboards that should be active in the future and `finished` only when
|
|
21
|
+
# creating a leaderboard with an end date in the past.
|
|
22
|
+
attr_reader :status
|
|
23
|
+
# @return [TrophyApiClient::CreateLeaderboardRequestItemRankBy] What the leaderboard ranks by.
|
|
24
|
+
attr_reader :rank_by
|
|
25
|
+
# @return [String] The metric ID to rank by when `rankBy` is `metric`.
|
|
26
|
+
attr_reader :metric_id
|
|
27
|
+
# @return [String] The points system ID to rank by when `rankBy` is `points`.
|
|
28
|
+
attr_reader :points_system_id
|
|
29
|
+
# @return [Integer] The maximum number of participants. Defaults to `1000`.
|
|
30
|
+
attr_reader :max_participants
|
|
31
|
+
# @return [String] The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.
|
|
32
|
+
attr_reader :start
|
|
33
|
+
# @return [String] The optional leaderboard end date in YYYY-MM-DD format.
|
|
34
|
+
attr_reader :end_
|
|
35
|
+
# @return [Array<String>] The UUIDs of the active user attributes to break rankings down by.
|
|
36
|
+
attr_reader :breakdown_attributes
|
|
37
|
+
# @return [TrophyApiClient::CreateLeaderboardRequestItemRunUnit] How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak
|
|
38
|
+
# leaderboards cannot repeat.
|
|
39
|
+
attr_reader :run_unit
|
|
40
|
+
# @return [Integer] The number of `runUnit`s between repeats. Required when `runUnit` is set.
|
|
41
|
+
attr_reader :run_interval
|
|
42
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
43
|
+
attr_reader :additional_properties
|
|
44
|
+
# @return [Object]
|
|
45
|
+
attr_reader :_field_set
|
|
46
|
+
protected :_field_set
|
|
47
|
+
|
|
48
|
+
OMIT = Object.new
|
|
49
|
+
|
|
50
|
+
# @param name [String] The leaderboard name.
|
|
51
|
+
# @param key [String] The leaderboard key. Only alphanumeric characters, hyphens, and underscores are
|
|
52
|
+
# permitted.
|
|
53
|
+
# @param description [String] The leaderboard description.
|
|
54
|
+
# @param status [TrophyApiClient::CreateLeaderboardRequestItemStatus] The initial user-facing status. Defaults to `inactive`. Use `scheduled` for
|
|
55
|
+
# leaderboards that should be active in the future and `finished` only when
|
|
56
|
+
# creating a leaderboard with an end date in the past.
|
|
57
|
+
# @param rank_by [TrophyApiClient::CreateLeaderboardRequestItemRankBy] What the leaderboard ranks by.
|
|
58
|
+
# @param metric_id [String] The metric ID to rank by when `rankBy` is `metric`.
|
|
59
|
+
# @param points_system_id [String] The points system ID to rank by when `rankBy` is `points`.
|
|
60
|
+
# @param max_participants [Integer] The maximum number of participants. Defaults to `1000`.
|
|
61
|
+
# @param start [String] The leaderboard start date in YYYY-MM-DD format. Defaults to today when omitted.
|
|
62
|
+
# @param end_ [String] The optional leaderboard end date in YYYY-MM-DD format.
|
|
63
|
+
# @param breakdown_attributes [Array<String>] The UUIDs of the active user attributes to break rankings down by.
|
|
64
|
+
# @param run_unit [TrophyApiClient::CreateLeaderboardRequestItemRunUnit] How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak
|
|
65
|
+
# leaderboards cannot repeat.
|
|
66
|
+
# @param run_interval [Integer] The number of `runUnit`s between repeats. Required when `runUnit` is set.
|
|
67
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
68
|
+
# @return [TrophyApiClient::CreateLeaderboardRequestItem]
|
|
69
|
+
def initialize(name:, key:, rank_by:, description: OMIT, status: OMIT, metric_id: OMIT, points_system_id: OMIT,
|
|
70
|
+
max_participants: OMIT, start: OMIT, end_: OMIT, breakdown_attributes: OMIT, run_unit: OMIT, run_interval: OMIT, additional_properties: nil)
|
|
71
|
+
@name = name
|
|
72
|
+
@key = key
|
|
73
|
+
@description = description if description != OMIT
|
|
74
|
+
@status = status if status != OMIT
|
|
75
|
+
@rank_by = rank_by
|
|
76
|
+
@metric_id = metric_id if metric_id != OMIT
|
|
77
|
+
@points_system_id = points_system_id if points_system_id != OMIT
|
|
78
|
+
@max_participants = max_participants if max_participants != OMIT
|
|
79
|
+
@start = start if start != OMIT
|
|
80
|
+
@end_ = end_ if end_ != OMIT
|
|
81
|
+
@breakdown_attributes = breakdown_attributes if breakdown_attributes != OMIT
|
|
82
|
+
@run_unit = run_unit if run_unit != OMIT
|
|
83
|
+
@run_interval = run_interval if run_interval != OMIT
|
|
84
|
+
@additional_properties = additional_properties
|
|
85
|
+
@_field_set = {
|
|
86
|
+
"name": name,
|
|
87
|
+
"key": key,
|
|
88
|
+
"description": description,
|
|
89
|
+
"status": status,
|
|
90
|
+
"rankBy": rank_by,
|
|
91
|
+
"metricId": metric_id,
|
|
92
|
+
"pointsSystemId": points_system_id,
|
|
93
|
+
"maxParticipants": max_participants,
|
|
94
|
+
"start": start,
|
|
95
|
+
"end": end_,
|
|
96
|
+
"breakdownAttributes": breakdown_attributes,
|
|
97
|
+
"runUnit": run_unit,
|
|
98
|
+
"runInterval": run_interval
|
|
99
|
+
}.reject do |_k, v|
|
|
100
|
+
v == OMIT
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Deserialize a JSON object to an instance of CreateLeaderboardRequestItem
|
|
105
|
+
#
|
|
106
|
+
# @param json_object [String]
|
|
107
|
+
# @return [TrophyApiClient::CreateLeaderboardRequestItem]
|
|
108
|
+
def self.from_json(json_object:)
|
|
109
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
110
|
+
parsed_json = JSON.parse(json_object)
|
|
111
|
+
name = parsed_json["name"]
|
|
112
|
+
key = parsed_json["key"]
|
|
113
|
+
description = parsed_json["description"]
|
|
114
|
+
status = parsed_json["status"]
|
|
115
|
+
rank_by = parsed_json["rankBy"]
|
|
116
|
+
metric_id = parsed_json["metricId"]
|
|
117
|
+
points_system_id = parsed_json["pointsSystemId"]
|
|
118
|
+
max_participants = parsed_json["maxParticipants"]
|
|
119
|
+
start = parsed_json["start"]
|
|
120
|
+
end_ = parsed_json["end"]
|
|
121
|
+
breakdown_attributes = parsed_json["breakdownAttributes"]
|
|
122
|
+
run_unit = parsed_json["runUnit"]
|
|
123
|
+
run_interval = parsed_json["runInterval"]
|
|
124
|
+
new(
|
|
125
|
+
name: name,
|
|
126
|
+
key: key,
|
|
127
|
+
description: description,
|
|
128
|
+
status: status,
|
|
129
|
+
rank_by: rank_by,
|
|
130
|
+
metric_id: metric_id,
|
|
131
|
+
points_system_id: points_system_id,
|
|
132
|
+
max_participants: max_participants,
|
|
133
|
+
start: start,
|
|
134
|
+
end_: end_,
|
|
135
|
+
breakdown_attributes: breakdown_attributes,
|
|
136
|
+
run_unit: run_unit,
|
|
137
|
+
run_interval: run_interval,
|
|
138
|
+
additional_properties: struct
|
|
139
|
+
)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Serialize an instance of CreateLeaderboardRequestItem to a JSON object
|
|
143
|
+
#
|
|
144
|
+
# @return [String]
|
|
145
|
+
def to_json(*_args)
|
|
146
|
+
@_field_set&.to_json
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
150
|
+
# hash and check each fields type against the current object's property
|
|
151
|
+
# definitions.
|
|
152
|
+
#
|
|
153
|
+
# @param obj [Object]
|
|
154
|
+
# @return [Void]
|
|
155
|
+
def self.validate_raw(obj:)
|
|
156
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
157
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
158
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
159
|
+
obj.status&.is_a?(TrophyApiClient::CreateLeaderboardRequestItemStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
|
160
|
+
obj.rank_by.is_a?(TrophyApiClient::CreateLeaderboardRequestItemRankBy) != false || raise("Passed value for field obj.rank_by is not the expected type, validation failed.")
|
|
161
|
+
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
162
|
+
obj.points_system_id&.is_a?(String) != false || raise("Passed value for field obj.points_system_id is not the expected type, validation failed.")
|
|
163
|
+
obj.max_participants&.is_a?(Integer) != false || raise("Passed value for field obj.max_participants is not the expected type, validation failed.")
|
|
164
|
+
obj.start&.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
165
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
166
|
+
obj.breakdown_attributes&.is_a?(Array) != false || raise("Passed value for field obj.breakdown_attributes is not the expected type, validation failed.")
|
|
167
|
+
obj.run_unit&.is_a?(TrophyApiClient::CreateLeaderboardRequestItemRunUnit) != false || raise("Passed value for field obj.run_unit is not the expected type, validation failed.")
|
|
168
|
+
obj.run_interval&.is_a?(Integer) != false || raise("Passed value for field obj.run_interval is not the expected type, validation failed.")
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrophyApiClient
|
|
4
|
+
# How often the leaderboard repeats. Omit for a non-recurring leaderboard. Streak
|
|
5
|
+
# leaderboards cannot repeat.
|
|
6
|
+
class CreateLeaderboardRequestItemRunUnit
|
|
7
|
+
DAY = "day"
|
|
8
|
+
MONTH = "month"
|
|
9
|
+
YEAR = "year"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module TrophyApiClient
|
|
4
|
+
# The initial user-facing status. Defaults to `inactive`. Use `scheduled` for
|
|
5
|
+
# leaderboards that should be active in the future and `finished` only when
|
|
6
|
+
# creating a leaderboard with an end date in the past.
|
|
7
|
+
class CreateLeaderboardRequestItemStatus
|
|
8
|
+
INACTIVE = "inactive"
|
|
9
|
+
ACTIVE = "active"
|
|
10
|
+
SCHEDULED = "scheduled"
|
|
11
|
+
FINISHED = "finished"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "admin_leaderboard"
|
|
4
|
+
require_relative "admin_issue"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# Response containing created leaderboards and any per-item issues.
|
|
10
|
+
class CreateLeaderboardsResponse
|
|
11
|
+
# @return [Array<TrophyApiClient::AdminLeaderboard>] Array of successfully created leaderboards.
|
|
12
|
+
attr_reader :created
|
|
13
|
+
# @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during leaderboard creation.
|
|
14
|
+
attr_reader :issues
|
|
15
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
attr_reader :additional_properties
|
|
17
|
+
# @return [Object]
|
|
18
|
+
attr_reader :_field_set
|
|
19
|
+
protected :_field_set
|
|
20
|
+
|
|
21
|
+
OMIT = Object.new
|
|
22
|
+
|
|
23
|
+
# @param created [Array<TrophyApiClient::AdminLeaderboard>] Array of successfully created leaderboards.
|
|
24
|
+
# @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during leaderboard creation.
|
|
25
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
|
+
# @return [TrophyApiClient::CreateLeaderboardsResponse]
|
|
27
|
+
def initialize(created:, issues:, additional_properties: nil)
|
|
28
|
+
@created = created
|
|
29
|
+
@issues = issues
|
|
30
|
+
@additional_properties = additional_properties
|
|
31
|
+
@_field_set = { "created": created, "issues": issues }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Deserialize a JSON object to an instance of CreateLeaderboardsResponse
|
|
35
|
+
#
|
|
36
|
+
# @param json_object [String]
|
|
37
|
+
# @return [TrophyApiClient::CreateLeaderboardsResponse]
|
|
38
|
+
def self.from_json(json_object:)
|
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
40
|
+
parsed_json = JSON.parse(json_object)
|
|
41
|
+
created = parsed_json["created"]&.map do |item|
|
|
42
|
+
item = item.to_json
|
|
43
|
+
TrophyApiClient::AdminLeaderboard.from_json(json_object: item)
|
|
44
|
+
end
|
|
45
|
+
issues = parsed_json["issues"]&.map do |item|
|
|
46
|
+
item = item.to_json
|
|
47
|
+
TrophyApiClient::AdminIssue.from_json(json_object: item)
|
|
48
|
+
end
|
|
49
|
+
new(
|
|
50
|
+
created: created,
|
|
51
|
+
issues: issues,
|
|
52
|
+
additional_properties: struct
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Serialize an instance of CreateLeaderboardsResponse to a JSON object
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
def to_json(*_args)
|
|
60
|
+
@_field_set&.to_json
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
64
|
+
# hash and check each fields type against the current object's property
|
|
65
|
+
# definitions.
|
|
66
|
+
#
|
|
67
|
+
# @param obj [Object]
|
|
68
|
+
# @return [Void]
|
|
69
|
+
def self.validate_raw(obj:)
|
|
70
|
+
obj.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
71
|
+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "create_metric_request_item_unit_type"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
# A metric to create.
|
|
9
|
+
class CreateMetricRequestItem
|
|
10
|
+
# @return [String] The metric name.
|
|
11
|
+
attr_reader :name
|
|
12
|
+
# @return [String] The metric key. Only alphanumeric characters, hyphens, and underscores are
|
|
13
|
+
# permitted.
|
|
14
|
+
attr_reader :key
|
|
15
|
+
# @return [TrophyApiClient::CreateMetricRequestItemUnitType] The metric unit type. Defaults to `number`.
|
|
16
|
+
attr_reader :unit_type
|
|
17
|
+
# @return [String] For `unitType: currency`, this must be a supported `MetricCurrency` code such as
|
|
18
|
+
# `USD`. For `number`, this is an optional freeform unit label.
|
|
19
|
+
attr_reader :units
|
|
20
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
21
|
+
attr_reader :additional_properties
|
|
22
|
+
# @return [Object]
|
|
23
|
+
attr_reader :_field_set
|
|
24
|
+
protected :_field_set
|
|
25
|
+
|
|
26
|
+
OMIT = Object.new
|
|
27
|
+
|
|
28
|
+
# @param name [String] The metric name.
|
|
29
|
+
# @param key [String] The metric key. Only alphanumeric characters, hyphens, and underscores are
|
|
30
|
+
# permitted.
|
|
31
|
+
# @param unit_type [TrophyApiClient::CreateMetricRequestItemUnitType] The metric unit type. Defaults to `number`.
|
|
32
|
+
# @param units [String] For `unitType: currency`, this must be a supported `MetricCurrency` code such as
|
|
33
|
+
# `USD`. For `number`, this is an optional freeform unit label.
|
|
34
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
35
|
+
# @return [TrophyApiClient::CreateMetricRequestItem]
|
|
36
|
+
def initialize(name:, key:, unit_type: OMIT, units: OMIT, additional_properties: nil)
|
|
37
|
+
@name = name
|
|
38
|
+
@key = key
|
|
39
|
+
@unit_type = unit_type if unit_type != OMIT
|
|
40
|
+
@units = units if units != OMIT
|
|
41
|
+
@additional_properties = additional_properties
|
|
42
|
+
@_field_set = { "name": name, "key": key, "unitType": unit_type, "units": units }.reject do |_k, v|
|
|
43
|
+
v == OMIT
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Deserialize a JSON object to an instance of CreateMetricRequestItem
|
|
48
|
+
#
|
|
49
|
+
# @param json_object [String]
|
|
50
|
+
# @return [TrophyApiClient::CreateMetricRequestItem]
|
|
51
|
+
def self.from_json(json_object:)
|
|
52
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
53
|
+
parsed_json = JSON.parse(json_object)
|
|
54
|
+
name = parsed_json["name"]
|
|
55
|
+
key = parsed_json["key"]
|
|
56
|
+
unit_type = parsed_json["unitType"]
|
|
57
|
+
units = parsed_json["units"]
|
|
58
|
+
new(
|
|
59
|
+
name: name,
|
|
60
|
+
key: key,
|
|
61
|
+
unit_type: unit_type,
|
|
62
|
+
units: units,
|
|
63
|
+
additional_properties: struct
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Serialize an instance of CreateMetricRequestItem to a JSON object
|
|
68
|
+
#
|
|
69
|
+
# @return [String]
|
|
70
|
+
def to_json(*_args)
|
|
71
|
+
@_field_set&.to_json
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
75
|
+
# hash and check each fields type against the current object's property
|
|
76
|
+
# definitions.
|
|
77
|
+
#
|
|
78
|
+
# @param obj [Object]
|
|
79
|
+
# @return [Void]
|
|
80
|
+
def self.validate_raw(obj:)
|
|
81
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
82
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
83
|
+
obj.unit_type&.is_a?(TrophyApiClient::CreateMetricRequestItemUnitType) != false || raise("Passed value for field obj.unit_type is not the expected type, validation failed.")
|
|
84
|
+
obj.units&.is_a?(String) != false || raise("Passed value for field obj.units is not the expected type, validation failed.")
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "created_metric"
|
|
4
|
+
require_relative "admin_issue"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# Response containing created metrics and any per-item issues.
|
|
10
|
+
class CreateMetricsResponse
|
|
11
|
+
# @return [Array<TrophyApiClient::CreatedMetric>] Array of successfully created metrics.
|
|
12
|
+
attr_reader :created
|
|
13
|
+
# @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during metric creation.
|
|
14
|
+
attr_reader :issues
|
|
15
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
16
|
+
attr_reader :additional_properties
|
|
17
|
+
# @return [Object]
|
|
18
|
+
attr_reader :_field_set
|
|
19
|
+
protected :_field_set
|
|
20
|
+
|
|
21
|
+
OMIT = Object.new
|
|
22
|
+
|
|
23
|
+
# @param created [Array<TrophyApiClient::CreatedMetric>] Array of successfully created metrics.
|
|
24
|
+
# @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during metric creation.
|
|
25
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
26
|
+
# @return [TrophyApiClient::CreateMetricsResponse]
|
|
27
|
+
def initialize(created:, issues:, additional_properties: nil)
|
|
28
|
+
@created = created
|
|
29
|
+
@issues = issues
|
|
30
|
+
@additional_properties = additional_properties
|
|
31
|
+
@_field_set = { "created": created, "issues": issues }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Deserialize a JSON object to an instance of CreateMetricsResponse
|
|
35
|
+
#
|
|
36
|
+
# @param json_object [String]
|
|
37
|
+
# @return [TrophyApiClient::CreateMetricsResponse]
|
|
38
|
+
def self.from_json(json_object:)
|
|
39
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
40
|
+
parsed_json = JSON.parse(json_object)
|
|
41
|
+
created = parsed_json["created"]&.map do |item|
|
|
42
|
+
item = item.to_json
|
|
43
|
+
TrophyApiClient::CreatedMetric.from_json(json_object: item)
|
|
44
|
+
end
|
|
45
|
+
issues = parsed_json["issues"]&.map do |item|
|
|
46
|
+
item = item.to_json
|
|
47
|
+
TrophyApiClient::AdminIssue.from_json(json_object: item)
|
|
48
|
+
end
|
|
49
|
+
new(
|
|
50
|
+
created: created,
|
|
51
|
+
issues: issues,
|
|
52
|
+
additional_properties: struct
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Serialize an instance of CreateMetricsResponse to a JSON object
|
|
57
|
+
#
|
|
58
|
+
# @return [String]
|
|
59
|
+
def to_json(*_args)
|
|
60
|
+
@_field_set&.to_json
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
64
|
+
# hash and check each fields type against the current object's property
|
|
65
|
+
# definitions.
|
|
66
|
+
#
|
|
67
|
+
# @param obj [Object]
|
|
68
|
+
# @return [Void]
|
|
69
|
+
def self.validate_raw(obj:)
|
|
70
|
+
obj.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
71
|
+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|