trophy_api_client 1.0.7 → 1.0.8

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: 41b13c271b0fdb5a50abd095f29e33f0f3619e526c86ebb6a7e199f94d414442
4
- data.tar.gz: 2ccc3ab43e106bf29f0937115c41b6d335064df134e90fa9779c99ac7e34920b
3
+ metadata.gz: 5d989ef5a5b073a7de3275ba37b0db5a3ee2e89e4917af9f7b6f032f626371ab
4
+ data.tar.gz: 06b608a64d458bb33af5be55d4f26bf1e3a98d434554483c9ad920143b32d67a
5
5
  SHA512:
6
- metadata.gz: 6ce2e3e945b755c71a2ff6935a1c805da673973968bdad4c322d04bd1cb1b3d8d712d8119a253556498893efdf2d43a1a6d23cdaa47c40fbb71bbdea610504cd
7
- data.tar.gz: f79af533a1669fe538de22ed65bf95c3966b137f07bd6498a87e6940e561ba988909c83cdb1406f05c6a91ad72eddb26fe118c52a4c4a838d1499ae3c78664f2
6
+ metadata.gz: d6ac64d6430a97fa1040bb27f43ce63aaddf337e33b9a675f51f0e52983ec4d92beed0bc70f57d862fb1750143c0eead9a03a7737e9ba4c78ddec0e01d1c58e2
7
+ data.tar.gz: 4f974403280fb7a754727ac49d653d06661419d4afab8555c150cc21a26338a302d062056ac652d62a1d8fd62e4a3d79c584af62df899df8bf708affa7eb8d0c
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.0.7"
5
+ VERSION = "1.0.8"
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 "api_achievement_response"
3
+ require_relative "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::ApiAchievementResponse]
11
+ # @return [TrophyApiClient::AchievementResponse]
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::ApiAchievementResponse]
22
+ # @param achievement [TrophyApiClient::AchievementResponse]
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::ApiAchievementResponse.from_json(json_object: achievement)
44
+ achievement = TrophyApiClient::AchievementResponse.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::ApiAchievementResponse.validate_raw(obj: obj.achievement)
68
+ TrophyApiClient::AchievementResponse.validate_raw(obj: obj.achievement)
69
69
  end
70
70
  end
71
71
  end
@@ -1,43 +1,120 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "date"
4
+ require "ostruct"
3
5
  require "json"
4
- require_relative "metric_achievement_response"
5
- require_relative "streak_achievement_response"
6
- require_relative "api_achievement_response"
7
6
 
8
7
  module TrophyApiClient
9
8
  class AchievementResponse
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
15
+ # @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
16
+ attr_reader :achieved_at
17
+ # @return [String] The key used to reference this achievement in the API (only applicable if
18
+ # trigger = 'api')
19
+ attr_reader :key
20
+ # @return [Integer] The length of the streak required to complete the achievement (only applicable
21
+ # if trigger = 'streak')
22
+ attr_reader :streak_length
23
+ # @return [String] The ID of the metric associated with this achievement (only applicable if
24
+ # trigger = 'metric')
25
+ attr_reader :metric_id
26
+ # @return [Float] The value of the metric required to complete the achievement (only applicable if
27
+ # trigger = 'metric')
28
+ attr_reader :metric_value
29
+ # @return [String] The name of the metric associated with this achievement (only applicable if
30
+ # trigger = 'metric')
31
+ attr_reader :metric_name
32
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
33
+ attr_reader :additional_properties
34
+ # @return [Object]
35
+ attr_reader :_field_set
36
+ protected :_field_set
37
+
38
+ OMIT = Object.new
39
+
40
+ # @param id [String] The unique ID of the achievement.
41
+ # @param name [String] The name of this achievement.
42
+ # @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
43
+ # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
44
+ # @param key [String] The key used to reference this achievement in the API (only applicable if
45
+ # trigger = 'api')
46
+ # @param streak_length [Integer] The length of the streak required to complete the achievement (only applicable
47
+ # if trigger = 'streak')
48
+ # @param metric_id [String] The ID of the metric associated with this achievement (only applicable if
49
+ # trigger = 'metric')
50
+ # @param metric_value [Float] The value of the metric required to complete the achievement (only applicable if
51
+ # trigger = 'metric')
52
+ # @param metric_name [String] The name of the metric associated with this achievement (only applicable if
53
+ # trigger = 'metric')
54
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
55
+ # @return [TrophyApiClient::AchievementResponse]
56
+ def initialize(id:, name:, badge_url: OMIT, achieved_at: OMIT, key: OMIT, streak_length: OMIT, metric_id: OMIT,
57
+ metric_value: OMIT, metric_name: OMIT, additional_properties: nil)
58
+ @id = id
59
+ @name = name
60
+ @badge_url = badge_url if badge_url != OMIT
61
+ @achieved_at = achieved_at if achieved_at != OMIT
62
+ @key = key if key != OMIT
63
+ @streak_length = streak_length if streak_length != OMIT
64
+ @metric_id = metric_id if metric_id != OMIT
65
+ @metric_value = metric_value if metric_value != OMIT
66
+ @metric_name = metric_name if metric_name != OMIT
67
+ @additional_properties = additional_properties
68
+ @_field_set = {
69
+ "id": id,
70
+ "name": name,
71
+ "badgeUrl": badge_url,
72
+ "achievedAt": achieved_at,
73
+ "key": key,
74
+ "streakLength": streak_length,
75
+ "metricId": metric_id,
76
+ "metricValue": metric_value,
77
+ "metricName": metric_name
78
+ }.reject do |_k, v|
79
+ v == OMIT
80
+ end
81
+ end
82
+
10
83
  # Deserialize a JSON object to an instance of AchievementResponse
