trophy_api_client 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85edf38a9fc0522a22a62f4e7ad27600c2e1b7376c0fc951d67f2ce590a8fe93
4
- data.tar.gz: a5306d1ea30e6ead932faa97c59ca02dca59106e4364c5e715ff45c319913b36
3
+ metadata.gz: 53980f53595d29d00f98c8417ae38f192c42eb899139036238aff75acd9a8b5a
4
+ data.tar.gz: fd0a8b34d06eea9ea76d68278384a6dff6189543d8288679b8965632ac3f8bde
5
5
  SHA512:
6
- metadata.gz: f9aaf222f94a5076cd95a0c58285b989557211d858804472ac0742cb17afccf1ebd94c77b637d9cfd3381915c9f9df758a05787ae17a0de57403bdd8747c0c9e
7
- data.tar.gz: 0bc86ae13782e710a68162a51a7be4e56f7f83bdae39083343d9b9e6b60dad9e3ff7ef1a017ff1ec72a39cd5e104ede0358979d78dd48077dc0c5e7f03883ea2
6
+ metadata.gz: a05179e86d3577f0ac681e87434b3c8260bd46de6f0233b69a65afc2802330fe6421c5cdb5f54e7dad967c7528381b9cd66291f9de833f38c2161430e8aba87a
7
+ data.tar.gz: 8821f372ad08068762223ba56af83134916e901f653988ce816626cbdf5f39c403be07d99f9736bab53a8f8621e531742a3c241219030b453642941ca120cd13
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.11.0"
5
+ VERSION = "1.12.0"
6
6
  AUTHORS = ["Trophy Labs, Inc"].freeze
7
7
  EMAIL = ""
8
8
  SUMMARY = "Ruby library for the Trophy API."
@@ -3,8 +3,6 @@
3
3
  require_relative "../../requests"
4
4
  require_relative "../types/bulk_streak_response"
5
5
  require "json"
6
- require_relative "types/streaks_rankings_request_type"
7
- require_relative "../types/streak_ranking_user"
8
6
  require "async"
9
7
 
10
8
  module TrophyApiClient
@@ -53,42 +51,6 @@ module TrophyApiClient
53
51
  TrophyApiClient::BulkStreakResponseItem.from_json(json_object: item)
54
52
  end
55
53
  end
56
-
57
- # Get the top users by streak length (active or longest).
58
- #
59
- # @param limit [Integer] Number of users to return. Must be between 1 and 100.
60
- # @param type [TrophyApiClient::Streaks::StreaksRankingsRequestType] Whether to rank users by active streaks or longest streaks ever achieved.
61
- # @param request_options [TrophyApiClient::RequestOptions]
62
- # @return [Array<TrophyApiClient::StreakRankingUser>]
63
- # @example
64
- # api = TrophyApiClient::Client.new(
65
- # base_url: "https://api.example.com",
66
- # environment: TrophyApiClient::Environment::PRODUCTION,
67
- # api_key: "YOUR_API_KEY"
68
- # )
69
- # api.streaks.rankings(limit: 1, type: ACTIVE)
70
- def rankings(limit: nil, type: nil, request_options: nil)
71
- response = @request_client.conn.get do |req|
72
- req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
73
- req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
74
- req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
75
- req.headers = {
76
- **(req.headers || {}),
77
- **@request_client.get_headers,
78
- **(request_options&.additional_headers || {})
79
- }.compact
80
- req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "type": type }.compact
81
- unless request_options.nil? || request_options&.additional_body_parameters.nil?
82
- req.body = { **(request_options&.additional_body_parameters || {}) }.compact
83
- end
84
- req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/streaks/rankings"
85
- end
86
- parsed_json = JSON.parse(response.body)
87
- parsed_json&.map do |item|
88
- item = item.to_json
89
- TrophyApiClient::StreakRankingUser.from_json(json_object: item)
90
- end
91
- end
92
54
  end
93
55
 
94
56
  class AsyncStreaksClient
@@ -138,43 +100,5 @@ module TrophyApiClient
138
100
  end
139
101
  end
140
102
  end
