trophy_api_client 1.0.1 → 1.0.2

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: 1dead4fcd46492c734d3a068b426764bf73d30241f2540944dacebca2cbeced8
4
- data.tar.gz: 0ab5f44fbe7a08bb62667c97a0f8c9487c522fcf4f03b2b4e95ee88e96d85e91
3
+ metadata.gz: 3a67cfb83b6601c4c488aa3ff95b578d33681982787c38e6448370eabaac987e
4
+ data.tar.gz: 9bde2c23199a0523fe99c350f155f9f6e79ac9a546663320ab2a2d1c6d62b995
5
5
  SHA512:
6
- metadata.gz: d910fb09cd06f5f2cf6e206e3e28bb3c51fad500c5324f906131e1eb12fc46051eff7efeccb83ea5a15192ecaf0110aaf6d7b2eb4a88a6c95066e4975d76cdb1
7
- data.tar.gz: bfbe3b66eeb09df596c08714495648dfcdb031c3386e0bb944f264bfd603c45887124f04e564da5b48b02f925f09c30efac9edaa54c70f2a92ccbe34a4dc840f
6
+ metadata.gz: 55cddb862ad713aba47db324c6f71f6b8c0f90a00ba2715f8917aafdef44ee43a0194a799c76717de6c24df518b532fb9c9fb40014ad26d6e430247feb65f02f
7
+ data.tar.gz: bd5e48a39c140ee9a0ea3dd9c7a9eaebc937a226002776dbe1834290d13389fd42c8140a5fe3eb3a4f8b8d595197b447029ce8dd919711f42d07626778dd3c1b
data/lib/gemconfig.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module TrophyApiClient
4
4
  module Gemconfig
5
- VERSION = "1.0.1"
5
+ VERSION = "1.0.2"
6
6
  AUTHORS = ["Trophy Labs, Inc"].freeze
7
7
  EMAIL = ""
8
8
  SUMMARY = "Ruby library for the Trophy API."
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../../requests"
4
- require_relative "../types/event_request_user"
4
+ require_relative "../types/upserted_user"
5
5
  require_relative "../types/achievement_completion_response"
6
6
  require "async"
7
7
 
@@ -19,11 +19,12 @@ module TrophyApiClient
19
19
  # Mark an achievement as completed for a user.
20
20
  #
21
21
  # @param key [String] Unique reference of the achievement as set when created.
22
- # @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::EventRequestUser, as a Hash
22
+ # @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::UpsertedUser, as a Hash
23
23
  # * :id (String)
24
24
  # * :email (String)
25
25
  # * :name (String)
26
26
  # * :tz (String)
27
+ # * :subscribe_to_emails (Boolean)
27
28
  # @param request_options [TrophyApiClient::RequestOptions]
28
29
  # @return [TrophyApiClient::AchievementCompletionResponse]
29
30
  # @example
@@ -32,7 +33,7 @@ module TrophyApiClient
32
33
  # environment: TrophyApiClient::Environment::DEFAULT,
33
34
  # api_key: "YOUR_API_KEY"
34
35
  # )
35
- # api.achievements.complete(key: "finish-onboarding", user: { id: "18", email: "jk.rowling@harrypotter.com", tz: "Europe/London" })
36
+ # api.achievements.complete(key: "finish-onboarding", user: { id: "user-id" })
36
37
  def complete(key:, user:, request_options: nil)
37
38
  response = @request_client.conn.post do |req|
38
39
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -65,11 +66,12 @@ module TrophyApiClient
65
66
  # Mark an achievement as completed for a user.
66
67
  #
67
68
  # @param key [String] Unique reference of the achievement as set when created.
68
- # @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::EventRequestUser, as a Hash
69
+ # @param user [Hash] The user that completed the achievement.Request of type TrophyApiClient::UpsertedUser, as a Hash
69
70
  # * :id (String)
70
71
  # * :email (String)
71
72
  # * :name (String)
72
73
  # * :tz (String)
74
+ # * :subscribe_to_emails (Boolean)
73
75
  # @param request_options [TrophyApiClient::RequestOptions]
74
76
  # @return [TrophyApiClient::AchievementCompletionResponse]
75
77
  # @example
@@ -78,7 +80,7 @@ module TrophyApiClient
78
80
  # environment: TrophyApiClient::Environment::DEFAULT,
79
81
  # api_key: "YOUR_API_KEY"
80
82
  # )
81
- # api.achievements.complete(key: "finish-onboarding", user: { id: "18", email: "jk.rowling@harrypotter.com", tz: "Europe/London" })
83
+ # api.achievements.complete(key: "finish-onboarding", user: { id: "user-id" })
82
84
  def complete(key:, user:, request_options: nil)
83
85
  Async do
84
86
  response = @request_client.conn.post do |req|
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../../requests"
4
- require_relative "../types/event_request_user"
4
+ require_relative "../types/upserted_user"
5
5
  require_relative "../types/event_response"
6
6
  require "async"
7
7
 
@@ -19,11 +19,12 @@ module TrophyApiClient
19
19
  # Increment or decrement the value of a metric for a user.
20
20
  #
21
21
  # @param key [String] Unique reference of the metric as set when created.
22
- # @param user [Hash] The user that triggered the event.Request of type TrophyApiClient::EventRequestUser, as a Hash
22
+ # @param user [Hash] The user that triggered the event.Request of type TrophyApiClient::UpsertedUser, as a Hash
23
23
  # * :id (String)
24
24
  # * :email (String)
25
25
  # * :name (String)
