trophy_api_client 1.0.10 → 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.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gemconfig.rb +1 -1
  3. data/lib/trophy_api_client/points/client.rb +175 -0
  4. data/lib/trophy_api_client/types/achievement_response.rb +20 -5
  5. data/lib/trophy_api_client/types/achievement_response_trigger.rb +10 -0
  6. data/lib/trophy_api_client/types/achievement_with_stats_response.rb +20 -5
  7. data/lib/trophy_api_client/types/completed_achievement_response.rb +20 -5
  8. data/lib/trophy_api_client/types/event_response.rb +24 -7
  9. data/lib/trophy_api_client/types/get_user_points_response.rb +71 -0
  10. data/lib/trophy_api_client/types/metric_event_points_response.rb +78 -0
  11. data/lib/trophy_api_client/types/{increment_metric_streak_response.rb → metric_event_streak_response.rb} +6 -6
  12. data/lib/trophy_api_client/types/points_award.rb +80 -0
  13. data/lib/trophy_api_client/types/points_range.rb +74 -0
  14. data/lib/trophy_api_client/types/points_summary_response.rb +7 -0
  15. data/lib/trophy_api_client/types/points_trigger.rb +116 -0
  16. data/lib/trophy_api_client/types/points_trigger_response.rb +164 -0
  17. data/lib/trophy_api_client/types/points_trigger_response_status.rb +9 -0
  18. data/lib/trophy_api_client/types/points_trigger_response_type.rb +10 -0
  19. data/lib/trophy_api_client/types/points_trigger_type.rb +10 -0
  20. data/lib/trophy_api_client/users/client.rb +167 -0
  21. data/lib/trophy_api_client/users/types/users_points_event_summary_request_aggregation.rb +11 -0
  22. data/lib/trophy_api_client/users/types/users_points_event_summary_response_item.rb +76 -0
  23. data/lib/trophy_api_client/version.rb +1 -1
  24. data/lib/trophy_api_client.rb +7 -0
  25. data/lib/types_export.rb +14 -1
  26. metadata +16 -2
@@ -10,6 +10,9 @@ require_relative "types/users_metric_event_summary_request_aggregation"
10
10
  require_relative "types/users_metric_event_summary_response_item"
11
11
  require_relative "../types/completed_achievement_response"
12
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"
13
16
  require "async"
14
17
 
15
18
  module TrophyApiClient
@@ -315,6 +318,86 @@ module TrophyApiClient
315
318
  end
316
319
  TrophyApiClient::StreakResponse.from_json(json_object: response.body)
317
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
318
401
  end
319
402
 
320
403
  class AsyncUsersClient
@@ -635,5 +718,89 @@ module TrophyApiClient
635
718
  TrophyApiClient::StreakResponse.from_json(json_object: response.body)
636
719
  end
637
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
638
805
  end
639
806
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TrophyApiClient
4
+ class Users
5
+ class UsersPointsEventSummaryRequestAggregation
6
+ DAILY = "daily"
7
+ WEEKLY = "weekly"
8
+ MONTHLY = "monthly"
9
+ end
10
+ end
11
+ 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
@@ -1,3 +1,3 @@
1
1
  module MyGem
2
- VERSION = "1.0.10"
2
+ VERSION = "1.0.11"
3
3
  end
@@ -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
@@ -2,12 +2,20 @@
2
2
 
3
3
  require_relative "trophy_api_client/users/types/users_metric_event_summary_request_aggregation"
4
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"
5
7
  require_relative "trophy_api_client/types/metric_status"
6
8
  require_relative "trophy_api_client/types/streak_frequency"
7
9
  require_relative "trophy_api_client/types/base_streak_response"
8
- require_relative "trophy_api_client/types/increment_metric_streak_response"
10
+ require_relative "trophy_api_client/types/metric_event_streak_response"
9
11
  require_relative "trophy_api_client/types/streak_response_streak_history_item"
10
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"
11
19
  require_relative "trophy_api_client/types/achievement_response"
12
20
  require_relative "trophy_api_client/types/completed_achievement_response"
13
21
  require_relative "trophy_api_client/types/achievement_with_stats_response"
@@ -18,3 +26,8 @@ require_relative "trophy_api_client/types/user"
18
26
  require_relative "trophy_api_client/types/error_body"
19
27
  require_relative "trophy_api_client/types/achievement_completion_response"
20
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.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trophy Labs, Inc
@@ -101,16 +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
106
108
  - lib/trophy_api_client/types/achievement_with_stats_response.rb
107
109
  - lib/trophy_api_client/types/base_streak_response.rb
108
110
  - lib/trophy_api_client/types/completed_achievement_response.rb
109
111
  - lib/trophy_api_client/types/error_body.rb
110
112
  - lib/trophy_api_client/types/event_response.rb
111
- - lib/trophy_api_client/types/increment_metric_streak_response.rb
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
112
116
  - lib/trophy_api_client/types/metric_response.rb
113
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
114
126
  - lib/trophy_api_client/types/streak_frequency.rb
115
127
  - lib/trophy_api_client/types/streak_response.rb
116
128
  - lib/trophy_api_client/types/streak_response_streak_history_item.rb
@@ -120,6 +132,8 @@ files:
120
132
  - lib/trophy_api_client/users/client.rb
121
133
  - lib/trophy_api_client/users/types/users_metric_event_summary_request_aggregation.rb
122
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
123
137
  - lib/trophy_api_client/version.rb
124
138
  - lib/types_export.rb
125
139
  homepage: https://github.com/trophyso/trophy-ruby