141
-
142
- # Get the top users by streak length (active or longest).
143
- #
144
- # @param limit [Integer] Number of users to return. Must be between 1 and 100.
145
- # @param type [TrophyApiClient::Streaks::StreaksRankingsRequestType] Whether to rank users by active streaks or longest streaks ever achieved.
146
- # @param request_options [TrophyApiClient::RequestOptions]
147
- # @return [Array<TrophyApiClient::StreakRankingUser>]
148
- # @example
149
- # api = TrophyApiClient::Client.new(
150
- # base_url: "https://api.example.com",
151
- # environment: TrophyApiClient::Environment::PRODUCTION,
152
- # api_key: "YOUR_API_KEY"
153
- # )
154
- # api.streaks.rankings(limit: 1, type: ACTIVE)
155
- def rankings(limit: nil, type: nil, request_options: nil)
156
- Async do
157
- response = @request_client.conn.get do |req|
158
- req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
159
- req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
160
- req.headers["Tenant-ID"] = request_options.tenant_id unless request_options&.tenant_id.nil?
161
- req.headers = {
162
- **(req.headers || {}),
163
- **@request_client.get_headers,
164
- **(request_options&.additional_headers || {})
165
- }.compact
166
- req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "type": type }.compact
167
- unless request_options.nil? || request_options&.additional_body_parameters.nil?
168
- req.body = { **(request_options&.additional_body_parameters || {}) }.compact
169
- end
170
- req.url "#{@request_client.get_url(environment: api, request_options: request_options)}/streaks/rankings"
171
- end
172
- parsed_json = JSON.parse(response.body)
173
- parsed_json&.map do |item|
174
- item = item.to_json
175
- TrophyApiClient::StreakRankingUser.from_json(json_object: item)
176
- end
177
- end
178
- end
179
103
  end
180
104
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "date"
3
4
  require_relative "streak_response_streak_history_item"
4
5
  require_relative "streak_frequency"
5
6
  require "ostruct"
@@ -8,12 +9,12 @@ require "json"
8
9
  module TrophyApiClient
9
10
  # An object representing the user's streak.
10
11
  class StreakResponse
12
+ # @return [DateTime] The timestamp the streak was most recently extended. Null if the streak is not
13
+ # active.
14
+ attr_reader :extended
11
15
  # @return [Array<TrophyApiClient::StreakResponseStreakHistoryItem>] A list of the user's past streak periods up through the current period. Each
12
16
  # period includes the start and end dates and the length of the streak.
13
17
  attr_reader :streak_history
14
- # @return [Integer] Deprecated. The user's rank across all users. Null if the user has no active
15
- # streak.
16
- attr_reader :rank
17
18
  # @return [Integer] The length of the user's current streak.
18
19
  attr_reader :length
19
20
  # @return [TrophyApiClient::StreakFrequency] The frequency of the streak.
@@ -46,10 +47,10 @@ module TrophyApiClient
46
47
 
47
48
  OMIT = Object.new
48
49
 
50
+ # @param extended [DateTime] The timestamp the streak was most recently extended. Null if the streak is not
51
+ # active.
49
52
  # @param streak_history [Array<TrophyApiClient::StreakResponseStreakHistoryItem>] A list of the user's past streak periods up through the current period. Each
50
53
  # period includes the start and end dates and the length of the streak.
51
- # @param rank [Integer] Deprecated. The user's rank across all users. Null if the user has no active
52
- # streak.
53
54
  # @param length [Integer] The length of the user's current streak.
54
55
  # @param frequency [TrophyApiClient::StreakFrequency] The frequency of the streak.
55
56
  # @param started [String] The date the streak started.
@@ -66,10 +67,10 @@ module TrophyApiClient
66
67
  # the organization has enabled streak freeze auto-earn.
67
68
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
68
69
  # @return [TrophyApiClient::StreakResponse]
