trophy_api_client 1.0.16 → 1.0.17

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.
@@ -2,7 +2,6 @@
2
2
 
3
3
  require_relative "completed_achievement_response"
4
4
  require_relative "metric_event_streak_response"
5
- require_relative "metric_event_points_response"
6
5
  require "ostruct"
7
6
  require "json"
8
7
 
@@ -18,8 +17,7 @@ module TrophyApiClient
18
17
  attr_reader :achievements
19
18
  # @return [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
20
19
  attr_reader :current_streak
21
- # @return [TrophyApiClient::MetricEventPointsResponse] The points added by this event, and a breakdown of the points awards that added
22
- # points.
20
+ # @return [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this event.
23
21
  attr_reader :points
24
22
  # @return [OpenStruct] Additional properties unmapped to the current class definition
25
23
  attr_reader :additional_properties
@@ -34,8 +32,7 @@ module TrophyApiClient
34
32
  # @param total [Float] The user's new total progress against the metric.
35
33
  # @param achievements [Array<TrophyApiClient::CompletedAchievementResponse>] Achievements completed as a result of this event.
36
34
  # @param current_streak [TrophyApiClient::MetricEventStreakResponse] The user's current streak for the metric, if the metric has streaks enabled.
37
- # @param points [TrophyApiClient::MetricEventPointsResponse] The points added by this event, and a breakdown of the points awards that added
38
- # points.
35
+ # @param points [Hash{String => TrophyApiClient::MetricEventPointsResponse}] A map of points systems by key that were affected by this event.
39
36
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
40
37
  # @return [TrophyApiClient::EventResponse]