26
26
  # * :tz (String)
27
+ # * :subscribe_to_emails (Boolean)
27
28
  # @param value [Float] The value to add to the user's current total for the given metric.
28
29
  # @param request_options [TrophyApiClient::RequestOptions]
29
30
  # @return [TrophyApiClient::EventResponse]
@@ -35,7 +36,7 @@ module TrophyApiClient
35
36
  # )
36
37
  # api.metrics.event(
37
38
  # key: "words-written",
38
- # user: { id: "18", email: "jk.rowling@harrypotter.com", tz: "Europe/London" },
39
+ # user: { email: "user@example.com", tz: "Europe/London", id: "18" },
39
40
  # value: 750
40
41
  # )
41
42
  def event(key:, user:, value:, request_options: nil)
@@ -70,11 +71,12 @@ module TrophyApiClient
70
71
  # Increment or decrement the value of a metric for a user.
71
72
  #
72
73
  # @param key [String] Unique reference of the metric as set when created.
73
- # @param user [Hash] The user that triggered the event.Request of type TrophyApiClient::EventRequestUser, as a Hash
74
+ # @param user [Hash] The user that triggered the event.Request of type TrophyApiClient::UpsertedUser, as a Hash
74
75
  # * :id (String)
75
76
  # * :email (String)
76
77
  # * :name (String)
77
78
  # * :tz (String)
79
+ # * :subscribe_to_emails (Boolean)
78
80
  # @param value [Float] The value to add to the user's current total for the given metric.
79
81
  # @param request_options [TrophyApiClient::RequestOptions]
80
82
  # @return [TrophyApiClient::EventResponse]
@@ -86,7 +88,7 @@ module TrophyApiClient
86
88
  # )
87
89
  # api.metrics.event(
88
90
  # key: "words-written",
89
- # user: { id: "18", email: "jk.rowling@harrypotter.com", tz: "Europe/London" },
91
+ # user: { email: "user@example.com", tz: "Europe/London", id: "18" },
90
92
  # value: 750
91
93
  # )
92
94
  def event(key:, user:, value:, request_options: nil)
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "event_response_metrics_item"
4
+ require_relative "streak_response"
4
5
  require "ostruct"
5
6
  require "json"
6
7
 
@@ -14,6 +15,8 @@ module TrophyApiClient
14
15
  attr_reader :total
15
16
  # @return [Array<TrophyApiClient::EventResponseMetricsItem>] Changes to achievements as a result of this event.
16
17
  attr_reader :achievements
18
+ # @return [TrophyApiClient::StreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
19
+ attr_reader :current_streak
17
20
  # @return [OpenStruct] Additional properties unmapped to the current class definition
18
21
  attr_reader :additional_properties
19
22
  # @return [Object]
@@ -26,19 +29,22 @@ module TrophyApiClient
26
29
  # @param metric_id [String] The unique ID of the metric that was updated.
27
30
  # @param total [Float] The user's new total progress against the metric.
28
31
  # @param achievements [Array<TrophyApiClient::EventResponseMetricsItem>] Changes to achievements as a result of this event.
32
+ # @param current_streak [TrophyApiClient::StreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
29
33
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
34
  # @return [TrophyApiClient::EventResponse]
31
- def initialize(event_id:, metric_id:, total:, achievements: OMIT, additional_properties: nil)
35
+ def initialize(event_id:, metric_id:, total:, achievements: OMIT, current_streak: OMIT, additional_properties: nil)
32
36
  @event_id = event_id
33
37
  @metric_id = metric_id
34
38
  @total = total
35
39
  @achievements = achievements if achievements != OMIT
40
+ @current_streak = current_streak if current_streak != OMIT
36
41
  @additional_properties = additional_properties
37
42
  @_field_set = {
38
43
  "eventId": event_id,
39
44
  "metricId": metric_id,
40
45
  "total": total,
41
- "achievements": achievements
46
+ "achievements": achievements,
47
+ "currentStreak": current_streak
42
48
  }.reject do |_k, v|
43
49
  v == OMIT
44
50
  end
@@ -58,11 +64,18 @@ module TrophyApiClient
58
64
  item = item.to_json
59
65
  TrophyApiClient::EventResponseMetricsItem.from_json(json_object: item)
60
66
  end
67
+ if parsed_json["currentStreak"].nil?
68
+ current_streak = nil
69
+ else
70
+ current_streak = parsed_json["currentStreak"].to_json
71
+ current_streak = TrophyApiClient::StreakResponse.from_json(json_object: current_streak)
72
+ end
61
73
  new(
62
74
  event_id: event_id,
63
75
  metric_id: metric_id,
64
76
  total: total,
65
77
  achievements: achievements,
78
+ current_streak: current_streak,
66
79
  additional_properties: struct
67
80
  )
68
81
  end
@@ -85,6 +98,7 @@ module TrophyApiClient
85
98
  obj.metric_id.is_a?(String) != false || raise("Passed value for field obj.metric_id is not the expected type, validation failed.")
86
99
  obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
87
100
  obj.achievements&.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
101
+ obj.current_streak.nil? || TrophyApiClient::StreakResponse.validate_raw(obj: obj.current_streak)
88
102
  end
89
103
  end
90
104
  end
@@ -26,7 +26,7 @@ module TrophyApiClient
26
26
  # @return [Array<TrophyApiClient::AchievementResponse>] 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
- attr_reader :streak
29
+ attr_reader :current_streak
30
30
  # @return [OpenStruct] Additional properties unmapped to the current class definition
