Skip to content

Commit ce441a4

Browse files
Automatically update Ruby SDK
1 parent 7d3cd11 commit ce441a4

32 files changed

+1799
-31
lines changed

lib/gemconfig.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module TrophyApiClient
44
module Gemconfig
5-
VERSION = "1.5.0"
5+
VERSION = "1.6.0"
66
AUTHORS = ["Trophy Labs, Inc"].freeze
77
EMAIL = ""
88
SUMMARY = "Ruby library for the Trophy API."

lib/trophy_api_client/admin/attributes/client.rb

Lines changed: 368 additions & 0 deletions
Large diffs are not rendered by default.

lib/trophy_api_client/admin/client.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,48 @@
22

33
require_relative "../../requests"
44
require_relative "streaks/client"
5+
require_relative "attributes/client"
6+
require_relative "metrics/client"
57
require_relative "points/client"
68

79
module TrophyApiClient
810
module Admin
911
class Client
1012
# @return [TrophyApiClient::Admin::StreaksClient]
1113
attr_reader :streaks
14+
# @return [TrophyApiClient::Admin::AttributesClient]
15+
attr_reader :attributes
16+
# @return [TrophyApiClient::Admin::MetricsClient]
17+
attr_reader :metrics
1218
# @return [TrophyApiClient::Admin::Points::Client]
1319
attr_reader :admin
1420

1521
# @param request_client [TrophyApiClient::RequestClient]
1622
# @return [TrophyApiClient::Admin::Client]
1723
def initialize(request_client:)
1824
@streaks = TrophyApiClient::Admin::StreaksClient.new(request_client: request_client)
25+
@attributes = TrophyApiClient::Admin::AttributesClient.new(request_client: request_client)
26+
@metrics = TrophyApiClient::Admin::MetricsClient.new(request_client: request_client)
1927
@admin = TrophyApiClient::Admin::Points::Client.new(request_client: request_client)
2028
end
2129
end
2230

2331
class AsyncClient
2432
# @return [TrophyApiClient::Admin::AsyncStreaksClient]
2533
attr_reader :streaks
34+
# @return [TrophyApiClient::Admin::AsyncAttributesClient]
35+
attr_reader :attributes
36+
# @return [TrophyApiClient::Admin::AsyncMetricsClient]
37+
attr_reader :metrics
2638
# @return [TrophyApiClient::Admin::Points::AsyncClient]
2739
attr_reader :admin
2840

2941
# @param request_client [TrophyApiClient::AsyncRequestClient]
3042
# @return [TrophyApiClient::Admin::AsyncClient]
3143
def initialize(request_client:)
3244
@streaks = TrophyApiClient::Admin::AsyncStreaksClient.new(request_client: request_client)
45+
@attributes = TrophyApiClient::Admin::AsyncAttributesClient.new(request_client: request_client)
46+
@metrics = TrophyApiClient::Admin::AsyncMetricsClient.new(request_client: request_client)
3347
@admin = TrophyApiClient::Admin::Points::AsyncClient.new(request_client: request_client)
3448
end
3549
end

lib/trophy_api_client/admin/metrics/client.rb

