trophy_api_client 1.0.5 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 781b0353ba46d056e106f841128a86cd104b6052d7fd39956bb42ab20a959d09
4
- data.tar.gz: 2272e2e18f75bd8fa4216e34aa4958893f2ee0d58741cc8112c56bc5cd2cc6cc
3
+ metadata.gz: 0bb50b78377373fe998de76dec582b9849dae850ff8ea926318ae361924833e8
4
+ data.tar.gz: 035d6798383c8612d08f8c8c3a954e7425d25526dabae8c4e63ac5884cc7096a
5
5
  SHA512:
6
- metadata.gz: 0471d201882a0db3aa29df13e5d512d49be2a9342aa0a0e0d69d644b31e8282898f7f42c1bff782cd61d12182ef25270aa66a86d8f11682a58eb4258bea079c1
7
- data.tar.gz: 0d5b104155ad175b4b8105a3dc3a49e1693508331eabe0d64df48033dbc4c3bf1aed05c2d4a1ce132b0aa4065b86dd8ea8f91ebe2f6c2f1802adb4d0291f2aed
6
+ metadata.gz: 592ea29e76efc5c383d92263d108698a0b8175077c8ddd6682f2fd7f1fde41f92e4b57811e05ac76e57fd1eadc0711d0aefe4267ef2eb37b9cda732f1dc56cea
7
+ data.tar.gz: 75899f9e4d97c32499853c25027cd0560dbab159573de0bed2bf7e1e348c1e37b3902528cdb884b01610eea9145c938fa7e19aa079723b7424e7472732007bcf
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.0.5"
5
+ VERSION = "1.0.6"
6
6
  AUTHORS = ["Trophy Labs, Inc"].freeze
7
7
  EMAIL = ""
8
8
  SUMMARY = "Ruby library for the Trophy API."
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "one_off_achievement_response"
3
+ require_relative "api_achievement_response"
4
4
  require "ostruct"
5
5
  require "json"
6
6
 
@@ -8,7 +8,7 @@ module TrophyApiClient
8
8
  class AchievementCompletionResponse
9
9
  # @return [String] The unique ID of the completion.
10
10
  attr_reader :completion_id
11
- # @return [TrophyApiClient::OneOffAchievementResponse]
11
+ # @return [TrophyApiClient::ApiAchievementResponse]
12
12
  attr_reader :achievement
13
13
  # @return [OpenStruct] Additional properties unmapped to the current class definition
14
14
  attr_reader :additional_properties
@@ -19,7 +19,7 @@ module TrophyApiClient
19
19
  OMIT = Object.new
20
20
 
21
21
  # @param completion_id [String] The unique ID of the completion.
22
- # @param achievement [TrophyApiClient::OneOffAchievementResponse]
22
+ # @param achievement [TrophyApiClient::ApiAchievementResponse]
23
23
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
24
  # @return [TrophyApiClient::AchievementCompletionResponse]
25
25
  def initialize(completion_id:, achievement:, additional_properties: nil)
@@ -41,7 +41,7 @@ module TrophyApiClient
41
41
  achievement = nil
42
42
  else
43
43
  achievement = parsed_json["achievement"].to_json
44
- achievement = TrophyApiClient::OneOffAchievementResponse.from_json(json_object: achievement)
44
+ achievement = TrophyApiClient::ApiAchievementResponse.from_json(json_object: achievement)
45
45
  end
