trophy_api_client 1.0.2 → 1.0.3

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: 3a67cfb83b6601c4c488aa3ff95b578d33681982787c38e6448370eabaac987e
4
- data.tar.gz: 9bde2c23199a0523fe99c350f155f9f6e79ac9a546663320ab2a2d1c6d62b995
3
+ metadata.gz: 3f97c407f35241fca730a7bf516b0e1e3d15d910710cd29dc75893d2d7f263ba
4
+ data.tar.gz: 5479b66a74a2904ceadcf8607833433a0a370dd85ef18c37227e949044d6074f
5
5
  SHA512:
6
- metadata.gz: 55cddb862ad713aba47db324c6f71f6b8c0f90a00ba2715f8917aafdef44ee43a0194a799c76717de6c24df518b532fb9c9fb40014ad26d6e430247feb65f02f
7
- data.tar.gz: bd5e48a39c140ee9a0ea3dd9c7a9eaebc937a226002776dbe1834290d13389fd42c8140a5fe3eb3a4f8b8d595197b447029ce8dd919711f42d07626778dd3c1b
6
+ metadata.gz: bf4906e28af4867b0eb7ae5582bb8060618a3effcb479d6fff0865d18bd61e3478a6492b6afcf66c06a0bba7cbf55f060909c1a33c6b261d338440c32a3a2990
7
+ data.tar.gz: df54eaff66af36b4227ff5d8113a444fcac229afb65be84e8848d3defa00a7725d8e68362507dc821c1ac743130916cfedd8cda212865cf1d73da26bb71d63d6
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.3"
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 "achievement_response"
3
+ require_relative "one_off_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::AchievementResponse]
11
+ # @return [TrophyApiClient::OneOffAchievementResponse]
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::AchievementResponse]
22
+ # @param achievement [TrophyApiClient::OneOffAchievementResponse]
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::AchievementResponse.from_json(json_object: achievement)
44
+ achievement = TrophyApiClient::OneOffAchievementResponse.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::AchievementResponse.validate_raw(obj: obj.achievement)
68
+ TrophyApiClient::OneOffAchievementResponse.validate_raw(obj: obj.achievement)
69
69
  end
70
70
  end
71
71
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "achievement_response"
3
+ require_relative "multi_stage_achievement_response"
4
4
  require "ostruct"
5
5
  require "json"
6
6
 
@@ -8,7 +8,7 @@ module TrophyApiClient
8
8
  class EventResponseMetricsItem
9
9
  # @return [String] The ID of the metric.
10
10
  attr_reader :metric_id
11
- # @return [Array<TrophyApiClient::AchievementResponse>] A list of any new achievements that the user has now completed as a result of
11
+ # @return [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of any new achievements that the user has now completed as a result of
12
12
  # this event being submitted.
13
13
  attr_reader :completed
14
14
  # @return [OpenStruct] Additional properties unmapped to the current class definition
@@ -20,7 +20,7 @@ module TrophyApiClient
20
20
  OMIT = Object.new
21
21
 
22
22
  # @param metric_id [String] The ID of the metric.
23
- # @param completed [Array<TrophyApiClient::AchievementResponse>] A list of any new achievements that the user has now completed as a result of
23
+ # @param completed [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of any new achievements that the user has now completed as a result of
24
24
  # this event being submitted.
25
25
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
26
26
  # @return [TrophyApiClient::EventResponseMetricsItem]
@@ -43,7 +43,7 @@ module TrophyApiClient
43
43
  metric_id = parsed_json["metricId"]
44
44
  completed = parsed_json["completed"]&.map do |item|
45
45
  item = item.to_json
46
- TrophyApiClient::AchievementResponse.from_json(json_object: item)
46
+ TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
47
47
  end