31
31
  attr_reader :additional_properties
32
32
  # @return [Object]
@@ -43,10 +43,10 @@ module TrophyApiClient
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
45
  # @param achievements [Array<TrophyApiClient::AchievementResponse>] A list of the metric's achievements and the user's progress towards each.
46
- # @param streak [TrophyApiClient::StreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
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]
49
- def initialize(id:, key:, name:, emoji:, streak_frequency:, status:, current:, achievements:, streak: OMIT,
49
+ def initialize(id:, key:, name:, emoji:, streak_frequency:, status:, current:, achievements:, current_streak: OMIT,
50
50
  additional_properties: nil)
51
51
  @id = id
52
52
  @key = key
@@ -56,7 +56,7 @@ module TrophyApiClient
56
56
  @status = status
57
57
  @current = current
58
58
  @achievements = achievements
59
- @streak = streak if streak != OMIT
59
+ @current_streak = current_streak if current_streak != OMIT
60
60
  @additional_properties = additional_properties
61
61
  @_field_set = {
62
62
  "id": id,
@@ -67,7 +67,7 @@ module TrophyApiClient
67
67
  "status": status,
68
68
  "current": current,
69
69
  "achievements": achievements,
70
- "streak": streak
70
+ "currentStreak": current_streak
71
71
  }.reject do |_k, v|
72
72
  v == OMIT
73
73
  end
@@ -91,11 +91,11 @@ module TrophyApiClient
91
91
  item = item.to_json
92
92
  TrophyApiClient::AchievementResponse.from_json(json_object: item)
93
93
  end
94
- if parsed_json["streak"].nil?
95
- streak = nil
94
+ if parsed_json["currentStreak"].nil?
95
+ current_streak = nil
96
96
  else
97
- streak = parsed_json["streak"].to_json
98
- streak = TrophyApiClient::StreakResponse.from_json(json_object: streak)
97
+ current_streak = parsed_json["currentStreak"].to_json
98
+ current_streak = TrophyApiClient::StreakResponse.from_json(json_object: current_streak)
99
99
  end
100
100
  new(
101
101
  id: id,
@@ -106,7 +106,7 @@ module TrophyApiClient
106
106
  status: status,
107
107
  current: current,
108
108
  achievements: achievements,
109
- streak: streak,
109
+ current_streak: current_streak,
110
110
  additional_properties: struct
111
111
  )
112
112
  end
@@ -133,7 +133,7 @@ module TrophyApiClient
133
133
  obj.status.is_a?(TrophyApiClient::MetricStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.")
134
134
  obj.current.is_a?(Float) != false || raise("Passed value for field obj.current is not the expected type, validation failed.")
135
135
  obj.achievements.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
136
- obj.streak.nil? || TrophyApiClient::StreakResponse.validate_raw(obj: obj.streak)
136
+ obj.current_streak.nil? || TrophyApiClient::StreakResponse.validate_raw(obj: obj.current_streak)
137
137
  end
138
138
  end
139
139
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ # An object with editable user fields.
8
+ class UpdatedUser
9
+ # @return [String] The user's email address. Required if subscribeToEmails is true.
10
+ attr_reader :email
11
+ # @return [String] The name to refer to the user by in emails.
12
+ attr_reader :name
13
+ # @return [String] The user's timezone (used for email scheduling).
14
+ attr_reader :tz
15
+ # @return [Boolean] Whether the user should receive Trophy-powered emails. Cannot be false if an
16
+ # email is provided.
17
+ attr_reader :subscribe_to_emails
18
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
19
+ attr_reader :additional_properties
20
+ # @return [Object]
21
+ attr_reader :_field_set
22
+ protected :_field_set
23
+
24
+ OMIT = Object.new
25
+
26
+ # @param email [String] The user's email address. Required if subscribeToEmails is true.
27
+ # @param name [String] The name to refer to the user by in emails.
28
+ # @param tz [String] The user's timezone (used for email scheduling).
29
+ # @param subscribe_to_emails [Boolean] Whether the user should receive Trophy-powered emails. Cannot be false if an
30
+ # email is provided.
31
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
32
+ # @return [TrophyApiClient::UpdatedUser]
33
+ def initialize(email: OMIT, name: OMIT, tz: OMIT, subscribe_to_emails: OMIT, additional_properties: nil)
34
+ @email = email if email != OMIT
35
+ @name = name if name != OMIT
36
+ @tz = tz if tz != OMIT
37
+ @subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
38
+ @additional_properties = additional_properties
39
+ @_field_set = {
40
+ "email": email,
41
+ "name": name,
42
+ "tz": tz,
43
+ "subscribeToEmails": subscribe_to_emails
44
+ }.reject do |_k, v|
45
+ v == OMIT
46
+ end
47
+ end
48
+
49
+ # Deserialize a JSON object to an instance of UpdatedUser
50
+ #
51
+ # @param json_object [String]
52
+ # @return [TrophyApiClient::UpdatedUser]
53
+ def self.from_json(json_object:)
54
+ struct = JSON.parse(json_object, object_class: OpenStruct)
55
+ parsed_json = JSON.parse(json_object)
56
+ email = parsed_json["email"]
57
+ name = parsed_json["name"]
58
+ tz = parsed_json["tz"]
59
+ subscribe_to_emails = parsed_json["subscribeToEmails"]
60
+ new(
61
+ email: email,
62
+ name: name,
63
+ tz: tz,
64
+ subscribe_to_emails: subscribe_to_emails,
65
+ additional_properties: struct
66
+ )
67
+ end
68
+
69
+ # Serialize an instance of UpdatedUser to a JSON object
70
+ #
71
+ # @return [String]
72
+ def to_json(*_args)
73
+ @_field_set&.to_json
74
+ end
75
+
76
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
77
+ # hash and check each fields type against the current object's property
78
+ # definitions.
79
+ #
80
+ # @param obj [Object]
81
+ # @return [Void]
82
+ def self.validate_raw(obj:)
83
+ obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
84
+ obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
85
+ obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
86
+ obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
87
+ end
88
+ end
89
+ end
@@ -4,16 +4,19 @@ require "ostruct"
4
4
  require "json"
5
5
 
6
6
  module TrophyApiClient
7
- # The user that triggered the event.
8
- class EventRequestUser
7
+ # An object with editable user fields.
8
+ class UpsertedUser
9
9
  # @return [String] The ID of the user in your database. Must be a string.
10
10
  attr_reader :id
11
- # @return [String] The user's email address.
11
+ # @return [String] The user's email address. Required if subscribeToEmails is true.
12
12
  attr_reader :email
13
13
  # @return [String] The name to refer to the user by in emails.
14
14
  attr_reader :name
15
15
  # @return [String] The user's timezone (used for email scheduling).
16
16
  attr_reader :tz
17
+ # @return [Boolean] Whether the user should receive Trophy-powered emails. Cannot be false if an
18
+ # email is provided.
19
+ attr_reader :subscribe_to_emails
17
20
  # @return [OpenStruct] Additional properties unmapped to the current class definition
18
21
  attr_reader :additional_properties
19
22
  # @return [Object]
@@ -23,26 +26,35 @@ module TrophyApiClient
23
26
  OMIT = Object.new
24
27
 
25
28
  # @param id [String] The ID of the user in your database. Must be a string.
26
- # @param email [String] The user's email address.
29
+ # @param email [String] The user's email address. Required if subscribeToEmails is true.
27
30
  # @param name [String] The name to refer to the user by in emails.
28
31
  # @param tz [String] The user's timezone (used for email scheduling).
32
+ # @param subscribe_to_emails [Boolean] Whether the user should receive Trophy-powered emails. Cannot be false if an
33
+ # email is provided.
29
34
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
- # @return [TrophyApiClient::EventRequestUser]
31
- def initialize(id:, email: OMIT, name: OMIT, tz: OMIT, additional_properties: nil)
35
+ # @return [TrophyApiClient::UpsertedUser]
36
+ def initialize(id:, email: OMIT, name: OMIT, tz: OMIT, subscribe_to_emails: OMIT, additional_properties: nil)
32
37
  @id = id
33
38
  @email = email if email != OMIT
34
39
  @name = name if name != OMIT
35
40
  @tz = tz if tz != OMIT
41
+ @subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
36
42
  @additional_properties = additional_properties
37
- @_field_set = { "id": id, "email": email, "name": name, "tz": tz }.reject do |_k, v|
43
+ @_field_set = {
44
+ "id": id,
45
+ "email": email,
46
+ "name": name,
47
+ "tz": tz,
48
+ "subscribeToEmails": subscribe_to_emails
49
+ }.reject do |_k, v|
38
50
  v == OMIT
39
51
  end
40
52
  end
41
53
 
42
- # Deserialize a JSON object to an instance of EventRequestUser
54
+ # Deserialize a JSON object to an instance of UpsertedUser
43
55
  #
44
56
  # @param json_object [String]
45
- # @return [TrophyApiClient::EventRequestUser]
57
+ # @return [TrophyApiClient::UpsertedUser]
46
58
  def self.from_json(json_object:)
47
59
  struct = JSON.parse(json_object, object_class: OpenStruct)
48
60
  parsed_json = JSON.parse(json_object)
@@ -50,16 +62,18 @@ module TrophyApiClient
50
62
  email = parsed_json["email"]
51
63
  name = parsed_json["name"]
52
64
  tz = parsed_json["tz"]
65
+ subscribe_to_emails = parsed_json["subscribeToEmails"]
53
66
  new(
54
67
  id: id,
55
68
  email: email,
56
69
  name: name,
57
70
  tz: tz,
71
+ subscribe_to_emails: subscribe_to_emails,
58
72
  additional_properties: struct
59
73
  )
60
74
  end
61
75
 
62
- # Serialize an instance of EventRequestUser to a JSON object
76
+ # Serialize an instance of UpsertedUser to a JSON object
63
77
  #
64
78
  # @return [String]
65
79
  def to_json(*_args)
@@ -77,6 +91,7 @@ module TrophyApiClient
77
91
  obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
78
92
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
79
93
  obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
94
+ obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
80
95
  end
81
96
  end
82
97
  end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ # A user of your application.
9
+ class User
10
+ # @return [Boolean] Whether the user is in the control group, meaning they do not receive emails or
11
+ # other communications from Trophy.
12
+ attr_reader :control
13
+ # @return [DateTime] The date and time the user was created, in ISO 8601 format.
14
+ attr_reader :created
15
+ # @return [DateTime] The date and time the user was last updated, in ISO 8601 format.
16
+ attr_reader :updated
17
+ # @return [String] The ID of the user in your database. Must be a string.
18
+ attr_reader :id
19
+ # @return [String] The user's email address. Required if subscribeToEmails is true.
20
+ attr_reader :email
21
+ # @return [String] The name to refer to the user by in emails.
22
+ attr_reader :name
23
+ # @return [String] The user's timezone (used for email scheduling).
24
+ attr_reader :tz
25
+ # @return [Boolean] Whether the user should receive Trophy-powered emails. Cannot be false if an
26
+ # email is provided.
27
+ attr_reader :subscribe_to_emails
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 control [Boolean] Whether the user is in the control group, meaning they do not receive emails or
37
+ # other communications from Trophy.
38
+ # @param created [DateTime] The date and time the user was created, in ISO 8601 format.
39
+ # @param updated [DateTime] The date and time the user was last updated, in ISO 8601 format.
40
+ # @param id [String] The ID of the user in your database. Must be a string.
41
+ # @param email [String] The user's email address. Required if subscribeToEmails is true.
42
+ # @param name [String] The name to refer to the user by in emails.
43
+ # @param tz [String] The user's timezone (used for email scheduling).
44
+ # @param subscribe_to_emails [Boolean] Whether the user should receive Trophy-powered emails. Cannot be false if an
45
+ # email is provided.
46
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
47
+ # @return [TrophyApiClient::User]
48
+ def initialize(id:, control: OMIT, created: OMIT, updated: OMIT, email: OMIT, name: OMIT, tz: OMIT,
49
+ subscribe_to_emails: OMIT, additional_properties: nil)
50
+ @control = control if control != OMIT
51
+ @created = created if created != OMIT
52
+ @updated = updated if updated != OMIT
53
+ @id = id
54
+ @email = email if email != OMIT
55
+ @name = name if name != OMIT
56
+ @tz = tz if tz != OMIT
57
+ @subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
58
+ @additional_properties = additional_properties
59
+ @_field_set = {
60
+ "control": control,
61
+ "created": created,
62
+ "updated": updated,
63
+ "id": id,
64
+ "email": email,
65
+ "name": name,
66
+ "tz": tz,
67
+ "subscribeToEmails": subscribe_to_emails
68
+ }.reject do |_k, v|
69
+ v == OMIT
70
+ end
71
+ end
72
+
73
+ # Deserialize a JSON object to an instance of User
74
+ #
75
+ # @param json_object [String]
76
+ # @return [TrophyApiClient::User]
77
+ def self.from_json(json_object:)
78
+ struct = JSON.parse(json_object, object_class: OpenStruct)
79
+ parsed_json = JSON.parse(json_object)
80
+ control = parsed_json["control"]
81
+ created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
82
+ updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
83
+ id = parsed_json["id"]
84
+ email = parsed_json["email"]
85
+ name = parsed_json["name"]
86
+ tz = parsed_json["tz"]
87
+ subscribe_to_emails = parsed_json["subscribeToEmails"]
88
+ new(
89
+ control: control,
90
+ created: created,
91
+ updated: updated,
92
+ id: id,
93
+ email: email,
94
+ name: name,
95
+ tz: tz,
96
+ subscribe_to_emails: subscribe_to_emails,
97
+ additional_properties: struct
98
+ )
99
+ end
100
+
101
+ # Serialize an instance of User to a JSON object
102
+ #
103
+ # @return [String]
104
+ def to_json(*_args)
105
+ @_field_set&.to_json
106
+ end
107
+
108
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
109
+ # hash and check each fields type against the current object's property
110
+ # definitions.
111
+ #
112
+ # @param obj [Object]
113
+ # @return [Void]
114
+ def self.validate_raw(obj:)
115
+ obj.control&.is_a?(Boolean) != false || raise("Passed value for field obj.control is not the expected type, validation failed.")
116
+ obj.created&.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
117
+ obj.updated&.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
118
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
119
+ obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
120
+ obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
121
+ obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
122
+ obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
123
+ end
124
+ end
125
+ end
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../../requests"
4
+ require_relative "../types/upserted_user"
5
+ require_relative "../types/user"
6
+ require_relative "../types/updated_user"
4
7
  require_relative "../types/metric_response"
5
8
  require "json"
6
9
  require_relative "../types/achievement_response"
@@ -17,9 +20,111 @@ module TrophyApiClient
17
20
  @request_client = request_client
18
21
  end
19
22
 
23
+ # Create a new user.
24
+ #
25
+ # @param request [Hash] The user object.Request of type TrophyApiClient::UpsertedUser, as a Hash
26
+ # * :id (String)
27
+ # * :email (String)
28
+ # * :name (String)
29
+ # * :tz (String)
30
+ # * :subscribe_to_emails (Boolean)
31
+ # @param request_options [TrophyApiClient::RequestOptions]
32
+ # @return [TrophyApiClient::User]
33
+ # @example
34
+ # api = TrophyApiClient::Client.new(
35
+ # base_url: "https://api.example.com",
36
+ # environment: TrophyApiClient::Environment::DEFAULT,
37
+ # api_key: "YOUR_API_KEY"
38
+ # )
39
+ # api.users.create(request: { id: "user-id" })
40
+ def create(request:, request_options: nil)
41
+ response = @request_client.conn.post do |req|
42
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
43
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
44
+ req.headers = {
45
+ **(req.headers || {}),
46
+ **@request_client.get_headers,
47
+ **(request_options&.additional_headers || {})
48
+ }.compact
49
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
50
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
51
+ end
52
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
53
+ req.url "#{@request_client.get_url(request_options: request_options)}/users"
54
+ end
55
+ TrophyApiClient::User.from_json(json_object: response.body)
56
+ end
57
+
58
+ # Get a single user.
59
+ #
60
+ # @param id [String] ID of the user to get.
61
+ # @param request_options [TrophyApiClient::RequestOptions]
62
+ # @return [TrophyApiClient::User]
63
+ # @example
64
+ # api = TrophyApiClient::Client.new(
65
+ # base_url: "https://api.example.com",
66
+ # environment: TrophyApiClient::Environment::DEFAULT,
67
+ # api_key: "YOUR_API_KEY"
68
+ # )
69
+ # api.users.get(id: "userId")
70
+ def get(id:, 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 = {
75
+ **(req.headers || {}),
76
+ **@request_client.get_headers,
77
+ **(request_options&.additional_headers || {})
78
+ }.compact
79
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
80
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
81
+ end
82
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
83
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
84
+ end
85
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}"
86
+ end
87
+ TrophyApiClient::User.from_json(json_object: response.body)
88
+ end
89
+
90
+ # Update a user.
91
+ #
92
+ # @param id [String] ID of the user to update.
93
+ # @param request [Hash] The user object.Request of type TrophyApiClient::UpdatedUser, as a Hash
94
+ # * :email (String)
95
+ # * :name (String)
96
+ # * :tz (String)
97
+ # * :subscribe_to_emails (Boolean)
98
+ # @param request_options [TrophyApiClient::RequestOptions]
99
+ # @return [TrophyApiClient::User]
100
+ # @example
101
+ # api = TrophyApiClient::Client.new(
102
+ # base_url: "https://api.example.com",
103
+ # environment: TrophyApiClient::Environment::DEFAULT,
104
+ # api_key: "YOUR_API_KEY"
105
+ # )
106
+ # api.users.update(id: "id", request: { email: "user@example.com", tz: "Europe/London" })
107
+ def update(id:, request:, request_options: nil)
108
+ response = @request_client.conn.patch do |req|
109
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
110
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
111
+ req.headers = {
112
+ **(req.headers || {}),
113
+ **@request_client.get_headers,
114
+ **(request_options&.additional_headers || {})
115
+ }.compact
116
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
117
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
118
+ end
119
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
120
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}"
121
+ end
122
+ TrophyApiClient::User.from_json(json_object: response.body)
123
+ end
124
+
20
125
  # Get a single user's progress against all active metrics.
21
126
  #
22
- # @param user_id [String] ID of the user
127
+ # @param id [String] ID of the user
23
128
  # @param request_options [TrophyApiClient::RequestOptions]
24
129
  # @return [Array<TrophyApiClient::MetricResponse>]
25
130
  # @example
@@ -28,8 +133,8 @@ module TrophyApiClient
28
133
  # environment: TrophyApiClient::Environment::DEFAULT,
29
134
  # api_key: "YOUR_API_KEY"
30
135
  # )
31
- # api.users.allmetrics(user_id: "userId")
32
- def allmetrics(user_id:, request_options: nil)
136
+ # api.users.allmetrics(id: "userId")
137
+ def allmetrics(id:, request_options: nil)
33
138
  response = @request_client.conn.get do |req|
34
139
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
35
140
  req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -44,7 +149,7 @@ module TrophyApiClient
44
149
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
45
150
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
46
151
  end
47
- req.url "#{@request_client.get_url(request_options: request_options)}/users/#{user_id}/metrics"
152
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/metrics"
48
153
  end
49
154
  parsed_json = JSON.parse(response.body)
50
155
  parsed_json&.map do |item|
@@ -55,7 +160,7 @@ module TrophyApiClient
55
160
 
56
161
  # Get a user's progress against a single active metric.
57
162
  #
58
- # @param user_id [String] ID of the user.
163
+ # @param id [String] ID of the user.
59
164
  # @param key [String] Unique key of the metric.
60
165
  # @param request_options [TrophyApiClient::RequestOptions]
61
166
  # @return [TrophyApiClient::MetricResponse]
@@ -65,8 +170,8 @@ module TrophyApiClient
65
170
  # environment: TrophyApiClient::Environment::DEFAULT,
66
171
  # api_key: "YOUR_API_KEY"
67
172
  # )
68
- # api.users.singlemetric(user_id: "userId", key: "key")
69
- def singlemetric(user_id:, key:, request_options: nil)
173
+ # api.users.singlemetric(id: "userId", key: "key")
174
+ def singlemetric(id:, key:, request_options: nil)
70
175
  response = @request_client.conn.get do |req|
71
176
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
72
177
  req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -81,14 +186,14 @@ module TrophyApiClient
81
186
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
82
187
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
83
188
  end
84
- req.url "#{@request_client.get_url(request_options: request_options)}/users/#{user_id}/metrics/#{key}"
189
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/metrics/#{key}"
85
190
  end
86
191
  TrophyApiClient::MetricResponse.from_json(json_object: response.body)
87
192
  end
88
193
 
89
194
  # Get all of a user's completed achievements.
90
195
  #
91
- # @param user_id [String] ID of the user.
196
+ # @param id [String] ID of the user.
92
197
  # @param request_options [TrophyApiClient::RequestOptions]
93
198
  # @return [Array<TrophyApiClient::AchievementResponse>]
94
199
  # @example
@@ -97,8 +202,8 @@ module TrophyApiClient
97
202
  # environment: TrophyApiClient::Environment::DEFAULT,
98
203
  # api_key: "YOUR_API_KEY"
99
204
  # )
100
- # api.users.allachievements(user_id: "userId")
101
- def allachievements(user_id:, request_options: nil)
205
+ # api.users.allachievements(id: "userId")
206
+ def allachievements(id:, request_options: nil)
102
207
  response = @request_client.conn.get do |req|
103
208
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
104
209
  req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
@@ -113,7 +218,7 @@ module TrophyApiClient
113
218
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
114
219
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
115
220
  end
116
- req.url "#{@request_client.get_url(request_options: request_options)}/users/#{user_id}/achievements"
221
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/achievements"
117
222
  end
118
223
  parsed_json = JSON.parse(response.body)
119
224
  parsed_json&.map do |item|
@@ -133,9 +238,117 @@ module TrophyApiClient
133
238
  @request_client = request_client
134
239
  end
135
240
 
241
+ # Create a new user.
242
+ #
243
+ # @param request [Hash] The user object.Request of type TrophyApiClient::UpsertedUser, as a Hash
244
+ # * :id (String)
245
+ # * :email (String)
246
+ # * :name (String)
247
+ # * :tz (String)
248
+ # * :subscribe_to_emails (Boolean)
249
+ # @param request_options [TrophyApiClient::RequestOptions]
250
+ # @return [TrophyApiClient::User]
251
+ # @example
252
+ # api = TrophyApiClient::Client.new(
253
+ # base_url: "https://api.example.com",
254
+ # environment: TrophyApiClient::Environment::DEFAULT,
255
+ # api_key: "YOUR_API_KEY"
256
+ # )
257
+ # api.users.create(request: { id: "user-id" })
258
+ def create(request:, request_options: nil)
259
+ Async do
260
+ response = @request_client.conn.post do |req|
261
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
262
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
263
+ req.headers = {
264
+ **(req.headers || {}),
265
+ **@request_client.get_headers,
266
+ **(request_options&.additional_headers || {})
267
+ }.compact
268
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
269
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
270
+ end
271
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
272
+ req.url "#{@request_client.get_url(request_options: request_options)}/users"
273
+ end
274
+ TrophyApiClient::User.from_json(json_object: response.body)
275
+ end
276
+ end
277
+
278
+ # Get a single user.
279
+ #
280
+ # @param id [String] ID of the user to get.
281
+ # @param request_options [TrophyApiClient::RequestOptions]
282
+ # @return [TrophyApiClient::User]
283
+ # @example
284
+ # api = TrophyApiClient::Client.new(
285
+ # base_url: "https://api.example.com",
286
+ # environment: TrophyApiClient::Environment::DEFAULT,
287
+ # api_key: "YOUR_API_KEY"
288
+ # )
289
+ # api.users.get(id: "userId")
290
+ def get(id:, request_options: nil)
291
+ Async do
292
+ response = @request_client.conn.get do |req|
293
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
294
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
295
+ req.headers = {
296
+ **(req.headers || {}),
297
+ **@request_client.get_headers,
298
+ **(request_options&.additional_headers || {})
299
+ }.compact
300
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
301
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
302
+ end
303
+ unless request_options.nil? || request_options&.additional_body_parameters.nil?
304
+ req.body = { **(request_options&.additional_body_parameters || {}) }.compact
305
+ end
306
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}"
307
+ end
308
+ TrophyApiClient::User.from_json(json_object: response.body)
309
+ end
310
+ end
311
+
312
+ # Update a user.
313
+ #
314
+ # @param id [String] ID of the user to update.
315
+ # @param request [Hash] The user object.Request of type TrophyApiClient::UpdatedUser, as a Hash
316
+ # * :email (String)
317
+ # * :name (String)
318
+ # * :tz (String)
319
+ # * :subscribe_to_emails (Boolean)
320
+ # @param request_options [TrophyApiClient::RequestOptions]
321
+ # @return [TrophyApiClient::User]
322
+ # @example
323
+ # api = TrophyApiClient::Client.new(
324
+ # base_url: "https://api.example.com",
325
+ # environment: TrophyApiClient::Environment::DEFAULT,
326
+ # api_key: "YOUR_API_KEY"
327
+ # )
328
+ # api.users.update(id: "id", request: { email: "user@example.com", tz: "Europe/London" })
329
+ def update(id:, request:, request_options: nil)
330
+ Async do
331
+ response = @request_client.conn.patch do |req|
332
+ req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
333
+ req.headers["X-API-KEY"] = request_options.api_key unless request_options&.api_key.nil?
334
+ req.headers = {
335
+ **(req.headers || {}),
336
+ **@request_client.get_headers,
337
+ **(request_options&.additional_headers || {})
338
+ }.compact
339
+ unless request_options.nil? || request_options&.additional_query_parameters.nil?
340
+ req.params = { **(request_options&.additional_query_parameters || {}) }.compact
341
+ end
342
+ req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
343
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}"
344
+ end
345
+ TrophyApiClient::User.from_json(json_object: response.body)
346
+ end
347
+ end
348
+
136
349
  # Get a single user's progress against all active metrics.