69
- def initialize(length:, frequency:, streak_history: OMIT, rank: OMIT, started: OMIT, period_start: OMIT,
70
+ def initialize(streak_history:, length:, frequency:, extended: OMIT, started: OMIT, period_start: OMIT,
70
71
  period_end: OMIT, expires: OMIT, freezes: OMIT, max_freezes: OMIT, freeze_auto_earn_interval: OMIT, freeze_auto_earn_amount: OMIT, additional_properties: nil)
71
- @streak_history = streak_history if streak_history != OMIT
72
- @rank = rank if rank != OMIT
72
+ @extended = extended if extended != OMIT
73
+ @streak_history = streak_history
73
74
  @length = length
74
75
  @frequency = frequency
75
76
  @started = started if started != OMIT
@@ -82,8 +83,8 @@ module TrophyApiClient
82
83
  @freeze_auto_earn_amount = freeze_auto_earn_amount if freeze_auto_earn_amount != OMIT
83
84
  @additional_properties = additional_properties
84
85
  @_field_set = {
86
+ "extended": extended,
85
87
  "streakHistory": streak_history,
86
- "rank": rank,
87
88
  "length": length,
88
89
  "frequency": frequency,
89
90
  "started": started,
@@ -106,11 +107,11 @@ module TrophyApiClient
106
107
  def self.from_json(json_object:)
107
108
  struct = JSON.parse(json_object, object_class: OpenStruct)
108
109
  parsed_json = JSON.parse(json_object)
110
+ extended = (DateTime.parse(parsed_json["extended"]) unless parsed_json["extended"].nil?)
109
111
  streak_history = parsed_json["streakHistory"]&.map do |item|
110
112
  item = item.to_json
111
113
  TrophyApiClient::StreakResponseStreakHistoryItem.from_json(json_object: item)
112
114
  end
113
- rank = parsed_json["rank"]
114
115
  length = parsed_json["length"]
115
116
  frequency = parsed_json["frequency"]
116
117
  started = parsed_json["started"]
@@ -122,8 +123,8 @@ module TrophyApiClient
122
123
  freeze_auto_earn_interval = parsed_json["freezeAutoEarnInterval"]
123
124
  freeze_auto_earn_amount = parsed_json["freezeAutoEarnAmount"]
124
125
  new(
126
+ extended: extended,
125
127
  streak_history: streak_history,
126
- rank: rank,
127
128
  length: length,
128
129
  frequency: frequency,
129
130
  started: started,
@@ -152,8 +153,8 @@ module TrophyApiClient
152
153
  # @param obj [Object]
153
154
  # @return [Void]
154
155
  def self.validate_raw(obj:)
155
- obj.streak_history&.is_a?(Array) != false || raise("Passed value for field obj.streak_history is not the expected type, validation failed.")
156
- obj.rank&.is_a?(Integer) != false || raise("Passed value for field obj.rank is not the expected type, validation failed.")
156
+ obj.extended&.is_a?(DateTime) != false || raise("Passed value for field obj.extended is not the expected type, validation failed.")
157
+ obj.streak_history.is_a?(Array) != false || raise("Passed value for field obj.streak_history is not the expected type, validation failed.")
157
158
  obj.length.is_a?(Integer) != false || raise("Passed value for field obj.length is not the expected type, validation failed.")
158
159
  obj.frequency.is_a?(TrophyApiClient::StreakFrequency) != false || raise("Passed value for field obj.frequency is not the expected type, validation failed.")
159
160
  obj.started&.is_a?(String) != false || raise("Passed value for field obj.started is not the expected type, validation failed.")
@@ -1,3 +1,3 @@
1
1
  module MyGem
2
- VERSION = "1.11.0"
2
+ VERSION = "1.12.0"
3
3
  end
data/lib/types_export.rb CHANGED
@@ -4,7 +4,6 @@ require_relative "trophy_api_client/users/types/users_metric_event_summary_reque
4
4
  require_relative "trophy_api_client/users/types/users_metric_event_summary_response_item"
5
5
  require_relative "trophy_api_client/users/types/users_points_event_summary_request_aggregation"
6
6
  require_relative "trophy_api_client/users/types/users_points_event_summary_response_item"
7
- require_relative "trophy_api_client/streaks/types/streaks_rankings_request_type"
8
7
  require_relative "trophy_api_client/leaderboards/types/leaderboards_all_response_item_status"
9
8
  require_relative "trophy_api_client/leaderboards/types/leaderboards_all_response_item"
10
9
  require_relative "trophy_api_client/admin/streaks/types/restore_streaks_request_users_item"
@@ -79,7 +78,6 @@ require_relative "trophy_api_client/types/event_response"
79
78
  require_relative "trophy_api_client/types/points_range"
80
79
  require_relative "trophy_api_client/types/points_summary_response"
81
80
  require_relative "trophy_api_client/types/points_system_response"
82
- require_relative "trophy_api_client/types/streak_ranking_user"
83
81
  require_relative "trophy_api_client/types/leaderboard_ranking"
84
82
  require_relative "trophy_api_client/types/leaderboard_event"
85
83
  require_relative "trophy_api_client/types/user_leaderboard_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.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trophy Labs, Inc
@@ -120,7 +120,6 @@ files:
120
120
  - lib/trophy_api_client/metrics/client.rb
121
121
  - lib/trophy_api_client/points/client.rb
122
122
  - lib/trophy_api_client/streaks/client.rb
123
- - lib/trophy_api_client/streaks/types/streaks_rankings_request_type.rb
124
123
  - lib/trophy_api_client/types/achievement_completion_response.rb
125
124
  - lib/trophy_api_client/types/achievement_response.rb
126
125
  - lib/trophy_api_client/types/achievement_response_event_attribute.rb
@@ -272,7 +271,6 @@ files:
272
271
  - lib/trophy_api_client/types/points_trigger_user_attributes_item.rb
273
272
  - lib/trophy_api_client/types/restore_streaks_response.rb
274
273
  - lib/trophy_api_client/types/streak_frequency.rb
275
- - lib/trophy_api_client/types/streak_ranking_user.rb
276
274
  - lib/trophy_api_client/types/streak_response.rb
277
275
  - lib/trophy_api_client/types/streak_response_streak_history_item.rb
278
276
  - lib/trophy_api_client/types/update_attribute_request_item.rb
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module TrophyApiClient
4
- class Streaks
5
- class StreaksRankingsRequestType
6
- ACTIVE = "active"
7
- LONGEST = "longest"
8
- end
9
- end
10
- end
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "ostruct"
4
- require "json"
5
-
6
- module TrophyApiClient
7
- # A user with their streak length in the rankings.
8
- class StreakRankingUser
9
- # @return [String] The ID of the user.
10
- attr_reader :user_id
11
- # @return [String] The name of the user. May be null if no name is set.
12
- attr_reader :name
13
- # @return [Integer] The user's streak length (active or longest depending on query parameter).
14
- attr_reader :streak_length
15
- # @return [OpenStruct] Additional properties unmapped to the current class definition
16
- attr_reader :additional_properties
17
- # @return [Object]
18
- attr_reader :_field_set
19
- protected :_field_set
20
-
21
- OMIT = Object.new
22
-
23
- # @param user_id [String] The ID of the user.
24
- # @param name [String] The name of the user. May be null if no name is set.
25
- # @param streak_length [Integer] The user's streak length (active or longest depending on query parameter).
26
- # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
- # @return [TrophyApiClient::StreakRankingUser]
28
- def initialize(user_id:, streak_length:, name: OMIT, additional_properties: nil)
29
- @user_id = user_id
30
- @name = name if name != OMIT
31
- @streak_length = streak_length
32
- @additional_properties = additional_properties
33
- @_field_set = { "userId": user_id, "name": name, "streakLength": streak_length }.reject do |_k, v|
34
- v == OMIT
35
- end
36
- end
37
-
38
- # Deserialize a JSON object to an instance of StreakRankingUser
39
- #
40
- # @param json_object [String]
41
- # @return [TrophyApiClient::StreakRankingUser]
42
- def self.from_json(json_object:)
43
- struct = JSON.parse(json_object, object_class: OpenStruct)
44
- parsed_json = JSON.parse(json_object)
45
- user_id = parsed_json["userId"]
46
- name = parsed_json["name"]
47
- streak_length = parsed_json["streakLength"]
48
- new(
49
- user_id: user_id,
50
- name: name,
51
- streak_length: streak_length,
52
- additional_properties: struct
53
- )
54
- end
55
-
56
- # Serialize an instance of StreakRankingUser to a JSON object
57
- #
58
- # @return [String]
59
- def to_json(*_args)
60
- @_field_set&.to_json
61
- end
62
-
63
- # Leveraged for Union-type generation, validate_raw attempts to parse the given
64
- # hash and check each fields type against the current object's property
65
- # definitions.
66
- #
67
- # @param obj [Object]
68
- # @return [Void]
69
- def self.validate_raw(obj:)
70
- obj.user_id.is_a?(String) != false || raise("Passed value for field obj.user_id is not the expected type, validation failed.")
71
- obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
72
- obj.streak_length.is_a?(Integer) != false || raise("Passed value for field obj.streak_length is not the expected type, validation failed.")
73
- end
74
- end
75
- end