48
48
  new(
49
49
  metric_id: metric_id,
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "streak_frequency"
4
4
  require_relative "metric_status"
5
- require_relative "achievement_response"
5
+ require_relative "multi_stage_achievement_response"
6
6
  require_relative "streak_response"
7
7
  require "ostruct"
8
8
  require "json"
@@ -23,7 +23,7 @@ module TrophyApiClient
23
23
  attr_reader :status
24
24
  # @return [Float] The user's current total for the metric.
25
25
  attr_reader :current
26
- # @return [Array<TrophyApiClient::AchievementResponse>] A list of the metric's achievements and the user's progress towards each.
26
+ # @return [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
27
27
  attr_reader :achievements
28
28
  # @return [TrophyApiClient::StreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
29
29
  attr_reader :current_streak
@@ -42,7 +42,7 @@ module TrophyApiClient
42
42
  # @param streak_frequency [TrophyApiClient::StreakFrequency] The frequency of the streak.
43
43
  # @param status [TrophyApiClient::MetricStatus] The status of the metric.
44
44
  # @param current [Float] The user's current total for the metric.
45
- # @param achievements [Array<TrophyApiClient::AchievementResponse>] A list of the metric's achievements and the user's progress towards each.
45
+ # @param achievements [Array<TrophyApiClient::MultiStageAchievementResponse>] A list of the metric's achievements and the user's progress towards each.
46
46
  # @param current_streak [TrophyApiClient::StreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
47
47
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
48
48
  # @return [TrophyApiClient::MetricResponse]
@@ -89,7 +89,7 @@ module TrophyApiClient
89
89
  current = parsed_json["current"]
90
90
  achievements = parsed_json["achievements"]&.map do |item|
91
91
  item = item.to_json
92
- TrophyApiClient::AchievementResponse.from_json(json_object: item)
92
+ TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
93
93
  end
94
94
  if parsed_json["currentStreak"].nil?
95
95
  current_streak = nil
@@ -5,7 +5,7 @@ require "ostruct"
5
5
  require "json"
6
6
 
7
7
  module TrophyApiClient
8
- class AchievementResponse
8
+ class MultiStageAchievementResponse
9
9
  # @return [String] The unique ID of the achievement.
10
10
  attr_reader :id
11
11
  # @return [String] The name of this achievement.
@@ -41,7 +41,7 @@ module TrophyApiClient
41
41
  # @param key [String] The key used to reference this achievement in the API.
42
42
  # @param achieved_at [DateTime] The date and time the achievement was completed, in ISO 8601 format.
43
43
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
44
- # @return [TrophyApiClient::AchievementResponse]
44
+ # @return [TrophyApiClient::MultiStageAchievementResponse]
45
45
  def initialize(id:, name: OMIT, badge_url: OMIT, metric_id: OMIT, metric_value: OMIT, metric_name: OMIT, key: OMIT,
46
46
  achieved_at: OMIT, additional_properties: nil)
47
47
  @id = id
@@ -67,10 +67,10 @@ module TrophyApiClient
67
67
  end
68
68
  end
69
69
 
70
- # Deserialize a JSON object to an instance of AchievementResponse
70
+ # Deserialize a JSON object to an instance of MultiStageAchievementResponse
71
71
  #
72
72
  # @param json_object [String]
73
- # @return [TrophyApiClient::AchievementResponse]
73
+ # @return [TrophyApiClient::MultiStageAchievementResponse]
74
74
  def self.from_json(json_object:)
75
75
  struct = JSON.parse(json_object, object_class: OpenStruct)
76
76
  parsed_json = JSON.parse(json_object)
@@ -95,7 +95,7 @@ module TrophyApiClient
95
95
  )
96
96
  end
97
97
 
98
- # Serialize an instance of AchievementResponse to a JSON object
98
+ # Serialize an instance of MultiStageAchievementResponse to a JSON object
99
99
  #
100
100
  # @return [String]
101
101
  def to_json(*_args)
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ class OneOffAchievementResponse
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::OneOffAchievementResponse]
34
+ def initialize(id:, name: OMIT, badge_url: OMIT, key: OMIT, achieved_at: OMIT, additional_properties: nil)
35
+ @id = id
36
+ @name = name if name != OMIT
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 OneOffAchievementResponse
53
+ #
54
+ # @param json_object [String]
55
+ # @return [TrophyApiClient::OneOffAchievementResponse]
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 OneOffAchievementResponse 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
@@ -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/achievement_response"
9
+ require_relative "../types/multi_stage_achievement_response"
10
10
  require "async"
11
11
 
12
12
  module TrophyApiClient