41
38
  def initialize(event_id:, metric_id:, total:, achievements: OMIT, current_streak: OMIT, points: OMIT,
@@ -79,11 +76,9 @@ module TrophyApiClient
79
76
  current_streak = parsed_json["currentStreak"].to_json
80
77
  current_streak = TrophyApiClient::MetricEventStreakResponse.from_json(json_object: current_streak)
81
78
  end
82
- if parsed_json["points"].nil?
83
- points = nil
84
- else
85
- points = parsed_json["points"].to_json
86
- points = TrophyApiClient::MetricEventPointsResponse.from_json(json_object: points)
79
+ points = parsed_json["points"]&.transform_values do |value|
80
+ value = value.to_json
81
+ TrophyApiClient::MetricEventPointsResponse.from_json(json_object: value)
87
82
  end
88
83
  new(
89
84
  event_id: event_id,
@@ -115,7 +110,7 @@ module TrophyApiClient
115
110
  obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
116
111
  obj.achievements&.is_a?(Array) != false || raise("Passed value for field obj.achievements is not the expected type, validation failed.")
117
112
  obj.current_streak.nil? || TrophyApiClient::MetricEventStreakResponse.validate_raw(obj: obj.current_streak)
118
- obj.points.nil? || TrophyApiClient::MetricEventPointsResponse.validate_raw(obj: obj.points)
113
+ obj.points&.is_a?(Hash) != false || raise("Passed value for field obj.points is not the expected type, validation failed.")
119
114
  end
120
115
  end
121
116
  end
@@ -6,6 +6,14 @@ require "json"
6
6
 
7
7
  module TrophyApiClient
8
8
  class GetUserPointsResponse
9
+ # @return [String] The ID of the points system
10
+ attr_reader :id
11
+ # @return [String] The name of the points system
12
+ attr_reader :name
13
+ # @return [String] The description of the points system
14
+ attr_reader :description
15
+ # @return [String] The URL of the badge image for the points system
16
+ attr_reader :badge_url
9
17
  # @return [Float] The user's total points
10
18
  attr_reader :total
11
19
  # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
@@ -18,15 +26,30 @@ module TrophyApiClient
18
26
 
19
27
  OMIT = Object.new
20
28
 
29
+ # @param id [String] The ID of the points system
30
+ # @param name [String] The name of the points system
31
+ # @param description [String] The description of the points system
32
+ # @param badge_url [String] The URL of the badge image for the points system
21
33
  # @param total [Float] The user's total points
22
34
  # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
23
35
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
36
  # @return [TrophyApiClient::GetUserPointsResponse]
25
- def initialize(total: OMIT, awards: OMIT, additional_properties: nil)
26
- @total = total if total != OMIT
27
- @awards = awards if awards != OMIT
37
+ def initialize(id:, name:, total:, awards:, description: OMIT, badge_url: OMIT, additional_properties: nil)
38
+ @id = id
39
+ @name = name
40
+ @description = description if description != OMIT
41
+ @badge_url = badge_url if badge_url != OMIT
42
+ @total = total
43
+ @awards = awards
28
44
  @additional_properties = additional_properties
29
- @_field_set = { "total": total, "awards": awards }.reject do |_k, v|
45
+ @_field_set = {
46
+ "id": id,
47
+ "name": name,
48
+ "description": description,
49
+ "badgeUrl": badge_url,
50
+ "total": total,
51
+ "awards": awards
52
+ }.reject do |_k, v|
30
53
  v == OMIT
31
54
  end
32
55
  end
@@ -38,12 +61,20 @@ module TrophyApiClient
38
61
  def self.from_json(json_object:)
39
62
  struct = JSON.parse(json_object, object_class: OpenStruct)
40
63
  parsed_json = JSON.parse(json_object)
64
+ id = parsed_json["id"]
65
+ name = parsed_json["name"]
66
+ description = parsed_json["description"]
67
+ badge_url = parsed_json["badgeUrl"]
41
68
  total = parsed_json["total"]
42
69
  awards = parsed_json["awards"]&.map do |item|
43
70
  item = item.to_json
44
71
  TrophyApiClient::PointsAward.from_json(json_object: item)
45
72
  end
46
73
  new(
74
+ id: id,
75
+ name: name,
76
+ description: description,
77
+ badge_url: badge_url,
47
78
  total: total,
48
79
  awards: awards,
49
80
  additional_properties: struct
@@ -64,8 +95,12 @@ module TrophyApiClient
64
95
  # @param obj [Object]
65
96
  # @return [Void]
66
97
  def self.validate_raw(obj:)
67
- obj.total&.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
68
- obj.awards&.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
98
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
99
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
100
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
101
+ obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
102
+ obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
103
+ obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
69
104
  end
70
105
  end
71
106
  end
@@ -8,6 +8,14 @@ module TrophyApiClient
8
8
  class MetricEventPointsResponse
9
9
  # @return [Float] The points added by this event.
10
10
  attr_reader :added
11
+ # @return [String] The ID of the points system
12
+ attr_reader :id
13
+ # @return [String] The name of the points system
14
+ attr_reader :name
15
+ # @return [String] The description of the points system
16
+ attr_reader :description
17
+ # @return [String] The URL of the badge image for the points system
18
+ attr_reader :badge_url
11
19
  # @return [Float] The user's total points
12
20
  attr_reader :total
13
21
  # @return [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
@@ -21,16 +29,33 @@ module TrophyApiClient
21
29
  OMIT = Object.new
22
30
 
23
31
  # @param added [Float] The points added by this event.
32
+ # @param id [String] The ID of the points system
33
+ # @param name [String] The name of the points system
34
+ # @param description [String] The description of the points system
35
+ # @param badge_url [String] The URL of the badge image for the points system
24
36
  # @param total [Float] The user's total points
25
37
  # @param awards [Array<TrophyApiClient::PointsAward>] Array of trigger awards that added points.
26
38
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
27
39
  # @return [TrophyApiClient::MetricEventPointsResponse]
28
- def initialize(added: OMIT, total: OMIT, awards: OMIT, additional_properties: nil)
40
+ def initialize(id:, name:, total:, awards:, added: OMIT, description: OMIT, badge_url: OMIT,
41
+ additional_properties: nil)
29
42
  @added = added if added != OMIT
30
- @total = total if total != OMIT
31
- @awards = awards if awards != OMIT
43
+ @id = id
44
+ @name = name
45
+ @description = description if description != OMIT
46
+ @badge_url = badge_url if badge_url != OMIT
47
+ @total = total
48
+ @awards = awards
32
49
  @additional_properties = additional_properties
33
- @_field_set = { "added": added, "total": total, "awards": awards }.reject do |_k, v|
50
+ @_field_set = {
51
+ "added": added,
52
+ "id": id,
53
+ "name": name,
54
+ "description": description,
55
+ "badgeUrl": badge_url,
56
+ "total": total,
57
+ "awards": awards
58
+ }.reject do |_k, v|
34
59
  v == OMIT
35
60
  end
36
61
  end
@@ -43,6 +68,10 @@ module TrophyApiClient
43
68
  struct = JSON.parse(json_object, object_class: OpenStruct)
44
69
  parsed_json = JSON.parse(json_object)
45
70
  added = parsed_json["added"]
71
+ id = parsed_json["id"]
72
+ name = parsed_json["name"]
73
+ description = parsed_json["description"]
74
+ badge_url = parsed_json["badgeUrl"]
46
75
  total = parsed_json["total"]
47
76
  awards = parsed_json["awards"]&.map do |item|
48
77
  item = item.to_json
@@ -50,6 +79,10 @@ module TrophyApiClient
50
79
  end
51
80
  new(
52
81
  added: added,
82
+ id: id,
83
+ name: name,
84
+ description: description,
85
+ badge_url: badge_url,
53
86
  total: total,
54
87
  awards: awards,
55
88
  additional_properties: struct
@@ -71,8 +104,12 @@ module TrophyApiClient
71
104
  # @return [Void]
72
105
  def self.validate_raw(obj:)
73
106
  obj.added&.is_a?(Float) != false || raise("Passed value for field obj.added is not the expected type, validation failed.")
74
- obj.total&.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
75
- obj.awards&.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
107
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
108
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
109
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
110
+ obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
111
+ obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.")
112
+ obj.awards.is_a?(Array) != false || raise("Passed value for field obj.awards is not the expected type, validation failed.")
76
113
  end
77
114
  end
78
115
  end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "points_trigger_response"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module TrophyApiClient
8
+ class PointsSystemResponse
9
+ # @return [String] The unique ID of the points system.
10
+ attr_reader :id
11
+ # @return [String] The name of the points system.
12
+ attr_reader :name
13
+ # @return [String] The description of the points system.
14
+ attr_reader :description
15
+ # @return [String] The URL of the badge image for the points system, if one has been uploaded.
16
+ attr_reader :badge_url
17
+ # @return [Array<TrophyApiClient::PointsTriggerResponse>] Array of active triggers for this points system.
18
+ attr_reader :triggers
19
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
20
+ attr_reader :additional_properties
21
+ # @return [Object]
22
+ attr_reader :_field_set
23
+ protected :_field_set
24
+
25
+ OMIT = Object.new
26
+
27
+ # @param id [String] The unique ID of the points system.
28
+ # @param name [String] The name of the points system.
29
+ # @param description [String] The description of the points system.
30
+ # @param badge_url [String] The URL of the badge image for the points system, if one has been uploaded.
31
+ # @param triggers [Array<TrophyApiClient::PointsTriggerResponse>] Array of active triggers for this points system.
32
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
33
+ # @return [TrophyApiClient::PointsSystemResponse]
34
+ def initialize(id:, name:, triggers:, description: OMIT, badge_url: OMIT, additional_properties: nil)
35
+ @id = id
36
+ @name = name
37
+ @description = description if description != OMIT
38
+ @badge_url = badge_url if badge_url != OMIT
39
+ @triggers = triggers
40
+ @additional_properties = additional_properties
41
+ @_field_set = {
42
+ "id": id,
43
+ "name": name,
44
+ "description": description,
45
+ "badgeUrl": badge_url,
46
+ "triggers": triggers
47
+ }.reject do |_k, v|
48
+ v == OMIT
49
+ end
50
+ end
51
+
52
+ # Deserialize a JSON object to an instance of PointsSystemResponse
53
+ #
54
+ # @param json_object [String]
55
+ # @return [TrophyApiClient::PointsSystemResponse]
56
+ def self.from_json(json_object:)
57
+ struct = JSON.parse(json_object, object_class: OpenStruct)
58
+ parsed_json = JSON.parse(json_object)
59
+ id = parsed_json["id"]
60
+ name = parsed_json["name"]
61
+ description = parsed_json["description"]
62
+ badge_url = parsed_json["badgeUrl"]
63
+ triggers = parsed_json["triggers"]&.map do |item|
64
+ item = item.to_json
65
+ TrophyApiClient::PointsTriggerResponse.from_json(json_object: item)
66
+ end
67
+ new(
68
+ id: id,
69
+ name: name,
70
+ description: description,
71
+ badge_url: badge_url,
72
+ triggers: triggers,
73
+ additional_properties: struct
74
+ )
75
+ end
76
+
77
+ # Serialize an instance of PointsSystemResponse to a JSON object
78
+ #
79
+ # @return [String]
80
+ def to_json(*_args)
81
+ @_field_set&.to_json
82
+ end
83
+
84
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
85
+ # hash and check each fields type against the current object's property
86
+ # definitions.
87
+ #
88
+ # @param obj [Object]
89
+ # @return [Void]
90
+ def self.validate_raw(obj:)
91
+ obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
92
+ obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
93
+ obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
94
+ obj.badge_url&.is_a?(String) != false || raise("Passed value for field obj.badge_url is not the expected type, validation failed.")
95
+ obj.triggers.is_a?(Array) != false || raise("Passed value for field obj.triggers is not the expected type, validation failed.")
96
+ end
97
+ end
98
+ end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require_relative "points_trigger_response_type"
4
4
  require_relative "points_trigger_response_status"
5
+ require_relative "points_trigger_response_user_attributes_item"
6
+ require_relative "points_trigger_response_event_attribute"
5
7
  require "date"
6
8
  require "ostruct"
7
9
  require "json"
@@ -33,6 +35,12 @@ module TrophyApiClient
33
35
  # @return [String] The name of the achievement associated with this trigger, if the trigger is an
34
36
  # achievement.
35
37
  attr_reader :achievement_name
38
+ # @return [Array<TrophyApiClient::PointsTriggerResponseUserAttributesItem>] User attribute filters that must be met for this trigger to activate. Only
39
+ # present if the trigger has user attribute filters configured.
40
+ attr_reader :user_attributes
41
+ # @return [TrophyApiClient::PointsTriggerResponseEventAttribute] Event attribute filter that must be met for this trigger to activate. Only
42
+ # present if the trigger has an event filter configured.
43
+ attr_reader :event_attribute
36
44
  # @return [DateTime] The date and time the trigger was created, in ISO 8601 format.
37
45
  attr_reader :created
38
46
  # @return [DateTime] The date and time the trigger was last updated, in ISO 8601 format.
@@ -60,12 +68,16 @@ module TrophyApiClient
60
68
  # @param metric_name [String] The name of the metric associated with this trigger, if the trigger is a metric.
61
69
  # @param achievement_name [String] The name of the achievement associated with this trigger, if the trigger is an
62
70
  # achievement.
71
+ # @param user_attributes [Array<TrophyApiClient::PointsTriggerResponseUserAttributesItem>] User attribute filters that must be met for this trigger to activate. Only
72
+ # present if the trigger has user attribute filters configured.
73
+ # @param event_attribute [TrophyApiClient::PointsTriggerResponseEventAttribute] Event attribute filter that must be met for this trigger to activate. Only
74
+ # present if the trigger has an event filter configured.
63
75
  # @param created [DateTime] The date and time the trigger was created, in ISO 8601 format.
64
76
  # @param updated [DateTime] The date and time the trigger was last updated, in ISO 8601 format.
65
77
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
66
78
  # @return [TrophyApiClient::PointsTriggerResponse]
67
79
  def initialize(id: OMIT, type: OMIT, points: OMIT, status: OMIT, achievement_id: OMIT, metric_id: OMIT,
68
- metric_threshold: OMIT, streak_length_threshold: OMIT, metric_name: OMIT, achievement_name: OMIT, created: OMIT, updated: OMIT, additional_properties: nil)
80
+ metric_threshold: OMIT, streak_length_threshold: OMIT, metric_name: OMIT, achievement_name: OMIT, user_attributes: OMIT, event_attribute: OMIT, created: OMIT, updated: OMIT, additional_properties: nil)
69
81
  @id = id if id != OMIT
70
82
  @type = type if type != OMIT
71
83
  @points = points if points != OMIT
@@ -76,6 +88,8 @@ module TrophyApiClient
76
88
  @streak_length_threshold = streak_length_threshold if streak_length_threshold != OMIT
77
89
  @metric_name = metric_name if metric_name != OMIT
78
90
  @achievement_name = achievement_name if achievement_name != OMIT
91
+ @user_attributes = user_attributes if user_attributes != OMIT
92
+ @event_attribute = event_attribute if event_attribute != OMIT
79
93
  @created = created if created != OMIT
80
94
  @updated = updated if updated != OMIT
81
95
  @additional_properties = additional_properties
@@ -90,6 +104,8 @@ module TrophyApiClient
90
104
  "streakLengthThreshold": streak_length_threshold,
91
105
  "metricName": metric_name,
92
106
  "achievementName": achievement_name,
107
+ "userAttributes": user_attributes,
108
+ "eventAttribute": event_attribute,
93
109
  "created": created,
94
110
  "updated": updated
95
111
  }.reject do |_k, v|
@@ -114,6 +130,16 @@ module TrophyApiClient
114
130
  streak_length_threshold = parsed_json["streakLengthThreshold"]
115
131
  metric_name = parsed_json["metricName"]
116
132
  achievement_name = parsed_json["achievementName"]
133
+ user_attributes = parsed_json["userAttributes"]&.map do |item|
134
+ item = item.to_json
135
+ TrophyApiClient::PointsTriggerResponseUserAttributesItem.from_json(json_object: item)
136
+ end
137
+ if parsed_json["eventAttribute"].nil?
138
+ event_attribute = nil
139
+ else
140
+ event_attribute = parsed_json["eventAttribute"].to_json
141
+ event_attribute = TrophyApiClient::PointsTriggerResponseEventAttribute.from_json(json_object: event_attribute)
142
+ end
117
143
  created = (DateTime.parse(parsed_json["created"]) unless parsed_json["created"].nil?)
118
144
  updated = (DateTime.parse(parsed_json["updated"]) unless parsed_json["updated"].nil?)
119
145
  new(
@@ -127,6 +153,8 @@ module TrophyApiClient
127
153
  streak_length_threshold: streak_length_threshold,
128
154
  metric_name: metric_name,
129
155
  achievement_name: achievement_name,
156
+ user_attributes: user_attributes,
157
+ event_attribute: event_attribute,
130
158
  created: created,
131
159
  updated: updated,
132
160
  additional_properties: struct
@@ -157,6 +185,8 @@ module TrophyApiClient
157
185
  obj.streak_length_threshold&.is_a?(Float) != false || raise("Passed value for field obj.streak_length_threshold is not the expected type, validation failed.")
158
186
  obj.metric_name&.is_a?(String) != false || raise("Passed value for field obj.metric_name is not the expected type, validation failed.")
159
187
  obj.achievement_name&.is_a?(String) != false || raise("Passed value for field obj.achievement_name is not the expected type, validation failed.")
188
+ obj.user_attributes&.is_a?(Array) != false || raise("Passed value for field obj.user_attributes is not the expected type, validation failed.")
189
+ obj.event_attribute.nil? || TrophyApiClient::PointsTriggerResponseEventAttribute.validate_raw(obj: obj.event_attribute)
160
190
  obj.created&.is_a?(DateTime) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
161
191
  obj.updated&.is_a?(DateTime) != false || raise("Passed value for field obj.updated is not the expected type, validation failed.")
162
192
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ # Event attribute filter that must be met for this trigger to activate. Only
8
+ # present if the trigger has an event filter configured.
9
+ class PointsTriggerResponseEventAttribute
10
+ # @return [String] The key of the event attribute.
11
+ attr_reader :key
12
+ # @return [String] The required value of the event attribute.
13
+ attr_reader :value
14
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
15
+ attr_reader :additional_properties
16
+ # @return [Object]
17
+ attr_reader :_field_set
18
+ protected :_field_set
19
+
20
+ OMIT = Object.new
21
+
22
+ # @param key [String] The key of the event attribute.
23
+ # @param value [String] The required value of the event attribute.
24
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
25
+ # @return [TrophyApiClient::PointsTriggerResponseEventAttribute]
26
+ def initialize(key:, value:, additional_properties: nil)
27
+ @key = key
28
+ @value = value
29
+ @additional_properties = additional_properties
30
+ @_field_set = { "key": key, "value": value }
31
+ end
32
+
33
+ # Deserialize a JSON object to an instance of PointsTriggerResponseEventAttribute
34
+ #
35
+ # @param json_object [String]
36
+ # @return [TrophyApiClient::PointsTriggerResponseEventAttribute]
37
+ def self.from_json(json_object:)
38
+ struct = JSON.parse(json_object, object_class: OpenStruct)
39
+ parsed_json = JSON.parse(json_object)
40
+ key = parsed_json["key"]
41
+ value = parsed_json["value"]
42
+ new(
43
+ key: key,
44
+ value: value,
45
+ additional_properties: struct
46
+ )
47
+ end
48
+
49
+ # Serialize an instance of PointsTriggerResponseEventAttribute to a JSON object
50
+ #
51
+ # @return [String]
52
+ def to_json(*_args)
53
+ @_field_set&.to_json
54
+ end
55
+
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
64
+ obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module TrophyApiClient
7
+ class PointsTriggerResponseUserAttributesItem
8
+ # @return [String] The key of the user attribute.
9
+ attr_reader :key
10
+ # @return [String] The value of the user attribute.
11
+ attr_reader :value
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param key [String] The key of the user attribute.
21
+ # @param value [String] The value of the user attribute.
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [TrophyApiClient::PointsTriggerResponseUserAttributesItem]
24
+ def initialize(key:, value:, additional_properties: nil)
25
+ @key = key
26
+ @value = value
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "key": key, "value": value }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of
32
+ # PointsTriggerResponseUserAttributesItem
33
+ #
34
+ # @param json_object [String]
35
+ # @return [TrophyApiClient::PointsTriggerResponseUserAttributesItem]
36
+ def self.from_json(json_object:)
37
+ struct = JSON.parse(json_object, object_class: OpenStruct)
38
+ parsed_json = JSON.parse(json_object)
39
+ key = parsed_json["key"]
40
+ value = parsed_json["value"]
41
+ new(
42
+ key: key,
43
+ value: value,
44
+ additional_properties: struct
45
+ )
46
+ end
47
+
48
+ # Serialize an instance of PointsTriggerResponseUserAttributesItem to a JSON
49
+ # object
50
+ #
51
+ # @return [String]
52
+ def to_json(*_args)
53
+ @_field_set&.to_json
54
+ end
55
+
56
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
57
+ # hash and check each fields type against the current object's property
58
+ # definitions.
59
+ #
60
+ # @param obj [Object]
61
+ # @return [Void]
62
+ def self.validate_raw(obj:)
63
+ obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
64
+ obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.")
65
+ end
66
+ end
67
+ end
@@ -17,6 +17,9 @@ module TrophyApiClient
17
17
  # @return [Boolean] Whether the user should receive Trophy-powered emails. If false, Trophy will not
18
18
  # store the user's email address.
19
19
  attr_reader :subscribe_to_emails
20
+ # @return [Hash{String => String}] User attributes as key-value pairs. Keys must match existing user attributes set
21
+ # up in the Trophy dashboard.
22
+ attr_reader :attributes
20
23
  # @return [OpenStruct] Additional properties unmapped to the current class definition
21
24
  attr_reader :additional_properties
22
25
  # @return [Object]
@@ -31,22 +34,26 @@ module TrophyApiClient
31
34
  # @param device_tokens [Array<String>] The user's device tokens, used for push notifications.
32
35
  # @param subscribe_to_emails [Boolean] Whether the user should receive Trophy-powered emails. If false, Trophy will not
33
36
  # store the user's email address.
37
+ # @param attributes [Hash{String => String}] User attributes as key-value pairs. Keys must match existing user attributes set
38
+ # up in the Trophy dashboard.
34
39
  # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
35
40
  # @return [TrophyApiClient::UpdatedUser]
36
- def initialize(email: OMIT, name: OMIT, tz: OMIT, device_tokens: OMIT, subscribe_to_emails: OMIT,
41
+ def initialize(email: OMIT, name: OMIT, tz: OMIT, device_tokens: OMIT, subscribe_to_emails: OMIT, attributes: OMIT,
37
42
  additional_properties: nil)
38
43
  @email = email if email != OMIT
39
44
  @name = name if name != OMIT
40
45
  @tz = tz if tz != OMIT
41
46
  @device_tokens = device_tokens if device_tokens != OMIT
42
47
  @subscribe_to_emails = subscribe_to_emails if subscribe_to_emails != OMIT
48
+ @attributes = attributes if attributes != OMIT
43
49
  @additional_properties = additional_properties
44
50
  @_field_set = {
45
51
  "email": email,
46
52
  "name": name,
47
53
  "tz": tz,
48
54
  "deviceTokens": device_tokens,
49
- "subscribeToEmails": subscribe_to_emails
55
+ "subscribeToEmails": subscribe_to_emails,
56
+ "attributes": attributes
50
57
  }.reject do |_k, v|
51
58
  v == OMIT
52
59
  end
@@ -64,12 +71,14 @@ module TrophyApiClient
64
71
  tz = parsed_json["tz"]
65
72
  device_tokens = parsed_json["deviceTokens"]
66
73
  subscribe_to_emails = parsed_json["subscribeToEmails"]
74
+ attributes = parsed_json["attributes"]
67
75
  new(
68
76
  email: email,
69
77
  name: name,
70
78
  tz: tz,
71
79
  device_tokens: device_tokens,
72
80
  subscribe_to_emails: subscribe_to_emails,
81
+ attributes: attributes,
73
82
  additional_properties: struct
74
83
  )
75
84
  end
@@ -93,6 +102,7 @@ module TrophyApiClient
93
102
  obj.tz&.is_a?(String) != false || raise("Passed value for field obj.tz is not the expected type, validation failed.")
94
103
  obj.device_tokens&.is_a?(Array) != false || raise("Passed value for field obj.device_tokens is not the expected type, validation failed.")
95
104
  obj.subscribe_to_emails&.is_a?(Boolean) != false || raise("Passed value for field obj.subscribe_to_emails is not the expected type, validation failed.")
105
+ obj.attributes&.is_a?(Hash) != false || raise("Passed value for field obj.attributes is not the expected type, validation failed.")
96
106
  end
97
107
  end
98
108
  end