rublox 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +6 -6
- data/LICENSE +21 -21
- data/{README.MD → README.md} +68 -68
- data/Rakefile +33 -33
- data/lib/rublox/derive/group.rb +50 -50
- data/lib/rublox/derive/user.rb +89 -89
- data/lib/rublox/models/full_group.rb +60 -60
- data/lib/rublox/models/full_user.rb +49 -49
- data/lib/rublox/models/group_member.rb +54 -54
- data/lib/rublox/models/group_role.rb +355 -70
- data/lib/rublox/models/group_shout.rb +62 -62
- data/lib/rublox/models/limited_user.rb +34 -34
- data/lib/rublox/models/presence.rb +98 -98
- data/lib/rublox/util/cache.rb +39 -39
- data/lib/rublox/util/errors.rb +109 -109
- data/lib/rublox/util/http_client.rb +95 -95
- data/lib/rublox/util/pages.rb +85 -85
- data/lib/rublox/util/url.rb +25 -25
- data/lib/rublox/version.rb +6 -6
- data/lib/rublox.rb +136 -136
- data/rublox.gemspec +32 -32
- metadata +5 -6
- data/CHANGELOG.MD +0 -4
@@ -1,70 +1,355 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rublox/util/
|
4
|
-
|
5
|
-
module Rublox
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rublox/util/errors"
|
4
|
+
|
5
|
+
module Rublox
|
6
|
+
# This class is used to set a role's permissions. It uses the builder pattern to assign permissions.
|
7
|
+
# @example (see Rublox::RolePermissions#initialize)
|
8
|
+
class RolePermissions # rubocop:disable Metrics/ClassLength
|
9
|
+
# @!visibility private
|
10
|
+
PERMISSIONS = {
|
11
|
+
permissions: {
|
12
|
+
DeleteFromWall: nil,
|
13
|
+
PostToWall: nil,
|
14
|
+
InviteMembers: nil,
|
15
|
+
PostToStatus: nil,
|
16
|
+
RemoveMembers: nil,
|
17
|
+
ViewStatus: nil,
|
18
|
+
ViewWall: nil,
|
19
|
+
ChangeRank: nil,
|
20
|
+
AdvertiseGroup: nil,
|
21
|
+
ManageRelationships: nil,
|
22
|
+
AddGroupPlaces: nil,
|
23
|
+
ViewAuditLogs: nil,
|
24
|
+
CreateItems: nil,
|
25
|
+
ManageItems: nil,
|
26
|
+
SpendGroupFunds: nil,
|
27
|
+
ManageClan: nil,
|
28
|
+
ManageGroupGames: nil,
|
29
|
+
UseCloudAuthentication: nil,
|
30
|
+
AdministerCloudAuthentication: nil
|
31
|
+
}
|
32
|
+
}.freeze
|
33
|
+
|
34
|
+
# Initialize a RolePermissions object from an endpoint's data
|
35
|
+
# @!visibility private
|
36
|
+
# @param data [Hash]
|
37
|
+
# @return [RolePermissions]
|
38
|
+
def self.from_data(data) # rubocop:disable Metrics/AbcSize
|
39
|
+
permissions_data = data["permissions"]
|
40
|
+
group_posts_permissions = permissions_data["groupPostsPermissions"]
|
41
|
+
group_membership_permissions = permissions_data["groupMembershipPermissions"]
|
42
|
+
group_management_permissions = permissions_data["groupManagementPermissions"]
|
43
|
+
group_economy_permissions = permissions_data["groupEconomyPermissions"]
|
44
|
+
# group_open_cloud_permissions = permissions_data["groupOpenCloudPermissions"]
|
45
|
+
|
46
|
+
object = new
|
47
|
+
object._permissions = {
|
48
|
+
permissions: {
|
49
|
+
DeleteFromWall: group_posts_permissions["deleteFromWall"],
|
50
|
+
PostToWall: group_posts_permissions["postToWall"],
|
51
|
+
InviteMembers: group_membership_permissions["inviteMembers"],
|
52
|
+
PostToStatus: group_posts_permissions["postToStatus"],
|
53
|
+
RemoveMembers: group_membership_permissions["removeMembers"],
|
54
|
+
ViewStatus: group_posts_permissions["viewStatus"],
|
55
|
+
ViewWall: group_posts_permissions["viewWall"],
|
56
|
+
ChangeRank: group_membership_permissions["changeRank"],
|
57
|
+
AdvertiseGroup: group_economy_permissions["advertiseGroup"],
|
58
|
+
ManageRelationships: group_management_permissions["manageRelationships"],
|
59
|
+
AddGroupPlaces: group_economy_permissions["addGroupPlaces"],
|
60
|
+
ViewAuditLogs: group_management_permissions["viewAuditLogs"],
|
61
|
+
CreateItems: group_economy_permissions["createItems"],
|
62
|
+
ManageItems: group_economy_permissions["manageItems"],
|
63
|
+
SpendGroupFunds: group_economy_permissions["spendGroupFunds"],
|
64
|
+
ManageClan: group_management_permissions["manageClan"],
|
65
|
+
ManageGroupGames: group_economy_permissions["manageGroupGames"]
|
66
|
+
# UseCloudAuthentication: group_open_cloud_permissions["useCloudAuthentication"],
|
67
|
+
# AdministerCloudAuthentication: group_open_cloud_permissions["administerCloudAuthentication"]
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
object
|
72
|
+
end
|
73
|
+
|
74
|
+
# @example
|
75
|
+
# # give permissions to view and delete messages from the group wall
|
76
|
+
# role_permissions = Rublox::RolePermissions.new
|
77
|
+
# .view_wall
|
78
|
+
# .delete_from_wall
|
79
|
+
def initialize
|
80
|
+
@permissions = PERMISSIONS.clone
|
81
|
+
end
|
82
|
+
|
83
|
+
# Private getter for permissions
|
84
|
+
# @!visibility private
|
85
|
+
# @return [Hash]
|
86
|
+
def _permissions
|
87
|
+
@permissions
|
88
|
+
end
|
89
|
+
|
90
|
+
# Private setter for permissions
|
91
|
+
# @!visibility private
|
92
|
+
# @return [nil]
|
93
|
+
def _permissions=(value)
|
94
|
+
@permissions = value
|
95
|
+
end
|
96
|
+
|
97
|
+
# Allow members with the role to view the group wall
|
98
|
+
# @return [RolePermissions]
|
99
|
+
def delete_from_wall
|
100
|
+
@permissions[:permissions][:DeleteFromWall] = true
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
104
|
+
# Allow members with the role to invite members
|
105
|
+
# @return [RolePermissions]
|
106
|
+
def invite_members
|
107
|
+
@permissions[:permissions][:InviteMembers] = true
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
# Allow members with the role to post to the group's status
|
112
|
+
# @return [RolePermissions]
|
113
|
+
def post_to_status
|
114
|
+
@permissions[:permissions][:PostToStatus] = true
|
115
|
+
self
|
116
|
+
end
|
117
|
+
|
118
|
+
# Allow members with the role to remove members
|
119
|
+
# @return [RolePermissions]
|
120
|
+
def remove_members
|
121
|
+
@permissions[:permissions][:RemoveMembers] = true
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Allow members with the role to view the group's status
|
126
|
+
# @return [RolePermissions]
|
127
|
+
def view_status
|
128
|
+
@permissions[:permissions][:ViewStatus] = true
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
# Allow members with the role to view the group's wall
|
133
|
+
# @return [RolePermissions]
|
134
|
+
def view_wall
|
135
|
+
@permissions[:permissions][:ViewWall] = true
|
136
|
+
self
|
137
|
+
end
|
138
|
+
|
139
|
+
# Allow members with the role to change the rank of other members
|
140
|
+
# @return [RolePermissions]
|
141
|
+
def change_rank
|
142
|
+
@permissions[:permissions][:ChangeRank] = true
|
143
|
+
self
|
144
|
+
end
|
145
|
+
|
146
|
+
# Allow members with the role to advertise the group
|
147
|
+
# @return [RolePermissions]
|
148
|
+
def advertise_group
|
149
|
+
@permissions[:permissions][:AdvertiseGroup] = true
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
# Allow members with the role to manage the group's relationships with other groups
|
154
|
+
# @return [RolePermissions]
|
155
|
+
def manage_relationships
|
156
|
+
@permissions[:permissions][:ManageRelationships] = true
|
157
|
+
self
|
158
|
+
end
|
159
|
+
|
160
|
+
# Allow members with the role to create group places
|
161
|
+
# @return [RolePermissions]
|
162
|
+
def add_group_places
|
163
|
+
@permissions[:permissions][:AddGroupPlaces] = true
|
164
|
+
self
|
165
|
+
end
|
166
|
+
|
167
|
+
# Allow members with the role to view audit logs
|
168
|
+
# @return [RolePermissions]
|
169
|
+
def view_audit_logs
|
170
|
+
@permissions[:permissions][:ViewAuditLogs] = true
|
171
|
+
self
|
172
|
+
end
|
173
|
+
|
174
|
+
# Allow members with the role to create items
|
175
|
+
# @return [RolePermissions]
|
176
|
+
def create_items
|
177
|
+
@permissions[:permissions][:ViewStatus] = true
|
178
|
+
self
|
179
|
+
end
|
180
|
+
|
181
|
+
# Allow members with the role to manage items
|
182
|
+
# @return [RolePermissions]
|
183
|
+
def manage_items
|
184
|
+
@permissions[:permissions][:ViewStatus] = true
|
185
|
+
self
|
186
|
+
end
|
187
|
+
|
188
|
+
# Allow members with the role to spend group funds
|
189
|
+
# @return [RolePermissions]
|
190
|
+
def spend_group_funds
|
191
|
+
@permissions[:permissions][:SpendGroupFunds] = true
|
192
|
+
self
|
193
|
+
end
|
194
|
+
|
195
|
+
# Allow members with the role to manage the clan
|
196
|
+
# @return [RolePermissions]
|
197
|
+
def manage_clan
|
198
|
+
@permissions[:permissions][:ManageClan] = true
|
199
|
+
self
|
200
|
+
end
|
201
|
+
|
202
|
+
# Allow members with the role to manage group games
|
203
|
+
# @return [RolePermissions]
|
204
|
+
def manage_group_games
|
205
|
+
@permissions[:permissions][:ManageGroupGames] = true
|
206
|
+
self
|
207
|
+
end
|
208
|
+
|
209
|
+
# @!visibility private
|
210
|
+
# @todo find out what this does (open cloud?)
|
211
|
+
# @return [RolePermissions]
|
212
|
+
def use_cloud_authentication
|
213
|
+
@permissions[:permissions][:UseCloudAuthentication] = true
|
214
|
+
self
|
215
|
+
end
|
216
|
+
|
217
|
+
# (see #use_cloud_authentication)
|
218
|
+
def administer_cloud_authentication
|
219
|
+
@permissions[:permissions][:AdministerCloudAuthentication] = true
|
220
|
+
self
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
# @note This class is handled internally by the public interface such as
|
225
|
+
# {Group#roles}. You should not be creating it yourself.
|
226
|
+
# The {GroupRole} class corresponds to a group's role. You can use it to get
|
227
|
+
# and set information about roles.
|
228
|
+
class GroupRole
|
229
|
+
# @return [Integer] the role's ID
|
230
|
+
attr_reader :id
|
231
|
+
|
232
|
+
# @return [String] the role's name
|
233
|
+
attr_reader :name
|
234
|
+
|
235
|
+
# @return [String, nil] the role's description. Can be nil if the authenticated
|
236
|
+
# user does not have access to the group's role settings.
|
237
|
+
attr_reader :description
|
238
|
+
|
239
|
+
# @return [Integer] the role's rank (0-255)
|
240
|
+
attr_reader :rank
|
241
|
+
|
242
|
+
# @return [Integer] the count of how many users have the role
|
243
|
+
attr_reader :member_count
|
244
|
+
|
245
|
+
# @return [Group] the group tied to this role
|
246
|
+
attr_reader :group
|
247
|
+
|
248
|
+
# @param data [Hash]
|
249
|
+
# @param group [FullGroup]
|
250
|
+
# @param client [Client]
|
251
|
+
def initialize(data, group, client)
|
252
|
+
@id = data["id"]
|
253
|
+
@name = data["name"]
|
254
|
+
@description = data["description"]
|
255
|
+
@rank = data["rank"]
|
256
|
+
@member_count = data["memberCount"]
|
257
|
+
@group = group
|
258
|
+
|
259
|
+
@client = client
|
260
|
+
end
|
261
|
+
|
262
|
+
# @example
|
263
|
+
# client = Rublox::Client.new
|
264
|
+
# client.group_from_id(7384468)
|
265
|
+
# role = client
|
266
|
+
# .group_from_id(7384468)
|
267
|
+
# .member_by_id(1)
|
268
|
+
# .role
|
269
|
+
# puts role.rank # -> 1
|
270
|
+
# # Assume Roblox now has the Owner role
|
271
|
+
# updated_role = role.refresh
|
272
|
+
# puts updated_role.rank # -> 255
|
273
|
+
# @return [GroupRole] a mirrored {GroupRole} object, containing new information
|
274
|
+
# about the role if it has been changed.
|
275
|
+
def refresh
|
276
|
+
data = @client.http_client.get(
|
277
|
+
URL.endpoint("groups", "/v1/groups/#{@group.id}/roles")
|
278
|
+
)["roles"].find { |role| role["id"] == @id }
|
279
|
+
raise Errors::RoleNotFoundError.new(@id, @group.id) unless data
|
280
|
+
|
281
|
+
GroupRole.new(
|
282
|
+
data,
|
283
|
+
@group,
|
284
|
+
@client
|
285
|
+
)
|
286
|
+
end
|
287
|
+
|
288
|
+
# Change the role's permissions
|
289
|
+
# @example
|
290
|
+
# client = Rublox::Client.new("COOKIE")
|
291
|
+
# permissions = Rublox::RolePermissions.new
|
292
|
+
# .manage_items
|
293
|
+
# .create_items
|
294
|
+
#
|
295
|
+
# role = client
|
296
|
+
# .group_from_id(1)
|
297
|
+
# .member_by_id(1)
|
298
|
+
# .role
|
299
|
+
# role.change_permissions(permissions)
|
300
|
+
# @param permissions [RolePermissions]
|
301
|
+
# @return [nil]
|
302
|
+
def change_permissions(permissions)
|
303
|
+
@client.http_client.patch(
|
304
|
+
URL.endpoint("groups", "v1/groups/#{@group.id}/roles/#{@id}/permissions"),
|
305
|
+
json: permissions._permisions
|
306
|
+
)
|
307
|
+
|
308
|
+
nil
|
309
|
+
end
|
310
|
+
|
311
|
+
# Get the role's permissions
|
312
|
+
# @example
|
313
|
+
# client = Rublox::Client.new("COOKIE")
|
314
|
+
#
|
315
|
+
# role = client
|
316
|
+
# .group_from_id(1)
|
317
|
+
# .member_by_id(1)
|
318
|
+
# .role
|
319
|
+
# permissions = role.permissions
|
320
|
+
# @return [RolePermissions]
|
321
|
+
def permissions
|
322
|
+
RolePermissions.from_data(
|
323
|
+
@client.http_client.get(
|
324
|
+
URL.endpoint("groups", "v1/groups/#{@group.id}/roles/#{@id}/permissions")
|
325
|
+
)
|
326
|
+
)
|
327
|
+
end
|
328
|
+
|
329
|
+
# Edit the role's information
|
330
|
+
# @example
|
331
|
+
# role = client
|
332
|
+
# .group_from_id(1)
|
333
|
+
# .member_by_id(1)
|
334
|
+
# .role
|
335
|
+
#
|
336
|
+
# role.edit(name: "cool epic name", rank: 255)
|
337
|
+
# role.edit(name: "some better name", description: "cool role")
|
338
|
+
# @param name [String, nil]
|
339
|
+
# @param description [String, nil]
|
340
|
+
# @param rank [Integer, nil]
|
341
|
+
# @return [nil]
|
342
|
+
def edit(name: nil, description: nil, rank: nil)
|
343
|
+
@client.http_client.patch(
|
344
|
+
URL.endpoint("groups", "v1/groups/#{@group.id}/rolesets/#{@id}"),
|
345
|
+
json: {
|
346
|
+
name: name || @name,
|
347
|
+
description: description || @description,
|
348
|
+
rank: rank || @rank
|
349
|
+
}
|
350
|
+
)
|
351
|
+
|
352
|
+
nil
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
@@ -1,62 +1,62 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "rublox/models/limited_user"
|
4
|
-
|
5
|
-
module Rublox
|
6
|
-
# @note This class is handled internally by the public interface such as
|
7
|
-
# {FullGroup#shout}. You should not be creating it yourself.
|
8
|
-
# The {GroupShout} class corresponds to a shout response. You can use it to get
|
9
|
-
# and set information about group shouts.
|
10
|
-
class GroupShout
|
11
|
-
# @return [String] the shout's body
|
12
|
-
attr_reader :body
|
13
|
-
|
14
|
-
# @return [LimitedUser, nil] the user that made the shout, can be nil if the
|
15
|
-
# shout has no poster
|
16
|
-
attr_reader :poster
|
17
|
-
|
18
|
-
# @param data [Hash]
|
19
|
-
# @param client [Client]
|
20
|
-
# @param group_id [Integer]
|
21
|
-
def initialize(data, client, group_id)
|
22
|
-
@body = data["body"]
|
23
|
-
@poster = LimitedUser.new(data["poster"], client) if data["poster"]
|
24
|
-
|
25
|
-
@group_id = group_id
|
26
|
-
@client = client
|
27
|
-
end
|
28
|
-
|
29
|
-
# Sends a new shout.
|
30
|
-
# @example
|
31
|
-
# client = Rublox::Client.new
|
32
|
-
# group = client.group_from_id(1)
|
33
|
-
# group.shout.send_shout("new shout")
|
34
|
-
# @param new_shout [String] the body of the new shout
|
35
|
-
# @return [void]
|
36
|
-
def send_shout(new_shout)
|
37
|
-
@client.http_client.patch(
|
38
|
-
URL.endpoint("groups", "v1/groups/#{@group_id}/status"),
|
39
|
-
json: {
|
40
|
-
message: new_shout
|
41
|
-
}
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
# Clears the group shout. Same as calling {#send_shout} with an empty string.
|
46
|
-
# @example
|
47
|
-
# client = Rublox::Client.new
|
48
|
-
# group = client.group_from_id(1)
|
49
|
-
# group.shout.clear
|
50
|
-
# # same as
|
51
|
-
# group.shout.send_shout("")
|
52
|
-
# @return [void]
|
53
|
-
def clear
|
54
|
-
send_shout("")
|
55
|
-
end
|
56
|
-
|
57
|
-
# @return [GroupShout] A new group shout object with updated information.
|
58
|
-
def refresh
|
59
|
-
@client.group_from_id(@group_id).shout
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rublox/models/limited_user"
|
4
|
+
|
5
|
+
module Rublox
|
6
|
+
# @note This class is handled internally by the public interface such as
|
7
|
+
# {FullGroup#shout}. You should not be creating it yourself.
|
8
|
+
# The {GroupShout} class corresponds to a shout response. You can use it to get
|
9
|
+
# and set information about group shouts.
|
10
|
+
class GroupShout
|
11
|
+
# @return [String] the shout's body
|
12
|
+
attr_reader :body
|
13
|
+
|
14
|
+
# @return [LimitedUser, nil] the user that made the shout, can be nil if the
|
15
|
+
# shout has no poster
|
16
|
+
attr_reader :poster
|
17
|
+
|
18
|
+
# @param data [Hash]
|
19
|
+
# @param client [Client]
|
20
|
+
# @param group_id [Integer]
|
21
|
+
def initialize(data, client, group_id)
|
22
|
+
@body = data["body"]
|
23
|
+
@poster = LimitedUser.new(data["poster"], client) if data["poster"]
|
24
|
+
|
25
|
+
@group_id = group_id
|
26
|
+
@client = client
|
27
|
+
end
|
28
|
+
|
29
|
+
# Sends a new shout.
|
30
|
+
# @example
|
31
|
+
# client = Rublox::Client.new
|
32
|
+
# group = client.group_from_id(1)
|
33
|
+
# group.shout.send_shout("new shout")
|
34
|
+
# @param new_shout [String] the body of the new shout
|
35
|
+
# @return [void]
|
36
|
+
def send_shout(new_shout)
|
37
|
+
@client.http_client.patch(
|
38
|
+
URL.endpoint("groups", "v1/groups/#{@group_id}/status"),
|
39
|
+
json: {
|
40
|
+
message: new_shout
|
41
|
+
}
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Clears the group shout. Same as calling {#send_shout} with an empty string.
|
46
|
+
# @example
|
47
|
+
# client = Rublox::Client.new
|
48
|
+
# group = client.group_from_id(1)
|
49
|
+
# group.shout.clear
|
50
|
+
# # same as
|
51
|
+
# group.shout.send_shout("")
|
52
|
+
# @return [void]
|
53
|
+
def clear
|
54
|
+
send_shout("")
|
55
|
+
end
|
56
|
+
|
57
|
+
# @return [GroupShout] A new group shout object with updated information.
|
58
|
+
def refresh
|
59
|
+
@client.group_from_id(@group_id).shout
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "time"
|
4
|
-
|
5
|
-
require "rublox/derive/user"
|
6
|
-
|
7
|
-
module Rublox
|
8
|
-
# @note This class is handled internally by the public interface such as
|
9
|
-
# {FullGroup#owner}. You should not be creating it yourself.
|
10
|
-
# The {LimitedUser} is an user containing less information. It exists as some
|
11
|
-
# API's do not return full user information, and I decided to not send extra
|
12
|
-
# requests. You can call {#refresh} to get a {FullUser} if needed.
|
13
|
-
class LimitedUser
|
14
|
-
include User
|
15
|
-
|
16
|
-
# (see FullUser#id)
|
17
|
-
attr_reader :id
|
18
|
-
|
19
|
-
# (see FullUser#username)
|
20
|
-
attr_reader :username
|
21
|
-
|
22
|
-
# (see FullUser#display_name)
|
23
|
-
attr_reader :display_name
|
24
|
-
|
25
|
-
# (see FullUser#initialize)
|
26
|
-
def initialize(data, client)
|
27
|
-
@id = data["id"] || data["userId"] || data["builderId"]
|
28
|
-
@username = data["name"] || data["username"] || data["builder"]
|
29
|
-
@display_name = data["displayName"] || data["DisplayName"]
|
30
|
-
|
31
|
-
@client = client
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "time"
|
4
|
+
|
5
|
+
require "rublox/derive/user"
|
6
|
+
|
7
|
+
module Rublox
|
8
|
+
# @note This class is handled internally by the public interface such as
|
9
|
+
# {FullGroup#owner}. You should not be creating it yourself.
|
10
|
+
# The {LimitedUser} is an user containing less information. It exists as some
|
11
|
+
# API's do not return full user information, and I decided to not send extra
|
12
|
+
# requests. You can call {#refresh} to get a {FullUser} if needed.
|
13
|
+
class LimitedUser
|
14
|
+
include User
|
15
|
+
|
16
|
+
# (see FullUser#id)
|
17
|
+
attr_reader :id
|
18
|
+
|
19
|
+
# (see FullUser#username)
|
20
|
+
attr_reader :username
|
21
|
+
|
22
|
+
# (see FullUser#display_name)
|
23
|
+
attr_reader :display_name
|
24
|
+
|
25
|
+
# (see FullUser#initialize)
|
26
|
+
def initialize(data, client)
|
27
|
+
@id = data["id"] || data["userId"] || data["builderId"]
|
28
|
+
@username = data["name"] || data["username"] || data["builder"]
|
29
|
+
@display_name = data["displayName"] || data["DisplayName"]
|
30
|
+
|
31
|
+
@client = client
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|