46
46
  new(
47
47
  completion_id: completion_id,
@@ -65,7 +65,7 @@ module TrophyApiClient
65
65
  # @return [Void]
66
66
  def self.validate_raw(obj:)
67
67
  obj.completion_id.is_a?(String) != false || raise("Passed value for field obj.completion_id is not the expected type, validation failed.")
68
- TrophyApiClient::OneOffAchievementResponse.validate_raw(obj: obj.achievement)
68
+ TrophyApiClient::ApiAchievementResponse.validate_raw(obj: obj.achievement)
69
69
  end
70
70
  end
71
71
  end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "metric_achievement_response"
5
+ require_relative "streak_achievement_response"
6
+ require_relative "api_achievement_response"
7
+
8
+ module TrophyApiClient
9
+ class AchievementResponse
10
+ # Deserialize a JSON object to an instance of AchievementResponse
11
+ #
12
+ # @param json_object [String]
13
+ # @return [TrophyApiClient::AchievementResponse]
14
+ def self.from_json(json_object:)
15
+ struct = JSON.parse(json_object, object_class: OpenStruct)
16
+ begin
17
+ TrophyApiClient::MetricAchievementResponse.validate_raw(obj: struct)
18
+ return TrophyApiClient::MetricAchievementResponse.from_json(json_object: struct) unless struct.nil?
19
+
20
+ return nil
21
+ rescue StandardError
22
+ # noop
23
+ end
24
+ begin
25
+ TrophyApiClient::StreakAchievementResponse.validate_raw(obj: struct)
26
+ return TrophyApiClient::StreakAchievementResponse.from_json(json_object: struct) unless struct.nil?
27
+
28
+ return nil
29
+ rescue StandardError
30
+ # noop
31
+ end
32
+ begin
33
+ TrophyApiClient::ApiAchievementResponse.validate_raw(obj: struct)
34
+ return TrophyApiClient::ApiAchievementResponse.from_json(json_object: struct) unless struct.nil?
35
+
36
+ return nil
37
+ rescue StandardError
38
+ # noop
39
+ end
40
+ struct
41
+ end
42
+
43
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
44
+ # hash and check each fields type against the current object's property
45
+ # definitions.
46
+ #
47
+ # @param obj [Object]
48
+ # @return [Void]
49
+ def self.validate_raw(obj:)
50
+ begin
51
+ return TrophyApiClient::MetricAchievementResponse.validate_raw(obj: obj)
52
+ rescue StandardError
53
+ # noop
54
+ end
55
+ begin
56
+ return TrophyApiClient::StreakAchievementResponse.validate_raw(obj: obj)
57
+ rescue StandardError
58
+ # noop
59
+ end
60
+ begin
61
+ return TrophyApiClient::ApiAchievementResponse.validate_raw(obj: obj)
62
+ rescue StandardError
63
+ # noop
64
+ end
65
+ raise("Passed value matched no type within the union, validation failed.")
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ class ApiAchievementResponse
9
+ # @return [String] The trigger of the achievement, in this case always 'api'.
10
+ attr_reader :trigger
11
+ # @return [String] The unique ID of the achievement.
12
+ attr_reader :id
13
+ # @return [String] The name of this achievement.
14
+ attr_reader :name
15
+ # @return [String] The URL of the badge image for the achievement, if one has been uploaded.
16
+ attr_reader :badge_url
17
+ # @return [String] The key used to reference this achievement in the API.
18
+ attr_reader :key
19
+ # @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
20
+ attr_reader :achieved_at
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 trigger [String] The trigger of the achievement, in this case always 'api'.
30
+ # @param id [String] The unique ID of the achievement.
31
+ # @param name [String] The name of this achievement.
32
+ # @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
33
+ # @param key [String] The key used to reference this achievement in the API.
34
+ # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
35
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
36
+ # @return [TrophyApiClient::ApiAchievementResponse]
37
+ def initialize(trigger:, id:, name:, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil)
38
+ @trigger = trigger
39
+ @id = id
40
+ @name = name
41
+ @badge_url = badge_url if badge_url != OMIT
42
+ @key = key if key != OMIT
43
+ @achieved_at = achieved_at if achieved_at != OMIT
44
+ @additional_properties = additional_properties
45
+ @_field_set = {
46
+ "trigger": trigger,
47
+ "id": id,
48
+ "name": name,
49
+ "badgeUrl": badge_url,
50
+ "key": key,
51
+ "achievedAt": achieved_at
52
+ }.reject do |_k, v|
53
+ v == OMIT
54
+ end
55
+ end
56
+
57
+ # Deserialize a JSON object to an instance of ApiAchievementResponse
58
+ #
59
+ # @param json_object [String]
60
+ # @return [TrophyApiClient::ApiAchievementResponse]
61
+ def self.from_json(json_object:)
62
+ struct = JSON.parse(json_object, object_class: OpenStruct)
63
+ parsed_json = JSON.parse(json_object)
64
+ trigger = parsed_json["trigger"]
65
+ id = parsed_json["id"]
66
+ name = parsed_json["name"]
67
+ badge_url = parsed_json["badgeUrl"]
68
+ key = parsed_json["key"]
69
+ achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
70
+ new(
71
+ trigger: trigger,
72
+ id: id,
73
+ name: name,
74
+ badge_url: badge_url,
75
+ key: key,
76
+ achieved_at: achieved_at,
77
+ additional_properties: struct
78
+ )
79
+ end
80
+
81
+ # Serialize an instance of ApiAchievementResponse 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.trigger.is_a?(String) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
96
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id 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.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
99
+ obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
100
+ obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
101
+ end
102
+ end
103
+ end
@@ -5,7 +5,7 @@ require "ostruct"
5
5
  require "json"
6
6
 
7
7
  module TrophyApiClient
8
- class OneOffAchievementResponse
8
+ class BaseAchievementResponse
9
9
  # @return [String] The unique ID of the achievement.
10
10
  attr_reader :id
11
11
  # @return [String] The name of this achievement.
@@ -30,10 +30,10 @@ module TrophyApiClient
30
30
  # @param key [String] The key used to reference this achievement in the API.
31
31
  # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
32
32
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
33
- # @return [TrophyApiClient::OneOffAchievementResponse]
34
- def initialize(id:, name: OMIT, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil)
33
+ # @return [TrophyApiClient::BaseAchievementResponse]
34
+ def initialize(id:, name:, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil)
35
35
  @id = id
36
- @name = name if name != OMIT
36
+ @name = name
37
37
  @badge_url = badge_url if badge_url != OMIT
38
38
  @key = key if key != OMIT
39
39
  @achieved_at = achieved_at if achieved_at != OMIT
@@ -49,10 +49,10 @@ module TrophyApiClient
49
49
  end
50
50
  end
51
51
 
52
- # Deserialize a JSON object to an instance of OneOffAchievementResponse
52
+ # Deserialize a JSON object to an instance of BaseAchievementResponse
53
53
  #
54
54
  # @param json_object [String]
55
- # @return [TrophyApiClient::OneOffAchievementResponse]
55
+ # @return [TrophyApiClient::BaseAchievementResponse]
56
56
  def self.from_json(json_object:)
57
57
  struct = JSON.parse(json_object, object_class: OpenStruct)
58
58
  parsed_json = JSON.parse(json_object)
@@ -71,7 +71,7 @@ module TrophyApiClient
71
71
  )