137
350
  #
138
- # @param user_id [String] ID of the user
351
+ # @param id [String] ID of the user
139
352
  # @param request_options [TrophyApiClient::RequestOptions]
140
353
  # @return [Array<TrophyApiClient::MetricResponse>]
141
354
  # @example
@@ -144,8 +357,8 @@ module TrophyApiClient
144
357
  # environment: TrophyApiClient::Environment::DEFAULT,
145
358
  # api_key: "YOUR_API_KEY"
146
359
  # )
147
- # api.users.allmetrics(user_id: "userId")
148
- def allmetrics(user_id:, request_options: nil)
360
+ # api.users.allmetrics(id: "userId")
361
+ def allmetrics(id:, request_options: nil)
149
362
  Async do
150
363
  response = @request_client.conn.get do |req|
151
364
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -161,7 +374,7 @@ module TrophyApiClient
161
374
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
162
375
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
163
376
  end
164
- req.url "#{@request_client.get_url(request_options: request_options)}/users/#{user_id}/metrics"
377
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/metrics"
165
378
  end
166
379
  parsed_json = JSON.parse(response.body)
167
380
  parsed_json&.map do |item|
@@ -173,7 +386,7 @@ module TrophyApiClient
173
386
 
174
387
  # Get a user's progress against a single active metric.
