trophy_api_client 1.1.2 → 1.3.4
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/leaderboards/types/leaderboards_all_response_item.rb +12 -4
- data/lib/trophy_api_client/points/client.rb +152 -0
- data/lib/trophy_api_client/types/achievement_response.rb +23 -11
- data/lib/trophy_api_client/types/achievement_response_event_attribute.rb +2 -2
- data/lib/trophy_api_client/types/achievement_response_event_attributes_item.rb +66 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +23 -11
- data/lib/trophy_api_client/types/get_user_points_response.rb +38 -22
- data/lib/trophy_api_client/types/leaderboard_response.rb +12 -4
- data/lib/trophy_api_client/types/leaderboard_response_with_rankings.rb +12 -4
- data/lib/trophy_api_client/types/metric_event_leaderboard_response.rb +30 -8
- data/lib/trophy_api_client/types/metric_event_leaderboard_response_breakdown_attribute_values_item.rb +67 -0
- data/lib/trophy_api_client/types/metric_event_points_response.rb +47 -31
- data/lib/trophy_api_client/types/points_level.rb +103 -0
- data/lib/trophy_api_client/types/points_level_summary_response.rb +7 -0
- data/lib/trophy_api_client/types/points_level_summary_response_item.rb +71 -0
- data/lib/trophy_api_client/types/points_response.rb +103 -0
- data/lib/trophy_api_client/types/points_system_response.rb +4 -4
- data/lib/trophy_api_client/types/points_trigger.rb +101 -9
- data/lib/trophy_api_client/types/{points_trigger_response_event_attribute.rb → points_trigger_event_attribute.rb} +7 -7
- data/lib/trophy_api_client/types/points_trigger_event_attributes_item.rb +65 -0
- data/lib/trophy_api_client/types/{points_trigger_response_status.rb → points_trigger_status.rb} +2 -1
- data/lib/trophy_api_client/types/{points_trigger_response_user_attributes_item.rb → points_trigger_user_attributes_item.rb} +7 -9
- data/lib/trophy_api_client/types/streak_response.rb +4 -2
- data/lib/trophy_api_client/types/user_achievement_response.rb +23 -11
- data/lib/trophy_api_client/types/user_achievement_with_stats_response.rb +23 -11
- data/lib/trophy_api_client/types/user_leaderboard_response.rb +12 -4
- data/lib/trophy_api_client/types/user_leaderboard_response_with_history.rb +12 -4
- data/lib/trophy_api_client/types/webhook_user_leaderboard_response.rb +11 -3
- data/lib/trophy_api_client/types/webhooks_points_level_changed_payload.rb +117 -0
- data/lib/trophy_api_client/types/webhooks_points_level_changed_payload_points.rb +114 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/types_export.rb +12 -6
- metadata +14 -8
- data/lib/trophy_api_client/types/points_trigger_response.rb +0 -211
- data/lib/trophy_api_client/types/points_trigger_response_time_unit.rb +0 -9
- data/lib/trophy_api_client/types/points_trigger_response_type.rb +0 -12
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# A level within a points system.
|
|
8
|
+
class PointsLevel
|
|
9
|
+
# @return [String] The ID of the level
|
|
10
|
+
attr_reader :id
|
|
11
|
+
# @return [String] The unique key of the level
|
|
12
|
+
attr_reader :key
|
|
13
|
+
# @return [String] The name of the level
|
|
14
|
+
attr_reader :name
|
|
15
|
+
# @return [String] The description of the level
|
|
16
|
+
attr_reader :description
|
|
17
|
+
# @return [String] The URL of the badge image for the level
|
|
18
|
+
attr_reader :badge_url
|
|
19
|
+
# @return [Integer] The points threshold required to reach this level
|
|
20
|
+
attr_reader :points
|
|
21
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
|
+
attr_reader :additional_properties
|
|
23
|
+
# @return [Object]
|
|
24
|
+
attr_reader :_field_set
|
|
25
|
+
protected :_field_set
|
|
26
|
+
|
|
27
|
+
OMIT = Object.new
|
|
28
|
+
|
|
29
|
+
# @param id [String] The ID of the level
|
|
30
|
+
# @param key [String] The unique key of the level
|
|
31
|
+
# @param name [String] The name of the level
|
|
32
|
+
# @param description [String] The description of the level
|
|
33
|
+
# @param badge_url [String] The URL of the badge image for the level
|
|
34
|
+
# @param points [Integer] The points threshold required to reach this level
|
|
35
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
36
|
+
# @return [TrophyApiClient::PointsLevel]
|
|
37
|
+
def initialize(id:, key:, name:, description:, points:, badge_url: OMIT, additional_properties: nil)
|
|
38
|
+
@id = id
|
|
39
|
+
@key = key
|
|
40
|
+
@name = name
|
|
41
|
+
@description = description
|
|
42
|
+
@badge_url = badge_url if badge_url != OMIT
|
|
43
|
+
@points = points
|
|
44
|
+
@additional_properties = additional_properties
|
|
45
|
+
@_field_set = {
|
|
46
|
+
"id": id,
|
|
47
|
+
"key": key,
|
|
48
|
+
"name": name,
|
|
49
|
+
"description": description,
|
|
50
|
+
"badgeUrl": badge_url,
|
|
51
|
+
"points": points
|
|
52
|
+
}.reject do |_k, v|
|
|
53
|
+
v == OMIT
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Deserialize a JSON object to an instance of PointsLevel
|
|
58
|
+
#
|
|
59
|
+
# @param json_object [String]
|
|
60
|
+
# @return [TrophyApiClient::PointsLevel]
|
|
61
|
+
def self.from_json(json_object:)
|
|
62
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
63
|
+
parsed_json = JSON.parse(json_object)
|
|
64
|
+
id = parsed_json["id"]
|
|
65
|
+
key = parsed_json["key"]
|
|
66
|
+
name = parsed_json["name"]
|
|
67
|
+
description = parsed_json["description"]
|
|
68
|
+
badge_url = parsed_json["badgeUrl"]
|
|
69
|
+
points = parsed_json["points"]
|
|
70
|
+
new(
|
|
71
|
+
id: id,
|
|
72
|
+
key: key,
|
|
73
|
+
name: name,
|
|
74
|
+
description: description,
|
|
75
|
+
badge_url: badge_url,
|
|
76
|
+
points: points,
|
|
77
|
+
additional_properties: struct
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Serialize an instance of PointsLevel to a JSON object
|
|
82
|
+
#
|
|
83
|
+
# @return [String]
|
|
84
|
+
def to_json(*_args)
|
|
85
|
+
@_field_set&.to_json
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
89
|
+
# hash and check each fields type against the current object's property
|
|
90
|
+
# definitions.
|
|
91
|
+
#
|
|
92
|
+
# @param obj [Object]
|
|
93
|
+
# @return [Void]
|
|
94
|
+
def self.validate_raw(obj:)
|
|
95
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
96
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
97
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
98
|
+
obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
99
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
100
|
+
obj.points.is_a?(Integer) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "points_level"
|
|
4
|
+
require "ostruct"
|
|
5
|
+
require "json"
|
|
6
|
+
|
|
7
|
+
module TrophyApiClient
|
|
8
|
+
class PointsLevelSummaryResponseItem
|
|
9
|
+
# @return [TrophyApiClient::PointsLevel]
|
|
10
|
+
attr_reader :level
|
|
11
|
+
# @return [Integer] The number of users currently at this level
|
|
12
|
+
attr_reader :users
|
|
13
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
14
|
+
attr_reader :additional_properties
|
|
15
|
+
# @return [Object]
|
|
16
|
+
attr_reader :_field_set
|
|
17
|
+
protected :_field_set
|
|
18
|
+
|
|
19
|
+
OMIT = Object.new
|
|
20
|
+
|
|
21
|
+
# @param level [TrophyApiClient::PointsLevel]
|
|
22
|
+
# @param users [Integer] The number of users currently at this level
|
|
23
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
24
|
+
# @return [TrophyApiClient::PointsLevelSummaryResponseItem]
|
|
25
|
+
def initialize(level:, users:, additional_properties: nil)
|
|
26
|
+
@level = level
|
|
27
|
+
@users = users
|
|
28
|
+
@additional_properties = additional_properties
|
|
29
|
+
@_field_set = { "level": level, "users": users }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Deserialize a JSON object to an instance of PointsLevelSummaryResponseItem
|
|
33
|
+
#
|
|
34
|
+
# @param json_object [String]
|
|
35
|
+
# @return [TrophyApiClient::PointsLevelSummaryResponseItem]
|
|
36
|
+
def self.from_json(json_object:)
|
|
37
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
38
|
+
parsed_json = JSON.parse(json_object)
|
|
39
|
+
if parsed_json["level"].nil?
|
|
40
|
+
level = nil
|
|
41
|
+
else
|
|
42
|
+
level = parsed_json["level"].to_json
|
|
43
|
+
level = TrophyApiClient::PointsLevel.from_json(json_object: level)
|
|
44
|
+
end
|
|
45
|
+
users = parsed_json["users"]
|
|
46
|
+
new(
|
|
47
|
+
level: level,
|
|
48
|
+
users: users,
|
|
49
|
+
additional_properties: struct
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Serialize an instance of PointsLevelSummaryResponseItem to a JSON object
|
|
54
|
+
#
|
|
55
|
+
# @return [String]
|
|
56
|
+
def to_json(*_args)
|
|
57
|
+
@_field_set&.to_json
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
61
|
+
# hash and check each fields type against the current object's property
|
|
62
|
+
# definitions.
|
|
63
|
+
#
|
|
64
|
+
# @param obj [Object]
|
|
65
|
+
# @return [Void]
|
|
66
|
+
def self.validate_raw(obj:)
|
|
67
|
+
TrophyApiClient::PointsLevel.validate_raw(obj: obj.level)
|
|
68
|
+
obj.users.is_a?(Integer) != false || raise("Passed value for field obj.users is not the expected type, validation failed.")
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
# Base points system fields shared across responses.
|
|
8
|
+
class PointsResponse
|
|
9
|
+
# @return [String] The ID of the points system
|
|
10
|
+
attr_reader :id
|
|
11
|
+
# @return [String] The key of the points system
|
|
12
|
+
attr_reader :key
|
|
13
|
+
# @return [String] The name of the points system
|
|
14
|
+
attr_reader :name
|
|
15
|
+
# @return [String] The description of the points system
|
|
16
|
+
attr_reader :description
|
|
17
|
+
# @return [String] The URL of the badge image for the points system
|
|
18
|
+
attr_reader :badge_url
|
|
19
|
+
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
20
|
+
attr_reader :max_points
|
|
21
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
|
+
attr_reader :additional_properties
|
|
23
|
+
# @return [Object]
|
|
24
|
+
attr_reader :_field_set
|
|
25
|
+
protected :_field_set
|
|
26
|
+
|
|
27
|
+
OMIT = Object.new
|
|
28
|
+
|
|
29
|
+
# @param id [String] The ID of the points system
|
|
30
|
+
# @param key [String] The key of the points system
|
|
31
|
+
# @param name [String] The name of the points system
|
|
32
|
+
# @param description [String] The description of the points system
|
|
33
|
+
# @param badge_url [String] The URL of the badge image for the points system
|
|
34
|
+
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
35
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
36
|
+
# @return [TrophyApiClient::PointsResponse]
|
|
37
|
+
def initialize(id:, key:, name:, description: OMIT, badge_url: OMIT, max_points: OMIT, additional_properties: nil)
|
|
38
|
+
@id = id
|
|
39
|
+
@key = key
|
|
40
|
+
@name = name
|
|
41
|
+
@description = description if description != OMIT
|
|
42
|
+
@badge_url = badge_url if badge_url != OMIT
|
|
43
|
+
@max_points = max_points if max_points != OMIT
|
|
44
|
+
@additional_properties = additional_properties
|
|
45
|
+
@_field_set = {
|
|
46
|
+
"id": id,
|
|
47
|
+
"key": key,
|
|
48
|
+
"name": name,
|
|
49
|
+
"description": description,
|
|
50
|
+
"badgeUrl": badge_url,
|
|
51
|
+
"maxPoints": max_points
|
|
52
|
+
}.reject do |_k, v|
|
|
53
|
+
v == OMIT
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Deserialize a JSON object to an instance of PointsResponse
|
|
58
|
+
#
|
|
59
|
+
# @param json_object [String]
|
|
60
|
+
# @return [TrophyApiClient::PointsResponse]
|
|
61
|
+
def self.from_json(json_object:)
|
|
62
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
63
|
+
parsed_json = JSON.parse(json_object)
|
|
64
|
+
id = parsed_json["id"]
|
|
65
|
+
key = parsed_json["key"]
|
|
66
|
+
name = parsed_json["name"]
|
|
67
|
+
description = parsed_json["description"]
|
|
68
|
+
badge_url = parsed_json["badgeUrl"]
|
|
69
|
+
max_points = parsed_json["maxPoints"]
|
|
70
|
+
new(
|
|
71
|
+
id: id,
|
|
72
|
+
key: key,
|
|
73
|
+
name: name,
|
|
74
|
+
description: description,
|
|
75
|
+
badge_url: badge_url,
|
|
76
|
+
max_points: max_points,
|
|
77
|
+
additional_properties: struct
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Serialize an instance of PointsResponse to a JSON object
|
|
82
|
+
#
|
|
83
|
+
# @return [String]
|
|
84
|
+
def to_json(*_args)
|
|
85
|
+
@_field_set&.to_json
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
89
|
+
# hash and check each fields type against the current object's property
|
|
90
|
+
# definitions.
|
|
91
|
+
#
|
|
92
|
+
# @param obj [Object]
|
|
93
|
+
# @return [Void]
|
|
94
|
+
def self.validate_raw(obj:)
|
|
95
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
96
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
97
|
+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
|
|
98
|
+
obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
|
|
99
|
+
obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
|
|
100
|
+
obj.max_points&.is_a?(Float) != false || raise("Passed value for field obj.max_points is not the expected type, validation failed.")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "
|
|
3
|
+
require_relative "points_trigger"
|
|
4
4
|
require "ostruct"
|
|
5
5
|
require "json"
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ module TrophyApiClient
|
|
|
16
16
|
attr_reader :badge_url
|
|
17
17
|
# @return [Float] The maximum number of points a user can be awarded in this points system
|
|
18
18
|
attr_reader :max_points
|
|
19
|
-
# @return [Array<TrophyApiClient::
|
|
19
|
+
# @return [Array<TrophyApiClient::PointsTrigger>] Array of active triggers for this points system.
|
|
20
20
|
attr_reader :triggers
|
|
21
21
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
22
22
|
attr_reader :additional_properties
|
|
@@ -31,7 +31,7 @@ module TrophyApiClient
|
|
|
31
31
|
# @param description [String] The description of the points system.
|
|
32
32
|
# @param badge_url [String] The URL of the badge image for the points system, if one has been uploaded.
|
|
33
33
|
# @param max_points [Float] The maximum number of points a user can be awarded in this points system
|
|
34
|
-
# @param triggers [Array<TrophyApiClient::
|
|
34
|
+
# @param triggers [Array<TrophyApiClient::PointsTrigger>] Array of active triggers for this points system.
|
|
35
35
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
36
36
|
# @return [TrophyApiClient::PointsSystemResponse]
|
|
37
37
|
def initialize(id:, name:, triggers:, description: OMIT, badge_url: OMIT, max_points: OMIT,
|
|
@@ -69,7 +69,7 @@ module TrophyApiClient
|
|
|
69
69
|
max_points = parsed_json["maxPoints"]
|
|
70
70
|
triggers = parsed_json["triggers"]&.map do |item|
|
|
71
71
|
item = item.to_json
|
|
72
|
-
TrophyApiClient::
|
|
72
|
+
TrophyApiClient::PointsTrigger.from_json(json_object: item)
|
|
73
73
|
end
|
|
74
74
|
new(
|
|
75
75
|
id: id,
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "points_trigger_type"
|
|
4
|
+
require_relative "points_trigger_status"
|
|
4
5
|
require_relative "points_trigger_time_unit"
|
|
6
|
+
require_relative "points_trigger_user_attributes_item"
|
|
7
|
+
require_relative "points_trigger_event_attribute"
|
|
8
|
+
require_relative "points_trigger_event_attributes_item"
|
|
9
|
+
require "date"
|
|
5
10
|
require "ostruct"
|
|
6
11
|
require "json"
|
|
7
12
|
|
|
@@ -13,6 +18,14 @@ module TrophyApiClient
|
|
|
13
18
|
attr_reader :type
|
|
14
19
|
# @return [Integer] The points awarded by this trigger.
|
|
15
20
|
attr_reader :points
|
|
21
|
+
# @return [TrophyApiClient::PointsTriggerStatus] The status of the trigger.
|
|
22
|
+
attr_reader :status
|
|
23
|
+
# @return [String] The unique ID of the achievement associated with this trigger, if the trigger is
|
|
24
|
+
# an achievement.
|
|
25
|
+
attr_reader :achievement_id
|
|
26
|
+
# @return [String] The unique ID of the metric associated with this trigger, if the trigger is a
|
|
27
|
+
# metric.
|
|
28
|
+
attr_reader :metric_id
|
|
16
29
|
# @return [String] If the trigger has type 'metric', the name of the metric
|
|
17
30
|
attr_reader :metric_name
|
|
18
31
|
# @return [Integer] If the trigger has type 'metric', the threshold of the metric that triggers the
|
|
@@ -28,6 +41,20 @@ module TrophyApiClient
|
|
|
28
41
|
# @return [Integer] If the trigger has type 'time', the numer of units of timeUnit after which to
|
|
29
42
|
# award points
|
|
30
43
|
attr_reader :time_interval
|
|
44
|
+
# @return [Array<TrophyApiClient::PointsTriggerUserAttributesItem>] User attribute filters that must be met for this trigger to award points. Empty
|
|
45
|
+
# when the trigger has no user attribute filters configured.
|
|
46
|
+
attr_reader :user_attributes
|
|
47
|
+
# @return [TrophyApiClient::PointsTriggerEventAttribute] Deprecated. Event attribute filter that must be met for this trigger to award
|
|
48
|
+
# points. Only present if the trigger has an event filter configured.
|
|
49
|
+
attr_reader :event_attribute
|
|
50
|
+
# @return [Array<TrophyApiClient::PointsTriggerEventAttributesItem>] If the trigger has type 'metric', the event attributes that must match for the
|
|
51
|
+
# trigger to award points. Empty when the trigger is metric-based and has no event
|
|
52
|
+
# attribute filters. Omitted for non-metric triggers.
|
|
53
|
+
attr_reader :event_attributes
|
|
54
|
+
# @return [DateTime] The date and time the trigger was created, in ISO 8601 format.
|
|
55
|
+
attr_reader :created
|
|
56
|
+
# @return [DateTime] The date and time the trigger was last updated, in ISO 8601 format.
|
|
57
|
+
attr_reader :updated
|
|
31
58
|
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
32
59
|
attr_reader :additional_properties
|
|
33
60
|
# @return [Object]
|
|
@@ -39,6 +66,11 @@ module TrophyApiClient
|
|
|
39
66
|
# @param id [String] The ID of the trigger
|
|
40
67
|
# @param type [TrophyApiClient::PointsTriggerType] The type of trigger
|
|
41
68
|
# @param points [Integer] The points awarded by this trigger.
|
|
69
|
+
# @param status [TrophyApiClient::PointsTriggerStatus] The status of the trigger.
|
|
70
|
+
# @param achievement_id [String] The unique ID of the achievement associated with this trigger, if the trigger is
|
|
71
|
+
# an achievement.
|
|
72
|
+
# @param metric_id [String] The unique ID of the metric associated with this trigger, if the trigger is a
|
|
73
|
+
# metric.
|
|
42
74
|
# @param metric_name [String] If the trigger has type 'metric', the name of the metric
|
|
43
75
|
# @param metric_threshold [Integer] If the trigger has type 'metric', the threshold of the metric that triggers the
|
|
44
76
|
# points
|
|
@@ -48,30 +80,55 @@ module TrophyApiClient
|
|
|
48
80
|
# @param time_unit [TrophyApiClient::PointsTriggerTimeUnit] If the trigger has type 'time', the unit of time after which to award points
|
|
49
81
|
# @param time_interval [Integer] If the trigger has type 'time', the numer of units of timeUnit after which to
|
|
50
82
|
# award points
|
|
83
|
+
# @param user_attributes [Array<TrophyApiClient::PointsTriggerUserAttributesItem>] User attribute filters that must be met for this trigger to award points. Empty
|
|
84
|
+
# when the trigger has no user attribute filters configured.
|
|
85
|
+
# @param event_attribute [TrophyApiClient::PointsTriggerEventAttribute] Deprecated. Event attribute filter that must be met for this trigger to award
|
|
86
|
+
# points. Only present if the trigger has an event filter configured.
|
|
87
|
+
# @param event_attributes [Array<TrophyApiClient::PointsTriggerEventAttributesItem>] If the trigger has type 'metric', the event attributes that must match for the
|
|
88
|
+
# trigger to award points. Empty when the trigger is metric-based and has no event
|
|
89
|
+
# attribute filters. Omitted for non-metric triggers.
|
|
90
|
+
# @param created [DateTime] The date and time the trigger was created, in ISO 8601 format.
|
|
91
|
+
# @param updated [DateTime] The date and time the trigger was last updated, in ISO 8601 format.
|
|
51
92
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
52
93
|
# @return [TrophyApiClient::PointsTrigger]
|
|
53
|
-
def initialize(id
|
|
54
|
-
streak_length_threshold: OMIT, achievement_name: OMIT, time_unit: OMIT, time_interval: OMIT, additional_properties: nil)
|
|
55
|
-
@id = id
|
|
56
|
-
@type = type
|
|
57
|
-
@points = points
|
|
94
|
+
def initialize(id:, type:, points:, status:, user_attributes:, created:, updated:, achievement_id: OMIT, metric_id: OMIT, metric_name: OMIT,
|
|
95
|
+
metric_threshold: OMIT, streak_length_threshold: OMIT, achievement_name: OMIT, time_unit: OMIT, time_interval: OMIT, event_attribute: OMIT, event_attributes: OMIT, additional_properties: nil)
|
|
96
|
+
@id = id
|
|
97
|
+
@type = type
|
|
98
|
+
@points = points
|
|
99
|
+
@status = status
|
|
100
|
+
@achievement_id = achievement_id if achievement_id != OMIT
|
|
101
|
+
@metric_id = metric_id if metric_id != OMIT
|
|
58
102
|
@metric_name = metric_name if metric_name != OMIT
|
|
59
103
|
@metric_threshold = metric_threshold if metric_threshold != OMIT
|
|
60
104
|
@streak_length_threshold = streak_length_threshold if streak_length_threshold != OMIT
|
|
61
105
|
@achievement_name = achievement_name if achievement_name != OMIT
|
|
62
106
|
@time_unit = time_unit if time_unit != OMIT
|
|
63
107
|
@time_interval = time_interval if time_interval != OMIT
|
|
108
|
+
@user_attributes = user_attributes
|
|
109
|
+
@event_attribute = event_attribute if event_attribute != OMIT
|
|
110
|
+
@event_attributes = event_attributes if event_attributes != OMIT
|
|
111
|
+
@created = created
|
|
112
|
+
@updated = updated
|
|
64
113
|
@additional_properties = additional_properties
|
|
65
114
|
@_field_set = {
|
|
66
115
|
"id": id,
|
|
67
116
|
"type": type,
|
|
68
117
|
"points": points,
|
|
118
|
+
"status": status,
|
|
119
|
+
"achievementId": achievement_id,
|
|
120
|
+
"metricId": metric_id,
|
|
69
121
|
"metricName": metric_name,
|
|
70
122
|
"metricThreshold": metric_threshold,
|
|
71
123
|
"streakLengthThreshold": streak_length_threshold,
|
|
72
124
|
"achievementName": achievement_name,
|
|
73
125
|
"timeUnit": time_unit,
|
|
74
|
-
"timeInterval": time_interval
|
|
126
|
+
"timeInterval": time_interval,
|
|
127
|
+
"userAttributes": user_attributes,
|
|
128
|
+
"eventAttribute": event_attribute,
|
|
129
|
+
"eventAttributes": event_attributes,
|
|
130
|
+
"created": created,
|
|
131
|
+
"updated": updated
|
|
75
132
|
}.reject do |_k, v|
|
|
76
133
|
v == OMIT
|
|
77
134
|
end
|
|
@@ -87,22 +144,49 @@ module TrophyApiClient
|
|
|
87
144
|
id = parsed_json["id"]
|
|
88
145
|
type = parsed_json["type"]
|
|
89
146
|
points = parsed_json["points"]
|
|
147
|
+
status = parsed_json["status"]
|
|
148
|
+
achievement_id = parsed_json["achievementId"]
|
|
149
|
+
metric_id = parsed_json["metricId"]
|
|
90
150
|
metric_name = parsed_json["metricName"]
|
|
91
151
|
metric_threshold = parsed_json["metricThreshold"]
|
|
92
152
|
streak_length_threshold = parsed_json["streakLengthThreshold"]
|
|
93
153
|
achievement_name = parsed_json["achievementName"]
|
|
94
154
|
time_unit = parsed_json["timeUnit"]
|
|
95
155
|
time_interval = parsed_json["timeInterval"]
|
|
156
|
+
user_attributes = parsed_json["userAttributes"]&.map do |item|
|
|
157
|
+
item = item.to_json
|
|
158
|
+
TrophyApiClient::PointsTriggerUserAttributesItem.from_json(json_object: item)
|
|
159
|
+
end
|
|
160
|
+
if parsed_json["eventAttribute"].nil?
|
|
161
|
+
event_attribute = nil
|
|
162
|
+
else
|
|
163
|
+
event_attribute = parsed_json["eventAttribute"].to_json
|
|
164
|
+
event_attribute = TrophyApiClient::PointsTriggerEventAttribute.from_json(json_object: event_attribute)
|
|
165
|
+
end
|
|
166
|
+
event_attributes = parsed_json["eventAttributes"]&.map do |item|
|
|
167
|
+
item = item.to_json
|
|
168
|
+
TrophyApiClient::PointsTriggerEventAttributesItem.from_json(json_object: item)
|
|
169
|
+
end
|
|
170
|
+
created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
|
|
171
|
+
updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
|
|
96
172
|
new(
|
|
97
173
|
id: id,
|
|
98
174
|
type: type,
|
|
99
175
|
points: points,
|
|
176
|
+
status: status,
|
|
177
|
+
achievement_id: achievement_id,
|
|
178
|
+
metric_id: metric_id,
|
|
100
179
|
metric_name: metric_name,
|
|
101
180
|
metric_threshold: metric_threshold,
|
|
102
181
|
streak_length_threshold: streak_length_threshold,
|
|
103
182
|
achievement_name: achievement_name,
|
|
104
183
|
time_unit: time_unit,
|
|
105
184
|
time_interval: time_interval,
|
|
185
|
+
user_attributes: user_attributes,
|
|
186
|
+
event_attribute: event_attribute,
|
|
187
|
+
event_attributes: event_attributes,
|
|
188
|
+
created: created,
|
|
189
|
+
updated: updated,
|
|
106
190
|
additional_properties: struct
|
|
107
191
|
)
|
|
108
192
|
end
|
|
@@ -121,15 +205,23 @@ module TrophyApiClient
|
|
|
121
205
|
# @param obj [Object]
|
|
122
206
|
# @return [Void]
|
|
123
207
|
def self.validate_raw(obj:)
|
|
124
|
-
obj.id
|
|
125
|
-
obj.type
|
|
126
|
-
obj.points
|
|
208
|
+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
|
|
209
|
+
obj.type.is_a?(TrophyApiClient::PointsTriggerType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
|
210
|
+
obj.points.is_a?(Integer) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
|
|
211
|
+
obj.status.is_a?(TrophyApiClient::PointsTriggerStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
|
|
212
|
+
obj.achievement_id&.is_a?(String) != false || raise("Passed value for field obj.achievement_id is not the expected type, validation failed.")
|
|
213
|
+
obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
|
|
127
214
|
obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
|
|
128
215
|
obj.metric_threshold&.is_a?(Integer) != false || raise("Passed value for field obj.metric_threshold is not the expected type, validation failed.")
|
|
129
216
|
obj.streak_length_threshold&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length_threshold is not the expected type, validation failed.")
|
|
130
217
|
obj.achievement_name&.is_a?(String) != false || raise("Passed value for field obj.achievement_name is not the expected type, validation failed.")
|
|
131
218
|
obj.time_unit&.is_a?(TrophyApiClient::PointsTriggerTimeUnit) != false || raise("Passed value for field obj.time_unit is not the expected type, validation failed.")
|
|
132
219
|
obj.time_interval&.is_a?(Integer) != false || raise("Passed value for field obj.time_interval is not the expected type, validation failed.")
|
|
220
|
+
obj.user_attributes.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
|
|
221
|
+
obj.event_attribute.nil? || TrophyApiClient::PointsTriggerEventAttribute.validate_raw(obj: obj.event_attribute)
|
|
222
|
+
obj.event_attributes&.is_a?(Array) != false || raise("Passed value for field obj.event_attributes is not the expected type, validation failed.")
|
|
223
|
+
obj.created.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
|
|
224
|
+
obj.updated.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
|
|
133
225
|
end
|
|
134
226
|
end
|
|
135
227
|
end
|
|
@@ -4,9 +4,9 @@ require "ostruct"
|
|
|
4
4
|
require "json"
|
|
5
5
|
|
|
6
6
|
module TrophyApiClient
|
|
7
|
-
# Event attribute filter that must be met for this trigger to
|
|
8
|
-
# present if the trigger has an event filter configured.
|
|
9
|
-
class
|
|
7
|
+
# Deprecated. Event attribute filter that must be met for this trigger to award
|
|
8
|
+
# points. Only present if the trigger has an event filter configured.
|
|
9
|
+
class PointsTriggerEventAttribute
|
|
10
10
|
# @return [String] The key of the event attribute.
|
|
11
11
|
attr_reader :key
|
|
12
12
|
# @return [String] The required value of the event attribute.
|
|
@@ -22,7 +22,7 @@ module TrophyApiClient
|
|
|
22
22
|
# @param key [String] The key of the event attribute.
|
|
23
23
|
# @param value [String] The required value of the event attribute.
|
|
24
24
|
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
25
|
-
# @return [TrophyApiClient::
|
|
25
|
+
# @return [TrophyApiClient::PointsTriggerEventAttribute]
|
|
26
26
|
def initialize(key:, value:, additional_properties: nil)
|
|
27
27
|
@key = key
|
|
28
28
|
@value = value
|
|
@@ -30,10 +30,10 @@ module TrophyApiClient
|
|
|
30
30
|
@_field_set = { "key": key, "value": value }
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# Deserialize a JSON object to an instance of
|
|
33
|
+
# Deserialize a JSON object to an instance of PointsTriggerEventAttribute
|
|
34
34
|
#
|
|
35
35
|
# @param json_object [String]
|
|
36
|
-
# @return [TrophyApiClient::
|
|
36
|
+
# @return [TrophyApiClient::PointsTriggerEventAttribute]
|
|
37
37
|
def self.from_json(json_object:)
|
|
38
38
|
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
39
39
|
parsed_json = JSON.parse(json_object)
|
|
@@ -46,7 +46,7 @@ module TrophyApiClient
|
|
|
46
46
|
)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
# Serialize an instance of
|
|
49
|
+
# Serialize an instance of PointsTriggerEventAttribute to a JSON object
|
|
50
50
|
#
|
|
51
51
|
# @return [String]
|
|
52
52
|
def to_json(*_args)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "ostruct"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module TrophyApiClient
|
|
7
|
+
class PointsTriggerEventAttributesItem
|
|
8
|
+
# @return [String] The key of the event attribute.
|
|
9
|
+
attr_reader :key
|
|
10
|
+
# @return [String] The required value of the event attribute.
|
|
11
|
+
attr_reader :value
|
|
12
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
|
13
|
+
attr_reader :additional_properties
|
|
14
|
+
# @return [Object]
|
|
15
|
+
attr_reader :_field_set
|
|
16
|
+
protected :_field_set
|
|
17
|
+
|
|
18
|
+
OMIT = Object.new
|
|
19
|
+
|
|
20
|
+
# @param key [String] The key of the event attribute.
|
|
21
|
+
# @param value [String] The required value of the event attribute.
|
|
22
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
|
23
|
+
# @return [TrophyApiClient::PointsTriggerEventAttributesItem]
|
|
24
|
+
def initialize(key:, value:, additional_properties: nil)
|
|
25
|
+
@key = key
|
|
26
|
+
@value = value
|
|
27
|
+
@additional_properties = additional_properties
|
|
28
|
+
@_field_set = { "key": key, "value": value }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Deserialize a JSON object to an instance of PointsTriggerEventAttributesItem
|
|
32
|
+
#
|
|
33
|
+
# @param json_object [String]
|
|
34
|
+
# @return [TrophyApiClient::PointsTriggerEventAttributesItem]
|
|
35
|
+
def self.from_json(json_object:)
|
|
36
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
|
37
|
+
parsed_json = JSON.parse(json_object)
|
|
38
|
+
key = parsed_json["key"]
|
|
39
|
+
value = parsed_json["value"]
|
|
40
|
+
new(
|
|
41
|
+
key: key,
|
|
42
|
+
value: value,
|
|
43
|
+
additional_properties: struct
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Serialize an instance of PointsTriggerEventAttributesItem to a JSON object
|
|
48
|
+
#
|
|
49
|
+
# @return [String]
|
|
50
|
+
def to_json(*_args)
|
|
51
|
+
@_field_set&.to_json
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
|
55
|
+
# hash and check each fields type against the current object's property
|
|
56
|
+
# definitions.
|
|
57
|
+
#
|
|
58
|
+
# @param obj [Object]
|
|
59
|
+
# @return [Void]
|
|
60
|
+
def self.validate_raw(obj:)
|
|
61
|
+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
|
|
62
|
+
obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|