11
84
  #
12
85
  # @param json_object [String]
13
86
  # @return [TrophyApiClient::AchievementResponse]
14
87
  def self.from_json(json_object:)
15
88
  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?
89
+ parsed_json = JSON.parse(json_object)
90
+ id = parsed_json["id"]
91
+ name = parsed_json["name"]
92
+ badge_url = parsed_json["badgeUrl"]
93
+ achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
94
+ key = parsed_json["key"]
95
+ streak_length = parsed_json["streakLength"]
96
+ metric_id = parsed_json["metricId"]
97
+ metric_value = parsed_json["metricValue"]
98
+ metric_name = parsed_json["metricName"]
99
+ new(
100
+ id: id,
101
+ name: name,
102
+ badge_url: badge_url,
103
+ achieved_at: achieved_at,
104
+ key: key,
105
+ streak_length: streak_length,
106
+ metric_id: metric_id,
107
+ metric_value: metric_value,
108
+ metric_name: metric_name,
109
+ additional_properties: struct
110
+ )
111
+ end
35
112
 
36
- return nil
37
- rescue StandardError
38
- # noop
39
- end
40
- struct
113
+ # Serialize an instance of AchievementResponse to a JSON object
114
+ #
115
+ # @return [String]
116
+ def to_json(*_args)
117
+ @_field_set&.to_json
41
118
  end
42
119
 
43
120
  # Leveraged for Union-type generation, validate_raw attempts to parse the given
@@ -47,22 +124,15 @@ module TrophyApiClient
47
124
  # @param obj [Object]
48
125
  # @return [Void]
49
126
  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.")
127
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
128
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
129
+ obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
130
+ obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
131
+ obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
132
+ obj.streak_length&.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
133
+ obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
134
+ obj.metric_value&.is_a?(Float) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.")
135
+ obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
66
136
  end
67
137
  end
68
138
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "event_response_metrics_item"
3
+ require_relative "achievement_response"
4
4
  require_relative "increment_metric_streak_response"
5
5
  require "ostruct"
6
6
  require "json"
@@ -13,7 +13,7 @@ module TrophyApiClient
13
13
  attr_reader :metric_id
14
14
  # @return [Float] The user's new total progress against the metric.
15
15
  attr_reader :total
16
- # @return [Array<TrophyApiClient::EventResponseMetricsItem>] Changes to achievements as a result of this event.
16
+ # @return [Array<TrophyApiClient::AchievementResponse>] Achievements completed as a result of this event.
17
17
  attr_reader :achievements
18
18
  # @return [TrophyApiClient::IncrementMetricStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
19
19
  attr_reader :current_streak
@@ -28,7 +28,7 @@ module TrophyApiClient
28
28
  # @param event_id [String] The unique ID of the event.
29
29
  # @param metric_id [String] The unique ID of the metric that was updated.
30
30
  # @param total [Float] The user's new total progress against the metric.
31
- # @param achievements [Array<TrophyApiClient::EventResponseMetricsItem>] Changes to achievements as a result of this event.
31
+ # @param achievements [Array<TrophyApiClient::AchievementResponse>] Achievements completed as a result of this event.
32
32
  # @param current_streak [TrophyApiClient::IncrementMetricStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
33
33
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
34
34
  # @return [TrophyApiClient::EventResponse]
@@ -62,7 +62,7 @@ module TrophyApiClient
62
62
  total = parsed_json["total"]
63
63
  achievements = parsed_json["achievements"]&.map do |item|