175
388
  #
176
- # @param user_id [String] ID of the user.
389
+ # @param id [String] ID of the user.
177
390
  # @param key [String] Unique key of the metric.
178
391
  # @param request_options [TrophyApiClient::RequestOptions]
179
392
  # @return [TrophyApiClient::MetricResponse]
@@ -183,8 +396,8 @@ module TrophyApiClient
183
396
  # environment: TrophyApiClient::Environment::DEFAULT,
184
397
  # api_key: "YOUR_API_KEY"
185
398
  # )
186
- # api.users.singlemetric(user_id: "userId", key: "key")
187
- def singlemetric(user_id:, key:, request_options: nil)
399
+ # api.users.singlemetric(id: "userId", key: "key")
400
+ def singlemetric(id:, key:, request_options: nil)
188
401
  Async do
189
402
  response = @request_client.conn.get do |req|
190
403
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -200,7 +413,7 @@ module TrophyApiClient
200
413
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
201
414
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
202
415
  end
203
- req.url "#{@request_client.get_url(request_options: request_options)}/users/#{user_id}/metrics/#{key}"
416
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/metrics/#{key}"
204
417
  end
205
418
  TrophyApiClient::MetricResponse.from_json(json_object: response.body)
206
419
  end
@@ -208,7 +421,7 @@ module TrophyApiClient
208
421
 
