trophy_api_client 1.0.42 → 1.1.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/client.rb +7 -0
- data/lib/trophy_api_client/admin/points/boosts/client.rb +247 -0
- data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item.rb +111 -0
- data/lib/trophy_api_client/admin/points/boosts/types/create_points_boosts_request_boosts_item_rounding.rb +16 -0
- data/lib/trophy_api_client/admin/points/client.rb +32 -0
- data/lib/trophy_api_client/leaderboards/client.rb +20 -12
- data/lib/trophy_api_client/points/client.rb +85 -2
- data/lib/trophy_api_client/types/archive_points_boosts_response.rb +56 -0
- data/lib/trophy_api_client/types/create_points_boosts_response.rb +75 -0
- data/lib/trophy_api_client/types/created_points_boost.rb +122 -0
- data/lib/trophy_api_client/types/created_points_boost_rounding.rb +10 -0
- data/lib/trophy_api_client/types/created_points_boost_status.rb +10 -0
- data/lib/trophy_api_client/types/metric_event_points_response.rb +10 -9
- data/lib/trophy_api_client/types/points_award.rb +15 -2
- data/lib/trophy_api_client/types/points_boost.rb +112 -0
- data/lib/trophy_api_client/types/points_boost_rounding.rb +10 -0
- data/lib/trophy_api_client/types/points_boost_status.rb +10 -0
- data/lib/trophy_api_client/types/points_boost_webhook_payload.rb +149 -0
- data/lib/trophy_api_client/types/points_boost_webhook_payload_rounding.rb +10 -0
- data/lib/trophy_api_client/types/points_boost_webhook_payload_status.rb +9 -0
- data/lib/trophy_api_client/types/webhooks_points_boost_finished_payload.rb +79 -0
- data/lib/trophy_api_client/types/webhooks_points_boost_started_payload.rb +79 -0
- data/lib/trophy_api_client/types/webhooks_points_changed_payload.rb +5 -5
- data/lib/trophy_api_client/users/client.rb +81 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +15 -0
- metadata +18 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# Response containing the count of archived points boosts.
|
|
8
|
+
class ArchivePointsBoostsResponse
|
|
9
|
+
# @return [Integer] The number of boosts that were archived.
|
|
10
|
+
attr_reader :archived_count
|
|
11
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
12
|
+
attr_reader :additional_properties
|
|
13
|
+
# @return [Object]
|
|
14
|
+
attr_reader :_field_set
|
|
15
|
+
protected :_field_set
|
|
16
|
+
|
|
17
|
+
OMIT = Object.new
|
|
18
|
+
|
|
19
|
+
# @param archived_count [Integer] The number of boosts that were archived.
|
|
20
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
21
|
+
# @return [TrophyApiClient::ArchivePointsBoostsResponse]
|
|
22
|
+
def initialize(archived_count:, additional_properties: nil)
|
|
23
|
+
@archived_count = archived_count
|
|
24
|
+
@additional_properties = additional_properties
|
|
25
|
+
@_field_set = { "archivedCount": archived_count }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Deserialize a JSON object to an instance of ArchivePointsBoostsResponse
|
|
29
|
+
#
|
|
30
|
+
# @param json_object [String]
|
|
31
|
+
# @return [TrophyApiClient::ArchivePointsBoostsResponse]
|
|
32
|
+
def self.from_json(json_object:)
|
|
33
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
34
|
+
parsed_json = JSON.parse(json_object)
|
|
35
|
+
archived_count = parsed_json["archivedCount"]
|
|
36
|
+
new(archived_count: archived_count, additional_properties: struct)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Serialize an instance of ArchivePointsBoostsResponse to a JSON object
|
|
40
|
+
#
|
|
41
|
+
# @return [String]
|
|
42
|
+
def to_json(*_args)
|
|
43
|
+
@_field_set&.to_json
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
47
|
+
# hash and check each fields type against the current object's property
|
|
48
|
+
# definitions.
|
|
49
|
+
#
|
|
50
|
+
# @param obj [Object]
|
|
51
|
+
# @return [Void]
|
|
52
|
+
def self.validate_raw(obj:)
|
|
53
|
+
obj.archived_count.is_a?(Integer) != false || raise("Passed value for field obj.archived_count is not the expected type, validation failed.")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "created_points_boost"
|
|
4
|
+
require_relative "bulk_insert_issue"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# Response containing created boosts and any issues encountered while creating
|
|
10
|
+
# points boosts.
|
|
11
|
+
class CreatePointsBoostsResponse
|
|
12
|
+
# @return [Array<TrophyApiClient::CreatedPointsBoost>] Array of successfully created boosts.
|
|
13
|
+
attr_reader :created
|
|
14
|
+
# @return [Array<TrophyApiClient::BulkInsertIssue>] Array of issues encountered during boost creation.
|
|
15
|
+
attr_reader :issues
|
|
16
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
17
|
+
attr_reader :additional_properties
|
|
18
|
+
# @return [Object]
|
|
19
|
+
attr_reader :_field_set
|
|
20
|
+
protected :_field_set
|
|
21
|
+
|
|
22
|
+
OMIT = Object.new
|
|
23
|
+
|
|
24
|
+
# @param created [Array<TrophyApiClient::CreatedPointsBoost>] Array of successfully created boosts.
|
|
25
|
+
# @param issues [Array<TrophyApiClient::BulkInsertIssue>] Array of issues encountered during boost creation.
|
|
26
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
27
|
+
# @return [TrophyApiClient::CreatePointsBoostsResponse]
|
|
28
|
+
def initialize(created:, issues:, additional_properties: nil)
|
|
29
|
+
@created = created
|
|
30
|
+
@issues = issues
|
|
31
|
+
@additional_properties = additional_properties
|
|
32
|
+
@_field_set = { "created": created, "issues": issues }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Deserialize a JSON object to an instance of CreatePointsBoostsResponse
|
|
36
|
+
#
|
|
37
|
+
# @param json_object [String]
|
|
38
|
+
# @return [TrophyApiClient::CreatePointsBoostsResponse]
|
|
39
|
+
def self.from_json(json_object:)
|
|
40
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
41
|
+
parsed_json = JSON.parse(json_object)
|
|
42
|
+
created = parsed_json["created"]&.map do |item|
|
|
43
|
+
item = item.to_json
|
|
44
|
+
TrophyApiClient::CreatedPointsBoost.from_json(json_object: item)
|
|
45
|
+
end
|
|
46
|
+
issues = parsed_json["issues"]&.map do |item|
|
|
47
|
+
item = item.to_json
|
|
48
|
+
TrophyApiClient::BulkInsertIssue.from_json(json_object: item)
|
|
49
|
+
end
|
|
50
|
+
new(
|
|
51
|
+
created: created,
|
|
52
|
+
issues: issues,
|
|
53
|
+
additional_properties: struct
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Serialize an instance of CreatePointsBoostsResponse 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.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
72
|
+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "created_points_boost_status"
|
|
4
|
+
require_relative "created_points_boost_rounding"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
# A successfully created points boost returned from the create endpoint.
|
|
10
|
+
class CreatedPointsBoost
|
|
11
|
+
# @return [String] The UUID of the created boost.
|
|
12
|
+
attr_reader :id
|
|
13
|
+
# @return [String] The name of the boost.
|
|
14
|
+
attr_reader :name
|
|
15
|
+
# @return [TrophyApiClient::CreatedPointsBoostStatus] The status of the boost.
|
|
16
|
+
attr_reader :status
|
|
17
|
+
# @return [String] The start date (YYYY-MM-DD).
|
|
18
|
+
attr_reader :start
|
|
19
|
+
# @return [String] The end date (YYYY-MM-DD) or null if no end date.
|
|
20
|
+
attr_reader :end_
|
|
21
|
+
# @return [Float] The points multiplier.
|
|
22
|
+
attr_reader :multiplier
|
|
23
|
+
# @return [TrophyApiClient::CreatedPointsBoostRounding] How boosted points are rounded.
|
|
24
|
+
attr_reader :rounding
|
|
25
|
+
# @return [String] The customer ID of the user the boost was created for.
|
|
26
|
+
attr_reader :user_id
|
|
27
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
28
|
+
attr_reader :additional_properties
|
|
29
|
+
# @return [Object]
|
|
30
|
+
attr_reader :_field_set
|
|
31
|
+
protected :_field_set
|
|
32
|
+
|
|
33
|
+
OMIT = Object.new
|
|
34
|
+
|
|
35
|
+
# @param id [String] The UUID of the created boost.
|
|
36
|
+
# @param name [String] The name of the boost.
|
|
37
|
+
# @param status [TrophyApiClient::CreatedPointsBoostStatus] The status of the boost.
|
|
38
|
+
# @param start [String] The start date (YYYY-MM-DD).
|
|
39
|
+
# @param end_ [String] The end date (YYYY-MM-DD) or null if no end date.
|
|
40
|
+
# @param multiplier [Float] The points multiplier.
|
|
41
|
+
# @param rounding [TrophyApiClient::CreatedPointsBoostRounding] How boosted points are rounded.
|
|
42
|
+
# @param user_id [String] The customer ID of the user the boost was created for.
|
|
43
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
44
|
+
# @return [TrophyApiClient::CreatedPointsBoost]
|
|
45
|
+
def initialize(id:, name:, status:, start:, multiplier:, rounding:, user_id:, end_: OMIT,
|
|
46
|
+
additional_properties: nil)
|
|
47
|
+
@id = id
|
|
48
|
+
@name = name
|
|
49
|
+
@status = status
|
|
50
|
+
@start = start
|
|
51
|
+
@end_ = end_ if end_ != OMIT
|
|
52
|
+
@multiplier = multiplier
|
|
53
|
+
@rounding = rounding
|
|
54
|
+
@user_id = user_id
|
|
55
|
+
@additional_properties = additional_properties
|
|
56
|
+
@_field_set = {
|
|
57
|
+
"id": id,
|
|
58
|
+
"name": name,
|
|
59
|
+
"status": status,
|
|
60
|
+
"start": start,
|
|
61
|
+
"end": end_,
|
|
62
|
+
"multiplier": multiplier,
|
|
63
|
+
"rounding": rounding,
|
|
64
|
+
"userId": user_id
|
|
65
|
+
}.reject do |_k, v|
|
|
66
|
+
v == OMIT
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Deserialize a JSON object to an instance of CreatedPointsBoost
|
|
71
|
+
#
|
|
72
|
+
# @param json_object [String]
|
|
73
|
+
# @return [TrophyApiClient::CreatedPointsBoost]
|
|
74
|
+
def self.from_json(json_object:)
|
|
75
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
76
|
+
parsed_json = JSON.parse(json_object)
|
|
77
|
+
id = parsed_json["id"]
|
|
78
|
+
name = parsed_json["name"]
|
|
79
|
+
status = parsed_json["status"]
|
|
80
|
+
start = parsed_json["start"]
|
|
81
|
+
end_ = parsed_json["end"]
|
|
82
|
+
multiplier = parsed_json["multiplier"]
|
|
83
|
+
rounding = parsed_json["rounding"]
|
|
84
|
+
user_id = parsed_json["userId"]
|
|
85
|
+
new(
|
|
86
|
+
id: id,
|
|
87
|
+
name: name,
|
|
88
|
+
status: status,
|
|
89
|
+
start: start,
|
|
90
|
+
end_: end_,
|
|
91
|
+
multiplier: multiplier,
|
|
92
|
+
rounding: rounding,
|
|
93
|
+
user_id: user_id,
|
|
94
|
+
additional_properties: struct
|
|
95
|
+
)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Serialize an instance of CreatedPointsBoost to a JSON object
|
|
99
|
+
#
|
|
100
|
+
# @return [String]
|
|
101
|
+
def to_json(*_args)
|
|
102
|
+
@_field_set&.to_json
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
106
|
+
# hash and check each fields type against the current object's property
|
|
107
|
+
# definitions.
|
|
108
|
+
#
|
|
109
|
+
# @param obj [Object]
|
|
110
|
+
# @return [Void]
|
|
111
|
+
def self.validate_raw(obj:)
|
|
112
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
113
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
114
|
+
obj.status.is_a?(TrophyApiClient::CreatedPointsBoostStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
|
115
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
116
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
117
|
+
obj.multiplier.is_a?(Float) != false || raise("Passed value for field obj.multiplier is not the expected type, validation failed.")
|
|
118
|
+
obj.rounding.is_a?(TrophyApiClient::CreatedPointsBoostRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.")
|
|
119
|
+
obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -5,9 +5,8 @@ require "ostruct"
|
|
|
5
5
|
require "json"
|
|
6
6
|
|
|
7
7
|
module TrophyApiClient
|
|
8
|
+
# Points system response for metric events.
|
|
8
9
|
class MetricEventPointsResponse
|
|
9
|
-
# @return [Integer] The points added by this event.
|
|
10
|
-
attr_reader :added
|
|
11
10
|
# @return [String] The ID of the points system
|
|
12
11
|
attr_reader :id
|
|
13
12
|
# @return [String] The key of the points system
|
|
@@ -22,6 +21,8 @@ module TrophyApiClient
|
|
|
22
21
|
attr_reader :max_points
|
|
23
22
|
# @return [Integer] The user's total points
|
|
24
23
|
attr_reader :total
|
|
24
|
+
# @return [Integer] The points added by this event.
|
|
25
|
+
attr_reader :added
|
|
25
26
|
# @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
26
27
|
attr_reader :awards
|
|
27
28
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
@@ -32,7 +33,6 @@ module TrophyApiClient
|
|
|
32
33
|
|
|
33
34
|
OMIT = Object.new
|
|
34
35
|
|
|
35
|
-
# @param added [Integer] The points added by this event.
|
|
36
36
|
# @param id [String] The ID of the points system
|
|
37
37
|
# @param key [String] The key of the points system
|
|
38
38
|
# @param name [String] The name of the points system
|
|
@@ -40,12 +40,12 @@ module TrophyApiClient
|
|
|
40
40
|
# @param badge_url [String] The URL of the badge image for the points system
|
|
41
41
|
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
42
42
|
# @param total [Integer] The user's total points
|
|
43
|
+
# @param added [Integer] The points added by this event.
|
|
43
44
|
# @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
|
|
44
45
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
45
46
|
# @return [TrophyApiClient::MetricEventPointsResponse]
|
|
46
|
-
def initialize(
|
|
47
|
+
def initialize(id:, key:, name:, total:, added:, awards:, description: OMIT, badge_url: OMIT, max_points: OMIT,
|
|
47
48
|
additional_properties: nil)
|
|
48
|
-
@added = added
|
|
49
49
|
@id = id
|
|
50
50
|
@key = key
|
|
51
51
|
@name = name
|
|
@@ -53,10 +53,10 @@ module TrophyApiClient
|
|
|
53
53
|
@badge_url = badge_url if badge_url != OMIT
|
|
54
54
|
@max_points = max_points if max_points != OMIT
|
|
55
55
|
@total = total
|
|
56
|
+
@added = added
|
|
56
57
|
@awards = awards
|
|
57
58
|
@additional_properties = additional_properties
|
|
58
59
|
@_field_set = {
|
|
59
|
-
"added": added,
|
|
60
60
|
"id": id,
|
|
61
61
|
"key": key,
|
|
62
62
|
"name": name,
|
|
@@ -64,6 +64,7 @@ module TrophyApiClient
|
|
|
64
64
|
"badgeUrl": badge_url,
|
|
65
65
|
"maxPoints": max_points,
|
|
66
66
|
"total": total,
|
|
67
|
+
"added": added,
|
|
67
68
|
"awards": awards
|
|
68
69
|
}.reject do |_k, v|
|
|
69
70
|
v == OMIT
|
|
@@ -77,7 +78,6 @@ module TrophyApiClient
|
|
|
77
78
|
def self.from_json(json_object:)
|
|
78
79
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
79
80
|
parsed_json = JSON.parse(json_object)
|
|
80
|
-
added = parsed_json["added"]
|
|
81
81
|
id = parsed_json["id"]
|
|
82
82
|
key = parsed_json["key"]
|
|
83
83
|
name = parsed_json["name"]
|
|
@@ -85,12 +85,12 @@ module TrophyApiClient
|
|
|
85
85
|
badge_url = parsed_json["badgeUrl"]
|
|
86
86
|
max_points = parsed_json["maxPoints"]
|
|
87
87
|
total = parsed_json["total"]
|
|
88
|
+
added = parsed_json["added"]
|
|
88
89
|
awards = parsed_json["awards"]&.map do |item|
|
|
89
90
|
item = item.to_json
|
|
90
91
|
TrophyApiClient::PointsAward.from_json(json_object: item)
|
|
91
92
|
end
|
|
92
93
|
new(
|
|
93
|
-
added: added,
|
|
94
94
|
id: id,
|
|
95
95
|
key: key,
|
|
96
96
|
name: name,
|
|
@@ -98,6 +98,7 @@ module TrophyApiClient
|
|
|
98
98
|
badge_url: badge_url,
|
|
99
99
|
max_points: max_points,
|
|
100
100
|
total: total,
|
|
101
|
+
added: added,
|
|
101
102
|
awards: awards,
|
|
102
103
|
additional_properties: struct
|
|
103
104
|
)
|
|
@@ -117,7 +118,6 @@ module TrophyApiClient
|
|
|
117
118
|
# @param obj [Object]
|
|
118
119
|
# @return [Void]
|
|
119
120
|
def self.validate_raw(obj:)
|
|
120
|
-
obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
|
121
121
|
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
122
122
|
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
123
123
|
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
@@ -125,6 +125,7 @@ module TrophyApiClient
|
|
|
125
125
|
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
126
126
|
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
127
127
|
obj.total.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
128
|
+
obj.added.is_a?(Integer) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
|
|
128
129
|
obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
|
|
129
130
|
end
|
|
130
131
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "points_trigger"
|
|
4
|
+
require_relative "points_boost"
|
|
4
5
|
require "ostruct"
|
|
5
6
|
require "json"
|
|
6
7
|
|
|
@@ -16,6 +17,8 @@ module TrophyApiClient
|
|
|
16
17
|
attr_reader :total
|
|
17
18
|
# @return [TrophyApiClient::PointsTrigger]
|
|
18
19
|
attr_reader :trigger
|
|
20
|
+
# @return [Array<TrophyApiClient::PointsBoost>] Array of points boosts that applied to this award.
|
|
21
|
+
attr_reader :boosts
|
|
19
22
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
20
23
|
attr_reader :additional_properties
|
|
21
24
|
# @return [Object]
|
|
@@ -29,21 +32,25 @@ module TrophyApiClient
|
|
|
29
32
|
# @param date [String] The date these points were awarded, in ISO 8601 format.
|
|
30
33
|
# @param total [Integer] The user's total points after this award occurred.
|
|
31
34
|
# @param trigger [TrophyApiClient::PointsTrigger]
|
|
35
|
+
# @param boosts [Array<TrophyApiClient::PointsBoost>] Array of points boosts that applied to this award.
|
|
32
36
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
33
37
|
# @return [TrophyApiClient::PointsAward]
|
|
34
|
-
def initialize(id: OMIT, awarded: OMIT, date: OMIT, total: OMIT, trigger: OMIT,
|
|
38
|
+
def initialize(id: OMIT, awarded: OMIT, date: OMIT, total: OMIT, trigger: OMIT, boosts: OMIT,
|
|
39
|
+
additional_properties: nil)
|
|
35
40
|
@id = id if id != OMIT
|
|
36
41
|
@awarded = awarded if awarded != OMIT
|
|
37
42
|
@date = date if date != OMIT
|
|
38
43
|
@total = total if total != OMIT
|
|
39
44
|
@trigger = trigger if trigger != OMIT
|
|
45
|
+
@boosts = boosts if boosts != OMIT
|
|
40
46
|
@additional_properties = additional_properties
|
|
41
47
|
@_field_set = {
|
|
42
48
|
"id": id,
|
|
43
49
|
"awarded": awarded,
|
|
44
50
|
"date": date,
|
|
45
51
|
"total": total,
|
|
46
|
-
"trigger": trigger
|
|
52
|
+
"trigger": trigger,
|
|
53
|
+
"boosts": boosts
|
|
47
54
|
}.reject do |_k, v|
|
|
48
55
|
v == OMIT
|
|
49
56
|
end
|
|
@@ -66,12 +73,17 @@ module TrophyApiClient
|
|
|
66
73
|
trigger = parsed_json["trigger"].to_json
|
|
67
74
|
trigger = TrophyApiClient::PointsTrigger.from_json(json_object: trigger)
|
|
68
75
|
end
|
|
76
|
+
boosts = parsed_json["boosts"]&.map do |item|
|
|
77
|
+
item = item.to_json
|
|
78
|
+
TrophyApiClient::PointsBoost.from_json(json_object: item)
|
|
79
|
+
end
|
|
69
80
|
new(
|
|
70
81
|
id: id,
|
|
71
82
|
awarded: awarded,
|
|
72
83
|
date: date,
|
|
73
84
|
total: total,
|
|
74
85
|
trigger: trigger,
|
|
86
|
+
boosts: boosts,
|
|
75
87
|
additional_properties: struct
|
|
76
88
|
)
|
|
77
89
|
end
|
|
@@ -95,6 +107,7 @@ module TrophyApiClient
|
|
|
95
107
|
obj.date&.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
|
|
96
108
|
obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
|
97
109
|
obj.trigger.nil? || TrophyApiClient::PointsTrigger.validate_raw(obj: obj.trigger)
|
|
110
|
+
obj.boosts&.is_a?(Array) != false || raise("Passed value for field obj.boosts is not the expected type, validation failed.")
|
|
98
111
|
end
|
|
99
112
|
end
|
|
100
113
|
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "points_boost_status"
|
|
4
|
+
require_relative "points_boost_rounding"
|
|
5
|
+
require "ostruct"
|
|
6
|
+
require "json"
|
|
7
|
+
|
|
8
|
+
module TrophyApiClient
|
|
9
|
+
class PointsBoost
|
|
10
|
+
# @return [String] The ID of the points boost
|
|
11
|
+
attr_reader :id
|
|
12
|
+
# @return [String] The name of the points boost
|
|
13
|
+
attr_reader :name
|
|
14
|
+
# @return [TrophyApiClient::PointsBoostStatus] The status of the points boost
|
|
15
|
+
attr_reader :status
|
|
16
|
+
# @return [String] The start date of the points boost
|
|
17
|
+
attr_reader :start
|
|
18
|
+
# @return [String] The end date of the points boost
|
|
19
|
+
attr_reader :end_
|
|
20
|
+
# @return [Float] The multiplier of the points boost
|
|
21
|
+
attr_reader :multiplier
|
|
22
|
+
# @return [TrophyApiClient::PointsBoostRounding] The rounding method of the points boost
|
|
23
|
+
attr_reader :rounding
|
|
24
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
25
|
+
attr_reader :additional_properties
|
|
26
|
+
# @return [Object]
|
|
27
|
+
attr_reader :_field_set
|
|
28
|
+
protected :_field_set
|
|
29
|
+
|
|
30
|
+
OMIT = Object.new
|
|
31
|
+
|
|
32
|
+
# @param id [String] The ID of the points boost
|
|
33
|
+
# @param name [String] The name of the points boost
|
|
34
|
+
# @param status [TrophyApiClient::PointsBoostStatus] The status of the points boost
|
|
35
|
+
# @param start [String] The start date of the points boost
|
|
36
|
+
# @param end_ [String] The end date of the points boost
|
|
37
|
+
# @param multiplier [Float] The multiplier of the points boost
|
|
38
|
+
# @param rounding [TrophyApiClient::PointsBoostRounding] The rounding method of the points boost
|
|
39
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
40
|
+
# @return [TrophyApiClient::PointsBoost]
|
|
41
|
+
def initialize(id:, name:, status:, start:, multiplier:, rounding:, end_: OMIT, additional_properties: nil)
|
|
42
|
+
@id = id
|
|
43
|
+
@name = name
|
|
44
|
+
@status = status
|
|
45
|
+
@start = start
|
|
46
|
+
@end_ = end_ if end_ != OMIT
|
|
47
|
+
@multiplier = multiplier
|
|
48
|
+
@rounding = rounding
|
|
49
|
+
@additional_properties = additional_properties
|
|
50
|
+
@_field_set = {
|
|
51
|
+
"id": id,
|
|
52
|
+
"name": name,
|
|
53
|
+
"status": status,
|
|
54
|
+
"start": start,
|
|
55
|
+
"end": end_,
|
|
56
|
+
"multiplier": multiplier,
|
|
57
|
+
"rounding": rounding
|
|
58
|
+
}.reject do |_k, v|
|
|
59
|
+
v == OMIT
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Deserialize a JSON object to an instance of PointsBoost
|
|
64
|
+
#
|
|
65
|
+
# @param json_object [String]
|
|
66
|
+
# @return [TrophyApiClient::PointsBoost]
|
|
67
|
+
def self.from_json(json_object:)
|
|
68
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
69
|
+
parsed_json = JSON.parse(json_object)
|
|
70
|
+
id = parsed_json["id"]
|
|
71
|
+
name = parsed_json["name"]
|
|
72
|
+
status = parsed_json["status"]
|
|
73
|
+
start = parsed_json["start"]
|
|
74
|
+
end_ = parsed_json["end"]
|
|
75
|
+
multiplier = parsed_json["multiplier"]
|
|
76
|
+
rounding = parsed_json["rounding"]
|
|
77
|
+
new(
|
|
78
|
+
id: id,
|
|
79
|
+
name: name,
|
|
80
|
+
status: status,
|
|
81
|
+
start: start,
|
|
82
|
+
end_: end_,
|
|
83
|
+
multiplier: multiplier,
|
|
84
|
+
rounding: rounding,
|
|
85
|
+
additional_properties: struct
|
|
86
|
+
)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Serialize an instance of PointsBoost to a JSON object
|
|
90
|
+
#
|
|
91
|
+
# @return [String]
|
|
92
|
+
def to_json(*_args)
|
|
93
|
+
@_field_set&.to_json
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
97
|
+
# hash and check each fields type against the current object's property
|
|
98
|
+
# definitions.
|
|
99
|
+
#
|
|
100
|
+
# @param obj [Object]
|
|
101
|
+
# @return [Void]
|
|
102
|
+
def self.validate_raw(obj:)
|
|
103
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
104
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
105
|
+
obj.status.is_a?(TrophyApiClient::PointsBoostStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
|
106
|
+
obj.start.is_a?(String) != false || raise("Passed value for field obj.start is not the expected type, validation failed.")
|
|
107
|
+
obj.end_&.is_a?(String) != false || raise("Passed value for field obj.end_ is not the expected type, validation failed.")
|
|
108
|
+
obj.multiplier.is_a?(Float) != false || raise("Passed value for field obj.multiplier is not the expected type, validation failed.")
|
|
109
|
+
obj.rounding.is_a?(TrophyApiClient::PointsBoostRounding) != false || raise("Passed value for field obj.rounding is not the expected type, validation failed.")
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|