64
64
  item = item.to_json
65
- TrophyApiClient::EventResponseMetricsItem.from_json(json_object: item)
65
+ TrophyApiClient::AchievementResponse.from_json(json_object: item)
66
66
  end
67
67
  if parsed_json["currentStreak"].nil?
68
68
  current_streak = nil
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "metric_status"
4
- require_relative "metric_achievement_response"
4
+ require_relative "achievement_response"
5
5
  require "ostruct"
6
6
  require "json"
7
7
 
@@ -17,7 +17,7 @@ module TrophyApiClient
17
17
  attr_reader :status
18
18
  # @return [Float] The user's current total for the metric.
19
19
  attr_reader :current
20
- # @return [Array<TrophyApiClient::MetricAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
20
+ # @return [Array<TrophyApiClient::AchievementResponse>] A list of the metric's achievements and the user's progress towards each.
21
21
  attr_reader :achievements
22
22
  # @return [OpenStruct] Additional properties unmapped to the current class definition
23
23
  attr_reader :additional_properties
@@ -32,7 +32,7 @@ module TrophyApiClient
32
32
  # @param name [String] The name of the metric.
33
33
  # @param status [TrophyApiClient::MetricStatus] The status of the metric.
34
34
  # @param current [Float] The user's current total for the metric.
35
- # @param achievements [Array<TrophyApiClient::MetricAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
35
+ # @param achievements [Array<TrophyApiClient::AchievementResponse>] A list of the metric's achievements and the user's progress towards each.
36
36
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
37
37
  # @return [TrophyApiClient::MetricResponse]
38
38
  def initialize(id:, key:, name:, status:, current:, achievements:, additional_properties: nil)
@@ -67,7 +67,7 @@ module TrophyApiClient
67
67
  current = parsed_json["current"]
68
68
  achievements = parsed_json["achievements"]&.map do |item|
69
69
  item = item.to_json
70
- TrophyApiClient::MetricAchievementResponse.from_json(json_object: item)
70
+ TrophyApiClient::AchievementResponse.from_json(json_object: item)
71
71
  end
