trophy_api_client 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gemconfig.rb +1 -1
- data/lib/trophy_api_client/achievements/client.rb +79 -7
- data/lib/trophy_api_client/points/client.rb +175 -0
- data/lib/trophy_api_client/types/achievement_completion_response.rb +5 -5
- data/lib/trophy_api_client/types/achievement_response.rb +29 -15
- data/lib/trophy_api_client/types/achievement_response_trigger.rb +10 -0
- data/lib/trophy_api_client/types/achievement_with_stats_response.rb +176 -0
- data/lib/trophy_api_client/types/completed_achievement_response.rb +169 -0
- data/lib/trophy_api_client/types/event_response.rb +28 -11
- data/lib/trophy_api_client/types/get_user_points_response.rb +71 -0
- data/lib/trophy_api_client/types/metric_event_points_response.rb +78 -0
- data/lib/trophy_api_client/types/{increment_metric_streak_response.rb → metric_event_streak_response.rb} +6 -6
- data/lib/trophy_api_client/types/metric_response.rb +4 -4
- data/lib/trophy_api_client/types/points_award.rb +80 -0
- data/lib/trophy_api_client/types/points_range.rb +74 -0
- data/lib/trophy_api_client/types/points_summary_response.rb +7 -0
- data/lib/trophy_api_client/types/points_trigger.rb +116 -0
- data/lib/trophy_api_client/types/points_trigger_response.rb +164 -0
- data/lib/trophy_api_client/types/points_trigger_response_status.rb +9 -0
- data/lib/trophy_api_client/types/points_trigger_response_type.rb +10 -0
- data/lib/trophy_api_client/types/points_trigger_type.rb +10 -0
- data/lib/trophy_api_client/users/client.rb +278 -5
- data/lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb +11 -0
- data/lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb +76 -0
- data/lib/trophy_api_client/users/types/users_points_event_summary_request_aggregation.rb +11 -0
- data/lib/trophy_api_client/users/types/users_points_event_summary_response_item.rb +76 -0
- data/lib/trophy_api_client/version.rb +1 -1
- data/lib/trophy_api_client.rb +7 -0
- data/lib/types_export.rb +18 -1
- metadata +20 -2
@@ -6,8 +6,13 @@ 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 "
|
9
|
+
require_relative "types/users_metric_event_summary_request_aggregation"
|
10
|
+
require_relative "types/users_metric_event_summary_response_item"
|
11
|
+
require_relative "../types/completed_achievement_response"
|
10
12
|
require_relative "../types/streak_response"
|
13
|
+
require_relative "../types/get_user_points_response"
|
14
|
+
require_relative "types/users_points_event_summary_request_aggregation"
|
15
|
+
require_relative "types/users_points_event_summary_response_item"
|
11
16
|
require "async"
|
12
17
|
|
13
18
|
module TrophyApiClient
|
@@ -192,11 +197,62 @@ module TrophyApiClient
|
|
192
197
|
TrophyApiClient::MetricResponse.from_json(json_object: response.body)
|
193
198
|
end
|
194
199
|
|
200
|
+
# Get a summary of metric events over time for a user.
|
201
|
+
#
|
202
|
+
# @param id [String] ID of the user.
|
203
|
+
# @param key [String] Unique key of the metric.
|
204
|
+
# @param aggregation [TrophyApiClient::Users::UsersMetricEventSummaryRequestAggregation] The time period over which to aggregate the event data.
|
205
|
+
# @param start_date [String] The start date for the data range in YYYY-MM-DD format. The startDate must be
|
206
|
+
# before the endDate, and the date range must not exceed 400 days.
|
207
|
+
# @param end_date [String] The end date for the data range in YYYY-MM-DD format. The endDate must be after
|
208
|
+
# the startDate, and the date range must not exceed 400 days.
|
209
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
210
|
+
# @return [Array<TrophyApiClient::Users::UsersMetricEventSummaryResponseItem>]
|
211
|
+
# @example
|
212
|
+
# api = TrophyApiClient::Client.new(
|
213
|
+
# base_url: "https://api.example.com",
|
214
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
215
|
+
# api_key: "YOUR_API_KEY"
|
216
|
+
# )
|
217
|
+
# api.users.metric_event_summary(
|
218
|
+
# id: "userId",
|
219
|
+
# key: "words-written",
|
220
|
+
# aggregation: DAILY,
|
221
|
+
# start_date: "2024-01-01",
|
222
|
+
# end_date: "2024-01-31"
|
223
|
+
# )
|
224
|
+
def metric_event_summary(id:, key:, aggregation:, start_date:, end_date:, request_options: nil)
|
225
|
+
response = @request_client.conn.get do |req|
|
226
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
227
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
228
|
+
req.headers = {
|
229
|
+
**(req.headers || {}),
|
230
|
+
**@request_client.get_headers,
|
231
|
+
**(request_options&.additional_headers || {})
|
232
|
+
}.compact
|
233
|
+
req.params = {
|
234
|
+
**(request_options&.additional_query_parameters || {}),
|
235
|
+
"aggregation": aggregation,
|
236
|
+
"startDate": start_date,
|
237
|
+
"endDate": end_date
|
238
|
+
}.compact
|
239
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
240
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
241
|
+
end
|
242
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/metrics/#{key}/event-summary"
|
243
|
+
end
|
244
|
+
parsed_json = JSON.parse(response.body)
|
245
|
+
parsed_json&.map do |item|
|
246
|
+
item = item.to_json
|
247
|
+
TrophyApiClient::Users::UsersMetricEventSummaryResponseItem.from_json(json_object: item)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
195
251
|
# Get all of a user's completed achievements.
|
196
252
|
#
|
197
253
|
# @param id [String] ID of the user.
|
198
254
|
# @param request_options [TrophyApiClient::RequestOptions]
|
199
|
-
# @return [Array<TrophyApiClient::
|
255
|
+
# @return [Array<TrophyApiClient::CompletedAchievementResponse>]
|
200
256
|
# @example
|
201
257
|
# api = TrophyApiClient::Client.new(
|
202
258
|
# base_url: "https://api.example.com",
|
@@ -224,7 +280,7 @@ module TrophyApiClient
|
|
224
280
|
parsed_json = JSON.parse(response.body)
|
225
281
|
parsed_json&.map do |item|
|
226
282
|
item = item.to_json
|
227
|
-
TrophyApiClient::
|
283
|
+
TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
|
228
284
|
end
|
229
285
|
end
|
230
286
|
|
@@ -262,6 +318,86 @@ module TrophyApiClient
|
|
262
318
|
end
|
263
319
|
TrophyApiClient::StreakResponse.from_json(json_object: response.body)
|
264
320
|
end
|
321
|
+
|
322
|
+
# Get a user's points.
|
323
|
+
#
|
324
|
+
# @param id [String] ID of the user.
|
325
|
+
# @param awards [Integer] The number of recent point awards to return.
|
326
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
327
|
+
# @return [TrophyApiClient::GetUserPointsResponse]
|
328
|
+
# @example
|
329
|
+
# api = TrophyApiClient::Client.new(
|
330
|
+
# base_url: "https://api.example.com",
|
331
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
332
|
+
# api_key: "YOUR_API_KEY"
|
333
|
+
# )
|
334
|
+
# api.users.points(id: "userId")
|
335
|
+
def points(id:, awards: nil, request_options: nil)
|
336
|
+
response = @request_client.conn.get do |req|
|
337
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
338
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
339
|
+
req.headers = {
|
340
|
+
**(req.headers || {}),
|
341
|
+
**@request_client.get_headers,
|
342
|
+
**(request_options&.additional_headers || {})
|
343
|
+
}.compact
|
344
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "awards": awards }.compact
|
345
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
346
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
347
|
+
end
|
348
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/points"
|
349
|
+
end
|
350
|
+
TrophyApiClient::GetUserPointsResponse.from_json(json_object: response.body)
|
351
|
+
end
|
352
|
+
|
353
|
+
# Get a summary of points awards over time for a user.
|
354
|
+
#
|
355
|
+
# @param id [String] ID of the user.
|
356
|
+
# @param aggregation [TrophyApiClient::Users::UsersPointsEventSummaryRequestAggregation] The time period over which to aggregate the event data.
|
357
|
+
# @param start_date [String] The start date for the data range in YYYY-MM-DD format. The startDate must be
|
358
|
+
# before the endDate, and the date range must not exceed 400 days.
|
359
|
+
# @param end_date [String] The end date for the data range in YYYY-MM-DD format. The endDate must be after
|
360
|
+
# the startDate, and the date range must not exceed 400 days.
|
361
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
362
|
+
# @return [Array<TrophyApiClient::Users::UsersPointsEventSummaryResponseItem>]
|
363
|
+
# @example
|
364
|
+
# api = TrophyApiClient::Client.new(
|
365
|
+
# base_url: "https://api.example.com",
|
366
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
367
|
+
# api_key: "YOUR_API_KEY"
|
368
|
+
# )
|
369
|
+
# api.users.points_event_summary(
|
370
|
+
# id: "userId",
|
371
|
+
# aggregation: DAILY,
|
372
|
+
# start_date: "2024-01-01",
|
373
|
+
# end_date: "2024-01-31"
|
374
|
+
# )
|
375
|
+
def points_event_summary(id:, aggregation:, start_date:, end_date:, request_options: nil)
|
376
|
+
response = @request_client.conn.get do |req|
|
377
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
378
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
379
|
+
req.headers = {
|
380
|
+
**(req.headers || {}),
|
381
|
+
**@request_client.get_headers,
|
382
|
+
**(request_options&.additional_headers || {})
|
383
|
+
}.compact
|
384
|
+
req.params = {
|
385
|
+
**(request_options&.additional_query_parameters || {}),
|
386
|
+
"aggregation": aggregation,
|
387
|
+
"startDate": start_date,
|
388
|
+
"endDate": end_date
|
389
|
+
}.compact
|
390
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
391
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
392
|
+
end
|
393
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/points/event-summary"
|
394
|
+
end
|
395
|
+
parsed_json = JSON.parse(response.body)
|
396
|
+
parsed_json&.map do |item|
|
397
|
+
item = item.to_json
|
398
|
+
TrophyApiClient::Users::UsersPointsEventSummaryResponseItem.from_json(json_object: item)
|
399
|
+
end
|
400
|
+
end
|
265
401
|
end
|
266
402
|
|
267
403
|
class AsyncUsersClient
|
@@ -455,11 +591,64 @@ module TrophyApiClient
|
|
455
591
|
end
|
456
592
|
end
|
457
593
|
|
594
|
+
# Get a summary of metric events over time for a user.
|
595
|
+
#
|
596
|
+
# @param id [String] ID of the user.
|
597
|
+
# @param key [String] Unique key of the metric.
|
598
|
+
# @param aggregation [TrophyApiClient::Users::UsersMetricEventSummaryRequestAggregation] The time period over which to aggregate the event data.
|
599
|
+
# @param start_date [String] The start date for the data range in YYYY-MM-DD format. The startDate must be
|
600
|
+
# before the endDate, and the date range must not exceed 400 days.
|
601
|
+
# @param end_date [String] The end date for the data range in YYYY-MM-DD format. The endDate must be after
|
602
|
+
# the startDate, and the date range must not exceed 400 days.
|
603
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
604
|
+
# @return [Array<TrophyApiClient::Users::UsersMetricEventSummaryResponseItem>]
|
605
|
+
# @example
|
606
|
+
# api = TrophyApiClient::Client.new(
|
607
|
+
# base_url: "https://api.example.com",
|
608
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
609
|
+
# api_key: "YOUR_API_KEY"
|
610
|
+
# )
|
611
|
+
# api.users.metric_event_summary(
|
612
|
+
# id: "userId",
|
613
|
+
# key: "words-written",
|
614
|
+
# aggregation: DAILY,
|
615
|
+
# start_date: "2024-01-01",
|
616
|
+
# end_date: "2024-01-31"
|
617
|
+
# )
|
618
|
+
def metric_event_summary(id:, key:, aggregation:, start_date:, end_date:, request_options: nil)
|
619
|
+
Async do
|
620
|
+
response = @request_client.conn.get do |req|
|
621
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
622
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
623
|
+
req.headers = {
|
624
|
+
**(req.headers || {}),
|
625
|
+
**@request_client.get_headers,
|
626
|
+
**(request_options&.additional_headers || {})
|
627
|
+
}.compact
|
628
|
+
req.params = {
|
629
|
+
**(request_options&.additional_query_parameters || {}),
|
630
|
+
"aggregation": aggregation,
|
631
|
+
"startDate": start_date,
|
632
|
+
"endDate": end_date
|
633
|
+
}.compact
|
634
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
635
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
636
|
+
end
|
637
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/metrics/#{key}/event-summary"
|
638
|
+
end
|
639
|
+
parsed_json = JSON.parse(response.body)
|
640
|
+
parsed_json&.map do |item|
|
641
|
+
item = item.to_json
|
642
|
+
TrophyApiClient::Users::UsersMetricEventSummaryResponseItem.from_json(json_object: item)
|
643
|
+
end
|
644
|
+
end
|
645
|
+
end
|
646
|
+
|
458
647
|
# Get all of a user's completed achievements.
|
459
648
|
#
|
460
649
|
# @param id [String] ID of the user.
|
461
650
|
# @param request_options [TrophyApiClient::RequestOptions]
|
462
|
-
# @return [Array<TrophyApiClient::
|
651
|
+
# @return [Array<TrophyApiClient::CompletedAchievementResponse>]
|
463
652
|
# @example
|
464
653
|
# api = TrophyApiClient::Client.new(
|
465
654
|
# base_url: "https://api.example.com",
|
@@ -488,7 +677,7 @@ module TrophyApiClient
|
|
488
677
|
parsed_json = JSON.parse(response.body)
|
489
678
|
parsed_json&.map do |item|
|
490
679
|
item = item.to_json
|
491
|
-
TrophyApiClient::
|
680
|
+
TrophyApiClient::CompletedAchievementResponse.from_json(json_object: item)
|
492
681
|
end
|
493
682
|
end
|
494
683
|
end
|
@@ -529,5 +718,89 @@ module TrophyApiClient
|
|
529
718
|
TrophyApiClient::StreakResponse.from_json(json_object: response.body)
|
530
719
|
end
|
531
720
|
end
|
721
|
+
|
722
|
+
# Get a user's points.
|
723
|
+
#
|
724
|
+
# @param id [String] ID of the user.
|
725
|
+
# @param awards [Integer] The number of recent point awards to return.
|
726
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
727
|
+
# @return [TrophyApiClient::GetUserPointsResponse]
|
728
|
+
# @example
|
729
|
+
# api = TrophyApiClient::Client.new(
|
730
|
+
# base_url: "https://api.example.com",
|
731
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
732
|
+
# api_key: "YOUR_API_KEY"
|
733
|
+
# )
|
734
|
+
# api.users.points(id: "userId")
|
735
|
+
def points(id:, awards: nil, request_options: nil)
|
736
|
+
Async do
|
737
|
+
response = @request_client.conn.get do |req|
|
738
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
739
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
740
|
+
req.headers = {
|
741
|
+
**(req.headers || {}),
|
742
|
+
**@request_client.get_headers,
|
743
|
+
**(request_options&.additional_headers || {})
|
744
|
+
}.compact
|
745
|
+
req.params = { **(request_options&.additional_query_parameters || {}), "awards": awards }.compact
|
746
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
747
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
748
|
+
end
|
749
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/points"
|
750
|
+
end
|
751
|
+
TrophyApiClient::GetUserPointsResponse.from_json(json_object: response.body)
|
752
|
+
end
|
753
|
+
end
|
754
|
+
|
755
|
+
# Get a summary of points awards over time for a user.
|
756
|
+
#
|
757
|
+
# @param id [String] ID of the user.
|
758
|
+
# @param aggregation [TrophyApiClient::Users::UsersPointsEventSummaryRequestAggregation] The time period over which to aggregate the event data.
|
759
|
+
# @param start_date [String] The start date for the data range in YYYY-MM-DD format. The startDate must be
|
760
|
+
# before the endDate, and the date range must not exceed 400 days.
|
761
|
+
# @param end_date [String] The end date for the data range in YYYY-MM-DD format. The endDate must be after
|
762
|
+
# the startDate, and the date range must not exceed 400 days.
|
763
|
+
# @param request_options [TrophyApiClient::RequestOptions]
|
764
|
+
# @return [Array<TrophyApiClient::Users::UsersPointsEventSummaryResponseItem>]
|
765
|
+
# @example
|
766
|
+
# api = TrophyApiClient::Client.new(
|
767
|
+
# base_url: "https://api.example.com",
|
768
|
+
# environment: TrophyApiClient::Environment::DEFAULT,
|
769
|
+
# api_key: "YOUR_API_KEY"
|
770
|
+
# )
|
771
|
+
# api.users.points_event_summary(
|
772
|
+
# id: "userId",
|
773
|
+
# aggregation: DAILY,
|
774
|
+
# start_date: "2024-01-01",
|
775
|
+
# end_date: "2024-01-31"
|
776
|
+
# )
|
777
|
+
def points_event_summary(id:, aggregation:, start_date:, end_date:, request_options: nil)
|
778
|
+
Async do
|
779
|
+
response = @request_client.conn.get do |req|
|
780
|
+
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
|
781
|
+
req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
|
782
|
+
req.headers = {
|
783
|
+
**(req.headers || {}),
|
784
|
+
**@request_client.get_headers,
|
785
|
+
**(request_options&.additional_headers || {})
|
786
|
+
}.compact
|
787
|
+
req.params = {
|
788
|
+
**(request_options&.additional_query_parameters || {}),
|
789
|
+
"aggregation": aggregation,
|
790
|
+
"startDate": start_date,
|
791
|
+
"endDate": end_date
|
792
|
+
}.compact
|
793
|
+
unless request_options.nil? || request_options&.additional_body_parameters.nil?
|
794
|
+
req.body = { **(request_options&.additional_body_parameters || {}) }.compact
|
795
|
+
end
|
796
|
+
req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/points/event-summary"
|
797
|
+
end
|
798
|
+
parsed_json = JSON.parse(response.body)
|
799
|
+
parsed_json&.map do |item|
|
800
|
+
item = item.to_json
|
801
|
+
TrophyApiClient::Users::UsersPointsEventSummaryResponseItem.from_json(json_object: item)
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
532
805
|
end
|
533
806
|
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module TrophyApiClient
|
7
|
+
class Users
|
8
|
+
class UsersMetricEventSummaryResponseItem
|
9
|
+
# @return [String] The date of the data point. For weekly or monthly aggregations, this is the
|
10
|
+
# first date of the period.
|
11
|
+
attr_reader :date
|
12
|
+
# @return [Float] The user's total for this metric at the end of this date.
|
13
|
+
attr_reader :total
|
14
|
+
# @return [Float] The change in the user's total for this metric during this period.
|
15
|
+
attr_reader :change
|
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 date [String] The date of the data point. For weekly or monthly aggregations, this is the
|
25
|
+
# first date of the period.
|
26
|
+
# @param total [Float] The user's total for this metric at the end of this date.
|
27
|
+
# @param change [Float] The change in the user's total for this metric during this period.
|
28
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
29
|
+
# @return [TrophyApiClient::Users::UsersMetricEventSummaryResponseItem]
|
30
|
+
def initialize(date:, total:, change:, additional_properties: nil)
|
31
|
+
@date = date
|
32
|
+
@total = total
|
33
|
+
@change = change
|
34
|
+
@additional_properties = additional_properties
|
35
|
+
@_field_set = { "date": date, "total": total, "change": change }
|
36
|
+
end
|
37
|
+
|
38
|
+
# Deserialize a JSON object to an instance of UsersMetricEventSummaryResponseItem
|
39
|
+
#
|
40
|
+
# @param json_object [String]
|
41
|
+
# @return [TrophyApiClient::Users::UsersMetricEventSummaryResponseItem]
|
42
|
+
def self.from_json(json_object:)
|
43
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
44
|
+
parsed_json = JSON.parse(json_object)
|
45
|
+
date = parsed_json["date"]
|
46
|
+
total = parsed_json["total"]
|
47
|
+
change = parsed_json["change"]
|
48
|
+
new(
|
49
|
+
date: date,
|
50
|
+
total: total,
|
51
|
+
change: change,
|
52
|
+
additional_properties: struct
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Serialize an instance of UsersMetricEventSummaryResponseItem 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.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
|
71
|
+
obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
72
|
+
obj.change.is_a?(Float) != false || raise("Passed value for field obj.change is not the expected type, validation failed.")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module TrophyApiClient
|
7
|
+
class Users
|
8
|
+
class UsersPointsEventSummaryResponseItem
|
9
|
+
# @return [String] The date of the data point. For weekly or monthly aggregations, this is the
|
10
|
+
# first date of the period.
|
11
|
+
attr_reader :date
|
12
|
+
# @return [Float] The user's total points at the end of this date.
|
13
|
+
attr_reader :total
|
14
|
+
# @return [Float] The change in the user's total points during this period.
|
15
|
+
attr_reader :change
|
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 date [String] The date of the data point. For weekly or monthly aggregations, this is the
|
25
|
+
# first date of the period.
|
26
|
+
# @param total [Float] The user's total points at the end of this date.
|
27
|
+
# @param change [Float] The change in the user's total points during this period.
|
28
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
29
|
+
# @return [TrophyApiClient::Users::UsersPointsEventSummaryResponseItem]
|
30
|
+
def initialize(date:, total:, change:, additional_properties: nil)
|
31
|
+
@date = date
|
32
|
+
@total = total
|
33
|
+
@change = change
|
34
|
+
@additional_properties = additional_properties
|
35
|
+
@_field_set = { "date": date, "total": total, "change": change }
|
36
|
+
end
|
37
|
+
|
38
|
+
# Deserialize a JSON object to an instance of UsersPointsEventSummaryResponseItem
|
39
|
+
#
|
40
|
+
# @param json_object [String]
|
41
|
+
# @return [TrophyApiClient::Users::UsersPointsEventSummaryResponseItem]
|
42
|
+
def self.from_json(json_object:)
|
43
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
44
|
+
parsed_json = JSON.parse(json_object)
|
45
|
+
date = parsed_json["date"]
|
46
|
+
total = parsed_json["total"]
|
47
|
+
change = parsed_json["change"]
|
48
|
+
new(
|
49
|
+
date: date,
|
50
|
+
total: total,
|
51
|
+
change: change,
|
52
|
+
additional_properties: struct
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Serialize an instance of UsersPointsEventSummaryResponseItem 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.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.")
|
71
|
+
obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
|
72
|
+
obj.change.is_a?(Float) != false || raise("Passed value for field obj.change is not the expected type, validation failed.")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/trophy_api_client.rb
CHANGED
@@ -6,6 +6,7 @@ require_relative "requests"
|
|
6
6
|
require_relative "trophy_api_client/achievements/client"
|
7
7
|
require_relative "trophy_api_client/metrics/client"
|
8
8
|
require_relative "trophy_api_client/users/client"
|
9
|
+
require_relative "trophy_api_client/points/client"
|
9
10
|
|
10
11
|
module TrophyApiClient
|
11
12
|
class Client
|
@@ -15,6 +16,8 @@ module TrophyApiClient
|
|
15
16
|
attr_reader :metrics
|
16
17
|
# @return [TrophyApiClient::UsersClient]
|
17
18
|
attr_reader :users
|
19
|
+
# @return [TrophyApiClient::PointsClient]
|
20
|
+
attr_reader :points
|
18
21
|
|
19
22
|
# @param base_url [String]
|
20
23
|
# @param environment [TrophyApiClient::Environment]
|
@@ -34,6 +37,7 @@ module TrophyApiClient
|
|
34
37
|
@achievements = TrophyApiClient::AchievementsClient.new(request_client: @request_client)
|
35
38
|
@metrics = TrophyApiClient::MetricsClient.new(request_client: @request_client)
|
36
39
|
@users = TrophyApiClient::UsersClient.new(request_client: @request_client)
|
40
|
+
@points = TrophyApiClient::PointsClient.new(request_client: @request_client)
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
@@ -44,6 +48,8 @@ module TrophyApiClient
|
|
44
48
|
attr_reader :metrics
|
45
49
|
# @return [TrophyApiClient::AsyncUsersClient]
|
46
50
|
attr_reader :users
|
51
|
+
# @return [TrophyApiClient::AsyncPointsClient]
|
52
|
+
attr_reader :points
|
47
53
|
|
48
54
|
# @param base_url [String]
|
49
55
|
# @param environment [TrophyApiClient::Environment]
|
@@ -63,6 +69,7 @@ module TrophyApiClient
|
|
63
69
|
@achievements = TrophyApiClient::AsyncAchievementsClient.new(request_client: @async_request_client)
|
64
70
|
@metrics = TrophyApiClient::AsyncMetricsClient.new(request_client: @async_request_client)
|
65
71
|
@users = TrophyApiClient::AsyncUsersClient.new(request_client: @async_request_client)
|
72
|
+
@points = TrophyApiClient::AsyncPointsClient.new(request_client: @async_request_client)
|
66
73
|
end
|
67
74
|
end
|
68
75
|
end
|
data/lib/types_export.rb
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "trophy_api_client/users/types/users_metric_event_summary_request_aggregation"
|
4
|
+
require_relative "trophy_api_client/users/types/users_metric_event_summary_response_item"
|
5
|
+
require_relative "trophy_api_client/users/types/users_points_event_summary_request_aggregation"
|
6
|
+
require_relative "trophy_api_client/users/types/users_points_event_summary_response_item"
|
3
7
|
require_relative "trophy_api_client/types/metric_status"
|
4
8
|
require_relative "trophy_api_client/types/streak_frequency"
|
5
9
|
require_relative "trophy_api_client/types/base_streak_response"
|
6
|
-
require_relative "trophy_api_client/types/
|
10
|
+
require_relative "trophy_api_client/types/metric_event_streak_response"
|
7
11
|
require_relative "trophy_api_client/types/streak_response_streak_history_item"
|
8
12
|
require_relative "trophy_api_client/types/streak_response"
|
13
|
+
require_relative "trophy_api_client/types/points_trigger_type"
|
14
|
+
require_relative "trophy_api_client/types/points_trigger"
|
15
|
+
require_relative "trophy_api_client/types/points_award"
|
16
|
+
require_relative "trophy_api_client/types/get_user_points_response"
|
17
|
+
require_relative "trophy_api_client/types/metric_event_points_response"
|
18
|
+
require_relative "trophy_api_client/types/achievement_response_trigger"
|
9
19
|
require_relative "trophy_api_client/types/achievement_response"
|
20
|
+
require_relative "trophy_api_client/types/completed_achievement_response"
|
21
|
+
require_relative "trophy_api_client/types/achievement_with_stats_response"
|
10
22
|
require_relative "trophy_api_client/types/metric_response"
|
11
23
|
require_relative "trophy_api_client/types/updated_user"
|
12
24
|
require_relative "trophy_api_client/types/upserted_user"
|
@@ -14,3 +26,8 @@ require_relative "trophy_api_client/types/user"
|
|
14
26
|
require_relative "trophy_api_client/types/error_body"
|
15
27
|
require_relative "trophy_api_client/types/achievement_completion_response"
|
16
28
|
require_relative "trophy_api_client/types/event_response"
|
29
|
+
require_relative "trophy_api_client/types/points_range"
|
30
|
+
require_relative "trophy_api_client/types/points_summary_response"
|
31
|
+
require_relative "trophy_api_client/types/points_trigger_response_type"
|
32
|
+
require_relative "trophy_api_client/types/points_trigger_response_status"
|
33
|
+
require_relative "trophy_api_client/types/points_trigger_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.
|
4
|
+
version: 1.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trophy Labs, Inc
|
@@ -101,14 +101,28 @@ files:
|
|
101
101
|
- lib/trophy_api_client.rb
|
102
102
|
- lib/trophy_api_client/achievements/client.rb
|
103
103
|
- lib/trophy_api_client/metrics/client.rb
|
104
|
+
- lib/trophy_api_client/points/client.rb
|
104
105
|
- lib/trophy_api_client/types/achievement_completion_response.rb
|
105
106
|
- lib/trophy_api_client/types/achievement_response.rb
|
107
|
+
- lib/trophy_api_client/types/achievement_response_trigger.rb
|
108
|
+
- lib/trophy_api_client/types/achievement_with_stats_response.rb
|
106
109
|
- lib/trophy_api_client/types/base_streak_response.rb
|
110
|
+
- lib/trophy_api_client/types/completed_achievement_response.rb
|
107
111
|
- lib/trophy_api_client/types/error_body.rb
|
108
112
|
- lib/trophy_api_client/types/event_response.rb
|
109
|
-
- lib/trophy_api_client/types/
|
113
|
+
- lib/trophy_api_client/types/get_user_points_response.rb
|
114
|
+
- lib/trophy_api_client/types/metric_event_points_response.rb
|
115
|
+
- lib/trophy_api_client/types/metric_event_streak_response.rb
|
110
116
|
- lib/trophy_api_client/types/metric_response.rb
|
111
117
|
- lib/trophy_api_client/types/metric_status.rb
|
118
|
+
- lib/trophy_api_client/types/points_award.rb
|
119
|
+
- lib/trophy_api_client/types/points_range.rb
|
120
|
+
- lib/trophy_api_client/types/points_summary_response.rb
|
121
|
+
- lib/trophy_api_client/types/points_trigger.rb
|
122
|
+
- lib/trophy_api_client/types/points_trigger_response.rb
|
123
|
+
- lib/trophy_api_client/types/points_trigger_response_status.rb
|
124
|
+
- lib/trophy_api_client/types/points_trigger_response_type.rb
|
125
|
+
- lib/trophy_api_client/types/points_trigger_type.rb
|
112
126
|
- lib/trophy_api_client/types/streak_frequency.rb
|
113
127
|
- lib/trophy_api_client/types/streak_response.rb
|
114
128
|
- lib/trophy_api_client/types/streak_response_streak_history_item.rb
|
@@ -116,6 +130,10 @@ files:
|
|
116
130
|
- lib/trophy_api_client/types/upserted_user.rb
|
117
131
|
- lib/trophy_api_client/types/user.rb
|
118
132
|
- lib/trophy_api_client/users/client.rb
|
133
|
+
- lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb
|
134
|
+
- lib/trophy_api_client/users/types/users_metric_event_summary_response_item.rb
|
135
|
+
- lib/trophy_api_client/users/types/users_points_event_summary_request_aggregation.rb
|
136
|
+
- lib/trophy_api_client/users/types/users_points_event_summary_response_item.rb
|
119
137
|
- lib/trophy_api_client/version.rb
|
120
138
|
- lib/types_export.rb
|
121
139
|
homepage: https://github.com/trophyso/trophy-ruby
|