@@ -20,7 +20,7 @@ module TrophyApiClient
20
20
  @request_client = request_client
21
21
  end
22
22
 
23
- # Create a new user.
23
+ # Identify a new user.
24
24
  #
25
25
  # @param request [Hash] The user object.Request of type TrophyApiClient::UpsertedUser, as a Hash
26
26
  # * :id (String)
@@ -195,7 +195,7 @@ module TrophyApiClient
195
195
  #
196
196
  # @param id [String] ID of the user.
197
197
  # @param request_options [TrophyApiClient::RequestOptions]
198
- # @return [Array<TrophyApiClient::AchievementResponse>]
198
+ # @return [Array<TrophyApiClient::MultiStageAchievementResponse>]
199
199
  # @example
200
200
  # api = TrophyApiClient::Client.new(
201
201
  # base_url: "https://api.example.com",
@@ -223,7 +223,7 @@ module TrophyApiClient
223
223
  parsed_json = JSON.parse(response.body)
224
224
  parsed_json&.map do |item|
225
225
  item = item.to_json
226
- TrophyApiClient::AchievementResponse.from_json(json_object: item)
226
+ TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
227
227
  end
228
228
  end
229
229
  end
@@ -238,7 +238,7 @@ module TrophyApiClient
238
238
  @request_client = request_client
239
239
  end
240
240
 
241
- # Create a new user.
241
+ # Identify a new user.
242
242
  #
243
243
  # @param request [Hash] The user object.Request of type TrophyApiClient::UpsertedUser, as a Hash
244
244
  # * :id (String)
@@ -423,7 +423,7 @@ module TrophyApiClient
423
423
  #
424
424
  # @param id [String] ID of the user.
425
425
  # @param request_options [TrophyApiClient::RequestOptions]
426
- # @return [Array<TrophyApiClient::AchievementResponse>]
426
+ # @return [Array<TrophyApiClient::MultiStageAchievementResponse>]
427
427
  # @example
428
428
  # api = TrophyApiClient::Client.new(
429
429
  # base_url: "https://api.example.com",
@@ -452,7 +452,7 @@ module TrophyApiClient
452
452
  parsed_json = JSON.parse(response.body)
453
453
  parsed_json&.map do |item|
454
454
  item = item.to_json
455
- TrophyApiClient::AchievementResponse.from_json(json_object: item)
455
+ TrophyApiClient::MultiStageAchievementResponse.from_json(json_object: item)
456
456
  end
457
457
  end
458
458
  end
@@ -1,3 +1,3 @@
1
1
  module MyGem
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
data/lib/types_export.rb CHANGED
@@ -3,7 +3,8 @@
3
3
  require_relative "trophy_api_client/types/metric_status"
4
4
  require_relative "trophy_api_client/types/streak_frequency"
5
5
  require_relative "trophy_api_client/types/streak_response"
6
- require_relative "trophy_api_client/types/achievement_response"
6
+ require_relative "trophy_api_client/types/multi_stage_achievement_response"
7
+ require_relative "trophy_api_client/types/one_off_achievement_response"
7
8
  require_relative "trophy_api_client/types/metric_response"
8
9
  require_relative "trophy_api_client/types/updated_user"
9
10
  require_relative "trophy_api_client/types/upserted_user"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trophy_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trophy Labs, Inc
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-30 00:00:00.000000000 Z
10
+ date: 2025-04-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async-http-faraday
@@ -102,12 +102,13 @@ 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
105
  - lib/trophy_api_client/types/error_body.rb
107
106
  - lib/trophy_api_client/types/event_response.rb
108
107
  - lib/trophy_api_client/types/event_response_metrics_item.rb
109
108
  - lib/trophy_api_client/types/metric_response.rb
110
109
  - lib/trophy_api_client/types/metric_status.rb
110
+ - lib/trophy_api_client/types/multi_stage_achievement_response.rb
111
+ - lib/trophy_api_client/types/one_off_achievement_response.rb
111
112
  - lib/trophy_api_client/types/streak_frequency.rb
112
113
  - lib/trophy_api_client/types/streak_response.rb
113
114
  - lib/trophy_api_client/types/updated_user.rb