72
72
  new(
73
73
  id: id,
@@ -1,3 +1,3 @@
1
1
  module MyGem
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
data/lib/types_export.rb CHANGED
@@ -6,10 +6,6 @@ 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/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
9
  require_relative "trophy_api_client/types/achievement_response"
14
10
  require_relative "trophy_api_client/types/metric_response"
15
11
  require_relative "trophy_api_client/types/updated_user"
@@ -17,6 +13,4 @@ require_relative "trophy_api_client/types/upserted_user"
17
13
  require_relative "trophy_api_client/types/user"
18
14
  require_relative "trophy_api_client/types/error_body"
19
15
  require_relative "trophy_api_client/types/achievement_completion_response"
20
- require_relative "trophy_api_client/types/event_response_metrics_item_completed_item"
21
- require_relative "trophy_api_client/types/event_response_metrics_item"
22
16
  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.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trophy Labs, Inc
@@ -103,18 +103,12 @@ files:
103
103
  - lib/trophy_api_client/metrics/client.rb
104
104
  - lib/trophy_api_client/types/achievement_completion_response.rb
105
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
108
106
  - lib/trophy_api_client/types/base_streak_response.rb
109
107
  - lib/trophy_api_client/types/error_body.rb
110
108
  - lib/trophy_api_client/types/event_response.rb
111
- - lib/trophy_api_client/types/event_response_metrics_item.rb
112
- - lib/trophy_api_client/types/event_response_metrics_item_completed_item.rb
113
109
  - lib/trophy_api_client/types/increment_metric_streak_response.rb
114
- - lib/trophy_api_client/types/metric_achievement_response.rb
115
110
  - lib/trophy_api_client/types/metric_response.rb
116
111
  - lib/trophy_api_client/types/metric_status.rb
117
- - lib/trophy_api_client/types/streak_achievement_response.rb
118
112
  - lib/trophy_api_client/types/streak_frequency.rb
119
113
  - lib/trophy_api_client/types/streak_response.rb
120
114
  - lib/trophy_api_client/types/streak_response_streak_history_item.rb
@@ -1,103 +0,0 @@
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
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "date"
4
- require "ostruct"
5
- require "json"
6
-
7
- module TrophyApiClient
8
- class BaseAchievementResponse
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
15
- # @return [String] The key used to reference this achievement in the API.
16
- attr_reader :key
17
- # @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
18
- attr_reader :achieved_at
19
- # @return [OpenStruct] Additional properties unmapped to the current class definition
20
- attr_reader :additional_properties
21
- # @return [Object]
22
- attr_reader :_field_set
23
- protected :_field_set
24
-
25
- OMIT = Object.new
26
-
27
- # @param id [String] The unique ID of the achievement.
28
- # @param name [String] The name of this achievement.
29
- # @param badge_url [String] The URL of the badge image for the achievement, if one has been uploaded.
30
- # @param key [String] The key used to reference this achievement in the API.
31
- # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
32
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
33
- # @return [TrophyApiClient::BaseAchievementResponse]
34
- def initialize(id:, name:, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil)
35
- @id = id
36
- @name = name
37
- @badge_url = badge_url if badge_url != OMIT
38
- @key = key if key != OMIT
39
- @achieved_at = achieved_at if achieved_at != OMIT
40
- @additional_properties = additional_properties
41
- @_field_set = {
42
- "id": id,
43
- "name": name,
44
- "badgeUrl": badge_url,
45
- "key": key,
46
- "achievedAt": achieved_at
47
- }.reject do |_k, v|
48
- v == OMIT
49
- end
50
- end
51
-
52
- # Deserialize a JSON object to an instance of BaseAchievementResponse
53
- #
54
- # @param json_object [String]
55
- # @return [TrophyApiClient::BaseAchievementResponse]
56
- def self.from_json(json_object:)
57
- struct = JSON.parse(json_object, object_class: OpenStruct)
58
- parsed_json = JSON.parse(json_object)
59
- id = parsed_json["id"]
60
- name = parsed_json["name"]
61
- badge_url = parsed_json["badgeUrl"]
62
- key = parsed_json["key"]
63
- achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
64
- new(
65
- id: id,
66
- name: name,
67
- badge_url: badge_url,
68
- key: key,
69
- achieved_at: achieved_at,
70
- additional_properties: struct
71
- )
72
- end
73
-
74
- # Serialize an instance of BaseAchievementResponse to a JSON object
75
- #
76
- # @return [String]
77
- def to_json(*_args)
78
- @_field_set&.to_json
79
- end
80
-
81
- # Leveraged for Union-type generation, validate_raw attempts to parse the given
82
- # hash and check each fields type against the current object's property
83
- # definitions.
84
- #
85
- # @param obj [Object]
86
- # @return [Void]
87
- def self.validate_raw(obj:)
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.")
90
- obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
91
- obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
92
- obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
93
- end
94
- end
95
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "event_response_metrics_item_completed_item"
4
- require "ostruct"
5
- require "json"
6
-
7
- module TrophyApiClient
8
- class EventResponseMetricsItem
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.
12
- attr_reader :metric_id
13
- # @return [Array<TrophyApiClient::EventResponseMetricsItemCompletedItem>] A list of any new achievements that the user has now completed as a result of
14
- # this event being submitted.
15
- attr_reader :completed
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 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
27
- # this event being submitted.
28
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
29
- # @return [TrophyApiClient::EventResponseMetricsItem]
30
- def initialize(completed:, trigger: OMIT, metric_id: OMIT, additional_properties: nil)
31
- @trigger = trigger if trigger != OMIT
32
- @metric_id = metric_id if metric_id != OMIT
33
- @completed = completed
34
- @additional_properties = additional_properties
35
- @_field_set = { "trigger": trigger, "metricId": metric_id, "completed": completed }.reject do |_k, v|
36
- v == OMIT
37
- end
38
- end
39
-
40
- # Deserialize a JSON object to an instance of EventResponseMetricsItem
41
- #
42
- # @param json_object [String]
43
- # @return [TrophyApiClient::EventResponseMetricsItem]
44
- def self.from_json(json_object:)
45
- struct = JSON.parse(json_object, object_class: OpenStruct)
46
- parsed_json = JSON.parse(json_object)
47
- trigger = parsed_json["trigger"]
48
- metric_id = parsed_json["metricId"]
49
- completed = parsed_json["completed"]&.map do |item|
50
- item = item.to_json
51
- TrophyApiClient::EventResponseMetricsItemCompletedItem.from_json(json_object: item)
52
- end
53
- new(
54
- trigger: trigger,
55
- metric_id: metric_id,
56
- completed: completed,
57
- additional_properties: struct
58
- )
59
- end
60
-
61
- # Serialize an instance of EventResponseMetricsItem to a JSON object
62
- #
63
- # @return [String]
64
- def to_json(*_args)
65
- @_field_set&.to_json
66
- end
67
-
68
- # Leveraged for Union-type generation, validate_raw attempts to parse the given
69
- # hash and check each fields type against the current object's property
70
- # definitions.
71
- #
72
- # @param obj [Object]
73
- # @return [Void]
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.")
76
- obj.metric_id&.is_a?(String) != false || raise("Passed value for field obj.metric_id 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.")
78
- end
79
- end
80
- end
@@ -1,55 +0,0 @@
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
@@ -1,130 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "date"
4
- require "ostruct"
5
- require "json"
6
-
7
- module TrophyApiClient
8
- class MetricAchievementResponse
9
- # @return [String] The trigger of the achievement, in this case always 'metric'.
10
- attr_reader :trigger
11
- # @return [String] The ID of the metric associated with this achievement, if any.
12
- attr_reader :metric_id
13
- # @return [Float] The value of the metric required to complete the achievement, if this
14
- # achievement is associated with a metric.
15
- attr_reader :metric_value
16
- # @return [String] The name of the metric associated with this achievement, if any.
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
24
- # @return [String] The key used to reference this achievement in the API.
25
- attr_reader :key
26
- # @return [DateTime] The date and time the achievement was completed, in ISO 8601 format.
27
- attr_reader :achieved_at
28
- # @return [OpenStruct] Additional properties unmapped to the current class definition
29
- attr_reader :additional_properties
30
- # @return [Object]
31
- attr_reader :_field_set
32
- protected :_field_set
33
-
34
- OMIT = Object.new
35
-
36
- # @param trigger [String] The trigger of the achievement, in this case always 'metric'.
37
- # @param metric_id [String] The ID of the metric associated with this achievement, if any.
38
- # @param metric_value [Float] The value of the metric required to complete the achievement, if this
39
- # achievement is associated with a metric.
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.
44
- # @param key [String] The key used to reference this achievement in the API.
45
- # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
46
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
47
- # @return [TrophyApiClient::MetricAchievementResponse]
48
- def initialize(trigger:, metric_id:, metric_value:, metric_name:, id:, name:, badge_url: OMIT, key: OMIT,
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
54
- @id = id
55
- @name = name
56
- @badge_url = badge_url if badge_url != OMIT
57
- @key = key if key != OMIT
58
- @achieved_at = achieved_at if achieved_at != OMIT
59
- @additional_properties = additional_properties
60
- @_field_set = {
61
- "trigger": trigger,
62
- "metricId": metric_id,
63
- "metricValue": metric_value,
64
- "metricName": metric_name,
65
- "id": id,
66
- "name": name,
67
- "badgeUrl": badge_url,
68
- "key": key,
69
- "achievedAt": achieved_at
70
- }.reject do |_k, v|
71
- v == OMIT
72
- end
73
- end
74
-
75
- # Deserialize a JSON object to an instance of MetricAchievementResponse
76
- #
77
- # @param json_object [String]
78
- # @return [TrophyApiClient::MetricAchievementResponse]
79
- def self.from_json(json_object:)
80
- struct = JSON.parse(json_object, object_class: OpenStruct)
81
- parsed_json = JSON.parse(json_object)
82
- trigger = parsed_json["trigger"]
83
- metric_id = parsed_json["metricId"]
84
- metric_value = parsed_json["metricValue"]
85
- metric_name = parsed_json["metricName"]
86
- id = parsed_json["id"]
87
- name = parsed_json["name"]
88
- badge_url = parsed_json["badgeUrl"]
89
- key = parsed_json["key"]
90
- achieved_at = (DateTime.parse(parsed_json["achievedAt"]) unless parsed_json["achievedAt"].nil?)
91
- new(
92
- trigger: trigger,
93
- metric_id: metric_id,
94
- metric_value: metric_value,
95
- metric_name: metric_name,
96
- id: id,
97
- name: name,
98
- badge_url: badge_url,
99
- key: key,
100
- achieved_at: achieved_at,
101
- additional_properties: struct
102
- )
103
- end
104
-
105
- # Serialize an instance of MetricAchievementResponse to a JSON object
106
- #
107
- # @return [String]
108
- def to_json(*_args)
109
- @_field_set&.to_json
110
- end
111
-
112
- # Leveraged for Union-type generation, validate_raw attempts to parse the given
113
- # hash and check each fields type against the current object's property
114
- # definitions.
115
- #
116
- # @param obj [Object]
117
- # @return [Void]
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.")
123
- obj.id.is_a?(String) != false || raise("Passed value for field obj.id 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.")
125
- obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
126
- obj.key&.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
127
- obj.achieved_at&.is_a?(DateTime) != false || raise("Passed value for field obj.achieved_at is not the expected type, validation failed.")
128
- end
129
- end
130
- end
@@ -1,112 +0,0 @@
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