Lines changed: 366 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "admin_attribute_type"
4+
require "ostruct"
5+
require "json"
6+
7+
module TrophyApiClient
8+
# An attribute returned from the admin attributes endpoints.
9+
class AdminAttribute
10+
# @return [String] The UUID of the attribute.
11+
attr_reader :id
12+
# @return [String] The attribute name.
13+
attr_reader :name
14+
# @return [String] The attribute key.
15+
attr_reader :key
16+
# @return [TrophyApiClient::AdminAttributeType] The attribute type.
17+
attr_reader :type
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 id [String] The UUID of the attribute.
27+
# @param name [String] The attribute name.
28+
# @param key [String] The attribute key.
29+
# @param type [TrophyApiClient::AdminAttributeType] The attribute type.
30+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
31+
# @return [TrophyApiClient::AdminAttribute]
32+
def initialize(id:, name:, key:, type:, additional_properties: nil)
33+
@id = id
34+
@name = name
35+
@key = key
36+
@type = type
37+
@additional_properties = additional_properties
38+
@_field_set = { "id": id, "name": name, "key": key, "type": type }
39+
end
40+
41+
# Deserialize a JSON object to an instance of AdminAttribute
42+
#
43+
# @param json_object [String]
44+
# @return [TrophyApiClient::AdminAttribute]
45+
def self.from_json(json_object:)
46+
struct = JSON.parse(json_object, object_class: OpenStruct)
47+
parsed_json = JSON.parse(json_object)
48+
id = parsed_json["id"]
49+
name = parsed_json["name"]
50+
key = parsed_json["key"]
51+
type = parsed_json["type"]
52+
new(
53+
id: id,
54+
name: name,
55+
key: key,
56+
type: type,
57+
additional_properties: struct
58+
)
59+
end
60+
61+
# Serialize an instance of AdminAttribute to a JSON object
62+
#
63+
# @return [String]
64+
def to_json(*_args)
65+
@_field_set&.to_json
66+
end
67+
68+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
69+
# hash and check each fields type against the current object's property
70+
# definitions.
71+
#
72+
# @param obj [Object]
73+
# @return [Void]
74+
def self.validate_raw(obj:)
75+
obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
76+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
77+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
78+
obj.type.is_a?(TrophyApiClient::AdminAttributeType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
79+
end
80+
end
81+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module TrophyApiClient
4+
# The attribute type.
5+
class AdminAttributeType
6+
USER = "user"
7+
EVENT = "event"
8+
end
9+
end
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "create_attribute_request_item_type"
4+
require "ostruct"
5+
require "json"
6+
7+
module TrophyApiClient
8+
# An attribute to create.
9+
class CreateAttributeRequestItem
10+
# @return [String] The attribute name.
11+
attr_reader :name
12+
# @return [String] The attribute key. Only alphanumeric characters, hyphens, and underscores are
13+
# permitted.
14+
attr_reader :key
15+
# @return [TrophyApiClient::CreateAttributeRequestItemType] The attribute type.
16+
attr_reader :type
17+
# @return [OpenStruct] Additional properties unmapped to the current class definition
18+
attr_reader :additional_properties
19+
# @return [Object]
20+
attr_reader :_field_set
21+
protected :_field_set
22+
23+
OMIT = Object.new
24+
25+
# @param name [String] The attribute name.
26+
# @param key [String] The attribute key. Only alphanumeric characters, hyphens, and underscores are
27+
# permitted.
28+
# @param type [TrophyApiClient::CreateAttributeRequestItemType] The attribute type.
29+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30+
# @return [TrophyApiClient::CreateAttributeRequestItem]
31+
def initialize(name:, key:, type:, additional_properties: nil)
32+
@name = name
33+
@key = key
34+
@type = type
35+
@additional_properties = additional_properties
36+
@_field_set = { "name": name, "key": key, "type": type }
37+
end
38+
39+
# Deserialize a JSON object to an instance of CreateAttributeRequestItem
40+
#
41+
# @param json_object [String]
42+
# @return [TrophyApiClient::CreateAttributeRequestItem]
43+
def self.from_json(json_object:)
44+
struct = JSON.parse(json_object, object_class: OpenStruct)
45+
parsed_json = JSON.parse(json_object)
46+
name = parsed_json["name"]
47+
key = parsed_json["key"]
48+
type = parsed_json["type"]
49+
new(
50+
name: name,
51+
key: key,
52+
type: type,
53+
additional_properties: struct
54+
)
55+
end
56+
57+
# Serialize an instance of CreateAttributeRequestItem to a JSON object
58+
#
59+
# @return [String]
60+
def to_json(*_args)
61+
@_field_set&.to_json
62+
end
63+
64+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
65+
# hash and check each fields type against the current object's property
66+
# definitions.
67+
#
68+
# @param obj [Object]
69+
# @return [Void]
70+
def self.validate_raw(obj:)
71+
obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
72+
obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.")
73+
obj.type.is_a?(TrophyApiClient::CreateAttributeRequestItemType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
74+
end
75+
end
76+
end
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# frozen_string_literal: true
2+
3+
module TrophyApiClient
4+
# The attribute type.
5+
class CreateAttributeRequestItemType
6+
USER = "user"
7+
EVENT = "event"
8+
end
9+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "create_attribute_request_item"
4+
5+
module TrophyApiClient
6+
CREATE_ATTRIBUTES_REQUEST = Array
7+
end
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "admin_attribute"
4+
require_relative "admin_issue"
5+
require "ostruct"
6+
require "json"
7+
8+
module TrophyApiClient
9+
# Response containing created attributes and any per-item issues.
10+
class CreateAttributesResponse
11+
# @return [Array<TrophyApiClient::AdminAttribute>] Array of successfully created attributes.
12+
attr_reader :created
13+
# @return [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during attribute creation.
14+
attr_reader :issues
15+
# @return [OpenStruct] Additional properties unmapped to the current class definition
16+
attr_reader :additional_properties
17+
# @return [Object]
18+
attr_reader :_field_set
19+
protected :_field_set
20+
21+
OMIT = Object.new
22+
23+
# @param created [Array<TrophyApiClient::AdminAttribute>] Array of successfully created attributes.
24+
# @param issues [Array<TrophyApiClient::AdminIssue>] Array of issues encountered during attribute creation.
25+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
26+
# @return [TrophyApiClient::CreateAttributesResponse]
27+
def initialize(created:, issues:, additional_properties: nil)
28+
@created = created
29+
@issues = issues
30+
@additional_properties = additional_properties
31+
@_field_set = { "created": created, "issues": issues }
32+
end
33+
34+
# Deserialize a JSON object to an instance of CreateAttributesResponse
35+
#
36+
# @param json_object [String]
37+
# @return [TrophyApiClient::CreateAttributesResponse]
38+
def self.from_json(json_object:)
39+
struct = JSON.parse(json_object, object_class: OpenStruct)
40+
parsed_json = JSON.parse(json_object)
41+
created = parsed_json["created"]&.map do |item|
42+
item = item.to_json
43+
TrophyApiClient::AdminAttribute.from_json(json_object: item)
44+
end
45+
issues = parsed_json["issues"]&.map do |item|
46+
item = item.to_json
47+
TrophyApiClient::AdminIssue.from_json(json_object: item)
48+
end
49+
new(
50+
created: created,
51+
issues: issues,
52+
additional_properties: struct
53+
)
54+
end
55+
56+
# Serialize an instance of CreateAttributesResponse 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.created.is_a?(Array) != false || raise("Passed value for field obj.created is not the expected type, validation failed.")
71+
obj.issues.is_a?(Array) != false || raise("Passed value for field obj.issues is not the expected type, validation failed.")
72+
end
73+
end
74+
end

0 commit comments

Comments
 (0)