209
422
  # Get all of a user's completed achievements.
210
423
  #
211
- # @param user_id [String] ID of the user.
424
+ # @param id [String] ID of the user.
212
425
  # @param request_options [TrophyApiClient::RequestOptions]
213
426
  # @return [Array<TrophyApiClient::AchievementResponse>]
214
427
  # @example
@@ -217,8 +430,8 @@ module TrophyApiClient
217
430
  # environment: TrophyApiClient::Environment::DEFAULT,
218
431
  # api_key: "YOUR_API_KEY"
219
432
  # )
220
- # api.users.allachievements(user_id: "userId")
221
- def allachievements(user_id:, request_options: nil)
433
+ # api.users.allachievements(id: "userId")
434
+ def allachievements(id:, request_options: nil)
222
435
  Async do
223
436
  response = @request_client.conn.get do |req|
224
437
  req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
@@ -234,7 +447,7 @@ module TrophyApiClient
234
447
  unless request_options.nil? || request_options&.additional_body_parameters.nil?
235
448
  req.body = { **(request_options&.additional_body_parameters || {}) }.compact
236
449
  end
237
- req.url "#{@request_client.get_url(request_options: request_options)}/users/#{user_id}/achievements"
450
+ req.url "#{@request_client.get_url(request_options: request_options)}/users/#{id}/achievements"
238
451
  end