72
72
  end
73
73
 
74
- # Serialize an instance of OneOffAchievementResponse to a JSON object
74
+ # Serialize an instance of BaseAchievementResponse to a JSON object
75
75
  #
76
76
  # @return [String]
77
77
  def to_json(*_args)
@@ -86,7 +86,7 @@ module TrophyApiClient
86
86
  # @return [Void]
87
87
  def self.validate_raw(obj:)
88
88
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
89
- obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
89
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
90
90
  obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
91
91
  obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
92
92
  obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
@@ -1,14 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "multi_stage_achievement_response"
3
+ require_relative "event_response_metrics_item_completed_item"
4
4
  require "ostruct"
5
5
  require "json"
6
6
 
7
7
  module TrophyApiClient
8
8
  class EventResponseMetricsItem
9
- # @return [String] The ID of the metric.
9
+ # @return [String] The trigger of the achievement, in this case either 'metric' or 'streak'.
10
+ attr_reader :trigger
11
+ # @return [String] The ID of the metric that these achievements are associated with, if any.
10
12
  attr_reader :metric_id
11
- # @return [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of any new achievements that the user has now completed as a result of
13
+ # @return [Array<TrophyApiClient::EventResponseMetricsItemCompletedItem>] A list of any new achievements that the user has now completed as a result of
12
14
  # this event being submitted.
13
15
  attr_reader :completed
14
16
  # @return [OpenStruct] Additional properties unmapped to the current class definition
@@ -19,16 +21,18 @@ module TrophyApiClient
19
21
 
20
22
  OMIT = Object.new
21
23
 
22
- # @param metric_id [String] The ID of the metric.
23
- # @param completed [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of any new achievements that the user has now completed as a result of
24
+ # @param trigger [String] The trigger of the achievement, in this case either 'metric' or 'streak'.
25
+ # @param metric_id [String] The ID of the metric that these achievements are associated with, if any.
26
+ # @param completed [Array<TrophyApiClient::EventResponseMetricsItemCompletedItem>] A list of any new achievements that the user has now completed as a result of
24
27
  # this event being submitted.
25
28
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
26
29
  # @return [TrophyApiClient::EventResponseMetricsItem]
27
- def initialize(metric_id: OMIT, completed: OMIT, additional_properties: nil)
30
+ def initialize(completed:, trigger: OMIT, metric_id: OMIT, additional_properties: nil)
31
+ @trigger = trigger if trigger != OMIT
28
32
  @metric_id = metric_id if metric_id != OMIT