239
452
  parsed_json = JSON.parse(response.body)
240
453
  parsed_json&.map do |item|
@@ -1,3 +1,3 @@
1
1
  module MyGem
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/types_export.rb CHANGED
@@ -5,7 +5,9 @@ require_relative "trophy_api_client/types/streak_frequency"
5
5
  require_relative "trophy_api_client/types/streak_response"
6
6
  require_relative "trophy_api_client/types/achievement_response"
7
7
  require_relative "trophy_api_client/types/metric_response"
8
- require_relative "trophy_api_client/types/event_request_user"
8
+ require_relative "trophy_api_client/types/updated_user"
9
+ require_relative "trophy_api_client/types/upserted_user"
10
+ require_relative "trophy_api_client/types/user"
9
11
  require_relative "trophy_api_client/types/error_body"
10
12
  require_relative "trophy_api_client/types/achievement_completion_response"
11
13
  require_relative "trophy_api_client/types/event_response_metrics_item"
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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trophy Labs, Inc
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-13 00:00:00.000000000 Z
10
+ date: 2025-03-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async-http-faraday
@@ -104,13 +104,15 @@ files:
104
104
  - lib/trophy_api_client/types/achievement_completion_response.rb
105
105
  - lib/trophy_api_client/types/achievement_response.rb
106
106
  - lib/trophy_api_client/types/error_body.rb
107
- - lib/trophy_api_client/types/event_request_user.rb
108
107
  - lib/trophy_api_client/types/event_response.rb
109
108
  - lib/trophy_api_client/types/event_response_metrics_item.rb
110
109
  - lib/trophy_api_client/types/metric_response.rb
111
110
  - lib/trophy_api_client/types/metric_status.rb
112
111
  - lib/trophy_api_client/types/streak_frequency.rb
113
112
  - lib/trophy_api_client/types/streak_response.rb
113
+ - lib/trophy_api_client/types/updated_user.rb
114
+ - lib/trophy_api_client/types/upserted_user.rb
115
+ - lib/trophy_api_client/types/user.rb
114
116
  - lib/trophy_api_client/users/client.rb
115
117
  - lib/trophy_api_client/version.rb
116
118
  - lib/types_export.rb