29
- @completed = completed if completed != OMIT
33
+ @completed = completed
30
34
  @additional_properties = additional_properties
31
- @_field_set = { "metricId": metric_id, "completed": completed }.reject do |_k, v|
35
+ @_field_set = { "trigger": trigger, "metricId": metric_id, "completed": completed }.reject do |_k, v|
32
36
  v == OMIT
33
37
  end
34
38
  end
@@ -40,12 +44,14 @@ module TrophyApiClient
40
44
  def self.from_json(json_object:)
41
45
  struct = JSON.parse(json_object, object_class: OpenStruct)
42
46
  parsed_json = JSON.parse(json_object)
47
+ trigger = parsed_json["trigger"]
43
48
  metric_id = parsed_json["metricId"]
44
49
  completed = parsed_json["completed"]&.map do |item|
45
50
  item = item.to_json
46
- TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
51
+ TrophyApiClient::EventResponseMetricsItemCompletedItem.from_json(json_object: item)
47
52
  end
48
53
  new(
54
+ trigger: trigger,
49
55
  metric_id: metric_id,
50
56
  completed: completed,
51
57
  additional_properties: struct
@@ -66,8 +72,9 @@ module TrophyApiClient
66
72
  # @param obj [Object]
67
73
  # @return [Void]
68
74
  def self.validate_raw(obj:)
75
+ obj.trigger&.is_a?(String) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
69
76
  obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
70
- obj.completed&.is_a?(Array) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.")
77
+ obj.completed.is_a?(Array) != false || raise("Passed value for field obj.completed is not the expected type, validation failed.")
71
78
  end
72
79
  end
73
80
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "metric_achievement_response"
5
+ require_relative "streak_achievement_response"
6
+
7
+ module TrophyApiClient
8
+ class EventResponseMetricsItemCompletedItem
9
+ # Deserialize a JSON object to an instance of
10
+ # EventResponseMetricsItemCompletedItem
11
+ #
12
+ # @param json_object [String]
13
+ # @return [TrophyApiClient::EventResponseMetricsItemCompletedItem]
14
+ def self.from_json(json_object:)
15
+ struct = JSON.parse(json_object, object_class: OpenStruct)
16
+ begin
17
+ TrophyApiClient::MetricAchievementResponse.validate_raw(obj: struct)
18
+ return TrophyApiClient::MetricAchievementResponse.from_json(json_object: struct) unless struct.nil?
19
+
20
+ return nil
21
+ rescue StandardError
22
+ # noop
23
+ end
24
+ begin
25
+ TrophyApiClient::StreakAchievementResponse.validate_raw(obj: struct)
26
+ return TrophyApiClient::StreakAchievementResponse.from_json(json_object: struct) unless struct.nil?
27
+
28
+ return nil
29
+ rescue StandardError
30
+ # noop
31
+ end
32
+ struct
33
+ end
34
+
35
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
36
+ # hash and check each fields type against the current object's property
37
+ # definitions.
38
+ #
39
+ # @param obj [Object]
40
+ # @return [Void]
41
+ def self.validate_raw(obj:)
42
+ begin
43
+ return TrophyApiClient::MetricAchievementResponse.validate_raw(obj: obj)
44
+ rescue StandardError
45
+ # noop
46
+ end
47
+ begin
48
+ return TrophyApiClient::StreakAchievementResponse.validate_raw(obj: obj)
49
+ rescue StandardError
50
+ # noop
51
+ end
52
+ raise("Passed value matched no type within the union, validation failed.")
53
+ end
54
+ end
55
+ end
@@ -5,13 +5,9 @@ require "ostruct"
5
5
  require "json"
6
6
 
7
7
  module TrophyApiClient
8
- class MultiStageAchievementResponse
9
- # @return [String] The unique ID of the achievement.
10
- attr_reader :id
11
- # @return [String] The name of this achievement.
12
- attr_reader :name
13
- # @return [String] The URL of the badge image for the achievement, if one has been uploaded.
14
- attr_reader :badge_url
8
+ class MetricAchievementResponse
9
+ # @return [String] The trigger of the achievement, in this case always 'metric'.
10
+ attr_reader :trigger
15
11
  # @return [String] The ID of the metric associated with this achievement, if any.
16
12
  attr_reader :metric_id
17
13
  # @return [Float] The value of the metric required to complete the achievement, if this
@@ -19,6 +15,12 @@ module TrophyApiClient
19
15
  attr_reader :metric_value
20
16
  # @return [String] The name of the metric associated with this achievement, if any.
21
17
  attr_reader :metric_name
18
+ # @return [String] The unique ID of the achievement.
19
+ attr_reader :id
20
+ # @return [String] The name of this achievement.
21
+ attr_reader :name
22
+ # @return [String] The URL of the badge image for the achievement, if one has been uploaded.
23
+ attr_reader :badge_url
22
24
  # @return [String] The key used to reference this achievement in the API.
23
25
  attr_reader :key
24
26
  # @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
@@ -31,35 +33,38 @@ module TrophyApiClient
31
33
 
32
34
  OMIT = Object.new
33
35
 
34
- # @param id [String] The unique ID of the achievement.
35
- # @param name [String] The name of this achievement.
36
- # @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
36
+ # @param trigger [String] The trigger of the achievement, in this case always 'metric'.
37
37
  # @param metric_id [String] The ID of the metric associated with this achievement, if any.
38
38
  # @param metric_value [Float] The value of the metric required to complete the achievement, if this
39
39
  # achievement is associated with a metric.
40
40
  # @param metric_name [String] The name of the metric associated with this achievement, if any.
41
+ # @param id [String] The unique ID of the achievement.
42
+ # @param name [String] The name of this achievement.
43
+ # @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
41
44
  # @param key [String] The key used to reference this achievement in the API.
42
45
  # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
43
46
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
44
- # @return [TrophyApiClient::MultiStageAchievementResponse]
45
- def initialize(id:, name: OMIT, badge_url: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, key: OMIT,
47
+ # @return [TrophyApiClient::MetricAchievementResponse]
48
+ def initialize(trigger:, metric_id:, metric_value:, metric_name:, id:, name:, badge_url: OMIT, key: OMIT,
46
49
  achieved_at: OMIT, additional_properties: nil)
50
+ @trigger = trigger
51
+ @metric_id = metric_id
52
+ @metric_value = metric_value
53
+ @metric_name = metric_name
47
54
  @id = id
48
- @name = name if name != OMIT
55
+ @name = name
49
56
  @badge_url = badge_url if badge_url != OMIT
50
- @metric_id = metric_id if metric_id != OMIT
51
- @metric_value = metric_value if metric_value != OMIT
52
- @metric_name = metric_name if metric_name != OMIT
53
57
  @key = key if key != OMIT
54
58
  @achieved_at = achieved_at if achieved_at != OMIT
55
59
  @additional_properties = additional_properties
56
60
  @_field_set = {
57
- "id": id,
58
- "name": name,
59
- "badgeUrl": badge_url,
61
+ "trigger": trigger,
60
62
  "metricId": metric_id,
61
63
  "metricValue": metric_value,
62
64
  "metricName": metric_name,
65
+ "id": id,
66
+ "name": name,
67
+ "badgeUrl": badge_url,
63
68
  "key": key,
64
69
  "achievedAt": achieved_at
65
70
  }.reject do |_k, v|
@@ -67,35 +72,37 @@ module TrophyApiClient
67
72
  end
68
73
  end
69
74
 
70
- # Deserialize a JSON object to an instance of MultiStageAchievementResponse
75
+ # Deserialize a JSON object to an instance of MetricAchievementResponse
71
76
  #
72
77
  # @param json_object [String]
73
- # @return [TrophyApiClient::MultiStageAchievementResponse]
78
+ # @return [TrophyApiClient::MetricAchievementResponse]
74
79
  def self.from_json(json_object:)
75
80
  struct = JSON.parse(json_object, object_class: OpenStruct)
76
81
  parsed_json = JSON.parse(json_object)
77
- id = parsed_json["id"]
78
- name = parsed_json["name"]
79
- badge_url = parsed_json["badgeUrl"]
82
+ trigger = parsed_json["trigger"]
80
83
  metric_id = parsed_json["metricId"]
81
84
  metric_value = parsed_json["metricValue"]
82
85
  metric_name = parsed_json["metricName"]
86
+ id = parsed_json["id"]
87
+ name = parsed_json["name"]
88
+ badge_url = parsed_json["badgeUrl"]
83
89
  key = parsed_json["key"]
84
90
  achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
85
91
  new(
86
- id: id,
87
- name: name,
88
- badge_url: badge_url,
92
+ trigger: trigger,
89
93
  metric_id: metric_id,
90
94
  metric_value: metric_value,
91
95
  metric_name: metric_name,
96
+ id: id,
97
+ name: name,
98
+ badge_url: badge_url,
92
99
  key: key,
93
100
  achieved_at: achieved_at,
94
101
  additional_properties: struct
95
102
  )
96
103
  end
97
104
 
98
- # Serialize an instance of MultiStageAchievementResponse to a JSON object
105
+ # Serialize an instance of MetricAchievementResponse to a JSON object
99
106
  #
100
107
  # @return [String]
101
108
  def to_json(*_args)
@@ -109,12 +116,13 @@ module TrophyApiClient
109
116
  # @param obj [Object]
110
117
  # @return [Void]
111
118
  def self.validate_raw(obj:)
119
+ obj.trigger.is_a?(String) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
120
+ obj.metric_id.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
121
+ obj.metric_value.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
122
+ obj.metric_name.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
112
123
  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.")
124
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
114
125
  obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
115
- obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
116
- obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
117
- obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
118
126
  obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
119
127
  obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
120
128
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "metric_status"
4
- require_relative "multi_stage_achievement_response"
4
+ require_relative "metric_achievement_response"
5
5
  require "ostruct"
6
6
  require "json"
7
7
 
@@ -13,13 +13,11 @@ module TrophyApiClient
13
13
  attr_reader :key
14
14
  # @return [String] The name of the metric.
15
15
  attr_reader :name
16
- # @return [String] The emoji to represent the metric.
17
- attr_reader :emoji
18
16
  # @return [TrophyApiClient::MetricStatus] The status of the metric.
19
17
  attr_reader :status
20
18
  # @return [Float] The user's current total for the metric.
21
19
  attr_reader :current
22
- # @return [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
20
+ # @return [Array<TrophyApiClient::MetricAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
23
21
  attr_reader :achievements
24
22
  # @return [OpenStruct] Additional properties unmapped to the current class definition
25
23
  attr_reader :additional_properties
@@ -32,17 +30,15 @@ module TrophyApiClient
32
30
  # @param id [String] The unique ID of the metric.
33
31
  # @param key [String] The unique key of the metric.
34
32
  # @param name [String] The name of the metric.
35
- # @param emoji [String] The emoji to represent the metric.
36
33
  # @param status [TrophyApiClient::MetricStatus] The status of the metric.
37
34
  # @param current [Float] The user's current total for the metric.
38
- # @param achievements [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
35
+ # @param achievements [Array<TrophyApiClient::MetricAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
39
36
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
40
37
  # @return [TrophyApiClient::MetricResponse]
41
- def initialize(id:, key:, name:, emoji:, status:, current:, achievements:, additional_properties: nil)
38
+ def initialize(id:, key:, name:, status:, current:, achievements:, additional_properties: nil)
42
39
  @id = id
43
40
  @key = key
44
41
  @name = name
45
- @emoji = emoji
46
42
  @status = status
47
43
  @current = current
48
44
  @achievements = achievements
@@ -51,7 +47,6 @@ module TrophyApiClient
51
47
  "id": id,
52
48
  "key": key,
53
49
  "name": name,
54
- "emoji": emoji,
55
50
  "status": status,
56
51
  "current": current,
57
52
  "achievements": achievements
@@ -68,18 +63,16 @@ module TrophyApiClient
68
63
  id = parsed_json["id"]
69
64
  key = parsed_json["key"]
70
65
  name = parsed_json["name"]
71
- emoji = parsed_json["emoji"]
72
66
  status = parsed_json["status"]
73
67
  current = parsed_json["current"]
74
68
  achievements = parsed_json["achievements"]&.map do |item|
75
69
  item = item.to_json
76
- TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
70
+ TrophyApiClient::MetricAchievementResponse.from_json(json_object: item)
77
71
  end
78
72
  new(
79
73
  id: id,
80
74
  key: key,
81
75
  name: name,
82
- emoji: emoji,
83
76
  status: status,
84
77
  current: current,
85
78
  achievements: achievements,
@@ -104,7 +97,6 @@ module TrophyApiClient
104
97
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
105
98
  obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
106
99
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
107
- obj.emoji.is_a?(String) != false || raise("Passed value for field obj.emoji is not the expected type, validation failed.")
108
100
  obj.status.is_a?(TrophyApiClient::MetricStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
109
101
  obj.current.is_a?(Float) != false || raise("Passed value for field obj.current is not the expected type, validation failed.")
110
102
  obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ class StreakAchievementResponse
9
+ # @return [String] The trigger of the achievement, in this case always 'streak'.
10
+ attr_reader :trigger
11
+ # @return [Integer] The length of the streak required to complete the achievement.
12
+ attr_reader :streak_length
13
+ # @return [String] The unique ID of the achievement.
14
+ attr_reader :id
15
+ # @return [String] The name of this achievement.
16
+ attr_reader :name
17
+ # @return [String] The URL of the badge image for the achievement, if one has been uploaded.
18
+ attr_reader :badge_url
19
+ # @return [String] The key used to reference this achievement in the API.
20
+ attr_reader :key
21
+ # @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
22
+ attr_reader :achieved_at
23
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
24
+ attr_reader :additional_properties
25
+ # @return [Object]
26
+ attr_reader :_field_set
27
+ protected :_field_set
28
+
29
+ OMIT = Object.new
30
+
31
+ # @param trigger [String] The trigger of the achievement, in this case always 'streak'.
32
+ # @param streak_length [Integer] The length of the streak required to complete the achievement.
33
+ # @param id [String] The unique ID of the achievement.
34
+ # @param name [String] The name of this achievement.
35
+ # @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
36
+ # @param key [String] The key used to reference this achievement in the API.
37
+ # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
38
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
39
+ # @return [TrophyApiClient::StreakAchievementResponse]
40
+ def initialize(trigger:, streak_length:, id:, name:, badge_url: OMIT, key: OMIT, achieved_at: OMIT,
41
+ additional_properties: nil)
42
+ @trigger = trigger
43
+ @streak_length = streak_length
44
+ @id = id
45
+ @name = name
46
+ @badge_url = badge_url if badge_url != OMIT
47
+ @key = key if key != OMIT
48
+ @achieved_at = achieved_at if achieved_at != OMIT
49
+ @additional_properties = additional_properties
50
+ @_field_set = {
51
+ "trigger": trigger,
52
+ "streakLength": streak_length,
53
+ "id": id,
54
+ "name": name,
55
+ "badgeUrl": badge_url,
56
+ "key": key,
57
+ "achievedAt": achieved_at
58
+ }.reject do |_k, v|
59
+ v == OMIT
60
+ end
61
+ end
62
+
63
+ # Deserialize a JSON object to an instance of StreakAchievementResponse
64
+ #
65
+ # @param json_object [String]
66
+ # @return [TrophyApiClient::StreakAchievementResponse]
67
+ def self.from_json(json_object:)
68
+ struct = JSON.parse(json_object, object_class: OpenStruct)
69
+ parsed_json = JSON.parse(json_object)
70
+ trigger = parsed_json["trigger"]
71
+ streak_length = parsed_json["streakLength"]
72
+ id = parsed_json["id"]
73
+ name = parsed_json["name"]
74
+ badge_url = parsed_json["badgeUrl"]
75
+ key = parsed_json["key"]
76
+ achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
77
+ new(
78
+ trigger: trigger,
79
+ streak_length: streak_length,
80
+ id: id,
81
+ name: name,
82
+ badge_url: badge_url,
83
+ key: key,
84
+ achieved_at: achieved_at,
85
+ additional_properties: struct
86
+ )
87
+ end
88
+
89
+ # Serialize an instance of StreakAchievementResponse 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.trigger.is_a?(String) != false || raise("Passed value for field obj.trigger is not the expected type, validation failed.")
104
+ obj.streak_length.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
105
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
106
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
107
+ obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
108
+ obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
109
+ obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
110
+ end
111
+ end
112
+ end
@@ -6,7 +6,7 @@ require_relative "../types/user"
6
6
  require_relative "../types/updated_user"
7
7
  require_relative "../types/metric_response"
8
8
  require "json"
9
- require_relative "../types/multi_stage_achievement_response"
9
+ require_relative "../types/achievement_response"
10
10
  require_relative "../types/streak_response"
11
11
  require "async"
12
12
 
@@ -196,7 +196,7 @@ module TrophyApiClient
196
196
  #
197
197
  # @param id [String] ID of the user.
198
198
  # @param request_options [TrophyApiClient::RequestOptions]
199
- # @return [Array<TrophyApiClient::MultiStageAchievementResponse>]
199
+ # @return [Array<TrophyApiClient::AchievementResponse>]
200
200
  # @example
201
201
  # api = TrophyApiClient::Client.new(
202
202
  # base_url: "https://api.example.com",
@@ -224,7 +224,7 @@ module TrophyApiClient
224
224
  parsed_json = JSON.parse(response.body)
225
225
  parsed_json&.map do |item|
226
226
  item = item.to_json
227
- TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
227
+ TrophyApiClient::AchievementResponse.from_json(json_object: item)
228
228
  end
229
229
  end
230
230
 
@@ -459,7 +459,7 @@ module TrophyApiClient
459
459
  #
460
460
  # @param id [String] ID of the user.
461
461
  # @param request_options [TrophyApiClient::RequestOptions]
462
- # @return [Array<TrophyApiClient::MultiStageAchievementResponse>]
462
+ # @return [Array<TrophyApiClient::AchievementResponse>]
463
463
  # @example
464
464
  # api = TrophyApiClient::Client.new(
465
465
  # base_url: "https://api.example.com",
@@ -488,7 +488,7 @@ module TrophyApiClient
488
488
  parsed_json = JSON.parse(response.body)
489
489
  parsed_json&.map do |item|
490
490
  item = item.to_json
491
- TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
491
+ TrophyApiClient::AchievementResponse.from_json(json_object: item)
492
492
  end
493
493
  end
494
494
  end
@@ -1,3 +1,3 @@
1
1
  module MyGem
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
data/lib/types_export.rb CHANGED
@@ -6,13 +6,17 @@ require_relative "trophy_api_client/types/base_streak_response"
6
6
  require_relative "trophy_api_client/types/increment_metric_streak_response"
7
7
  require_relative "trophy_api_client/types/streak_response_streak_history_item"
8
8
  require_relative "trophy_api_client/types/streak_response"
9
- require_relative "trophy_api_client/types/multi_stage_achievement_response"
10
- require_relative "trophy_api_client/types/one_off_achievement_response"
9
+ require_relative "trophy_api_client/types/base_achievement_response"
10
+ require_relative "trophy_api_client/types/metric_achievement_response"
11
+ require_relative "trophy_api_client/types/api_achievement_response"
12
+ require_relative "trophy_api_client/types/streak_achievement_response"
13
+ require_relative "trophy_api_client/types/achievement_response"
11
14
  require_relative "trophy_api_client/types/metric_response"
12
15
  require_relative "trophy_api_client/types/updated_user"
13
16
  require_relative "trophy_api_client/types/upserted_user"
14
17
  require_relative "trophy_api_client/types/user"
15
18
  require_relative "trophy_api_client/types/error_body"
16
19
  require_relative "trophy_api_client/types/achievement_completion_response"
20
+ require_relative "trophy_api_client/types/event_response_metrics_item_completed_item"
17
21
  require_relative "trophy_api_client/types/event_response_metrics_item"
18
22
  require_relative "trophy_api_client/types/event_response"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trophy_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trophy Labs, Inc
@@ -102,15 +102,19 @@ files:
102
102
  - lib/trophy_api_client/achievements/client.rb
103
103
  - lib/trophy_api_client/metrics/client.rb
104
104
  - lib/trophy_api_client/types/achievement_completion_response.rb
105
+ - lib/trophy_api_client/types/achievement_response.rb
106
+ - lib/trophy_api_client/types/api_achievement_response.rb
107
+ - lib/trophy_api_client/types/base_achievement_response.rb
105
108
  - lib/trophy_api_client/types/base_streak_response.rb
106
109
  - lib/trophy_api_client/types/error_body.rb
107
110
  - lib/trophy_api_client/types/event_response.rb
108
111
  - lib/trophy_api_client/types/event_response_metrics_item.rb
112
+ - lib/trophy_api_client/types/event_response_metrics_item_completed_item.rb
109
113
  - lib/trophy_api_client/types/increment_metric_streak_response.rb
114
+ - lib/trophy_api_client/types/metric_achievement_response.rb
110
115
  - lib/trophy_api_client/types/metric_response.rb
111
116
  - lib/trophy_api_client/types/metric_status.rb
112
- - lib/trophy_api_client/types/multi_stage_achievement_response.rb
113
- - lib/trophy_api_client/types/one_off_achievement_response.rb
117
+ - lib/trophy_api_client/types/streak_achievement_response.rb
114
118
  - lib/trophy_api_client/types/streak_frequency.rb
115
119
  - lib/trophy_api_client/types/streak_response.rb
116
120
  - lib/trophy_api_client/types/streak_response_streak_history_item.rb