gitlab-customer-support-operations_zendesk 1.0.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 +7 -0
- data/lib/support_ops_zendesk/packages.rb +89 -0
- data/lib/support_ops_zendesk/zendesk/app_installations.rb +62 -0
- data/lib/support_ops_zendesk/zendesk/app_job_statuses.rb +157 -0
- data/lib/support_ops_zendesk/zendesk/apps.rb +476 -0
- data/lib/support_ops_zendesk/zendesk/articles.rb +362 -0
- data/lib/support_ops_zendesk/zendesk/audit_logs.rb +166 -0
- data/lib/support_ops_zendesk/zendesk/automations.rb +390 -0
- data/lib/support_ops_zendesk/zendesk/base.rb +472 -0
- data/lib/support_ops_zendesk/zendesk/brands.rb +172 -0
- data/lib/support_ops_zendesk/zendesk/client.rb +91 -0
- data/lib/support_ops_zendesk/zendesk/comments.rb +37 -0
- data/lib/support_ops_zendesk/zendesk/configuration.rb +138 -0
- data/lib/support_ops_zendesk/zendesk/custom_roles.rb +224 -0
- data/lib/support_ops_zendesk/zendesk/dynamic_content.rb +297 -0
- data/lib/support_ops_zendesk/zendesk/dynamic_content_variants.rb +309 -0
- data/lib/support_ops_zendesk/zendesk/group_memberships.rb +337 -0
- data/lib/support_ops_zendesk/zendesk/groups.rb +385 -0
- data/lib/support_ops_zendesk/zendesk/help_center_categories.rb +332 -0
- data/lib/support_ops_zendesk/zendesk/help_center_content_tags.rb +237 -0
- data/lib/support_ops_zendesk/zendesk/help_center_management_permission_groups.rb +271 -0
- data/lib/support_ops_zendesk/zendesk/help_center_sections.rb +378 -0
- data/lib/support_ops_zendesk/zendesk/help_center_topics.rb +274 -0
- data/lib/support_ops_zendesk/zendesk/help_center_user_segments.rb +279 -0
- data/lib/support_ops_zendesk/zendesk/job_statuses.rb +231 -0
- data/lib/support_ops_zendesk/zendesk/locales.rb +326 -0
- data/lib/support_ops_zendesk/zendesk/macros.rb +407 -0
- data/lib/support_ops_zendesk/zendesk/oauth_clients.rb +186 -0
- data/lib/support_ops_zendesk/zendesk/oauth_tokens.rb +114 -0
- data/lib/support_ops_zendesk/zendesk/organization_fields.rb +282 -0
- data/lib/support_ops_zendesk/zendesk/organization_memberships.rb +336 -0
- data/lib/support_ops_zendesk/zendesk/organizations.rb +568 -0
- data/lib/support_ops_zendesk/zendesk/requester_roles.rb +58 -0
- data/lib/support_ops_zendesk/zendesk/satisfaction_reasons.rb +161 -0
- data/lib/support_ops_zendesk/zendesk/schedule_holidays.rb +27 -0
- data/lib/support_ops_zendesk/zendesk/schedules.rb +192 -0
- data/lib/support_ops_zendesk/zendesk/search.rb +185 -0
- data/lib/support_ops_zendesk/zendesk/sla_policies.rb +302 -0
- data/lib/support_ops_zendesk/zendesk/targets.rb +96 -0
- data/lib/support_ops_zendesk/zendesk/theme_job_statuses.rb +154 -0
- data/lib/support_ops_zendesk/zendesk/themes.rb +328 -0
- data/lib/support_ops_zendesk/zendesk/ticket_field_options.rb +154 -0
- data/lib/support_ops_zendesk/zendesk/ticket_fields.rb +357 -0
- data/lib/support_ops_zendesk/zendesk/ticket_forms.rb +370 -0
- data/lib/support_ops_zendesk/zendesk/ticket_user_types.rb +67 -0
- data/lib/support_ops_zendesk/zendesk/tickets.rb +837 -0
- data/lib/support_ops_zendesk/zendesk/translations.rb +310 -0
- data/lib/support_ops_zendesk/zendesk/trigger_categories.rb +275 -0
- data/lib/support_ops_zendesk/zendesk/triggers.rb +427 -0
- data/lib/support_ops_zendesk/zendesk/user_field_options.rb +153 -0
- data/lib/support_ops_zendesk/zendesk/user_fields.rb +312 -0
- data/lib/support_ops_zendesk/zendesk/users.rb +889 -0
- data/lib/support_ops_zendesk/zendesk/via_types.rb +137 -0
- data/lib/support_ops_zendesk/zendesk/views.rb +636 -0
- data/lib/support_ops_zendesk/zendesk/webhooks.rb +206 -0
- data/lib/support_ops_zendesk/zendesk.rb +66 -0
- data/lib/support_ops_zendesk.rb +29 -0
- metadata +274 -0
@@ -0,0 +1,889 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module SupportOps.
|
4
|
+
module SupportOps
|
5
|
+
# Defines the module Zendesk
|
6
|
+
module Zendesk
|
7
|
+
##
|
8
|
+
# Defines the class Users within the module {SupportOps::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.0
|
12
|
+
# @attr [Boolean] active false if the user has been deleted
|
13
|
+
# @attr [String] alias An alias displayed to end users
|
14
|
+
# @attr [String] created_at The time the user was created
|
15
|
+
# @attr [Integer] custom_role_id A custom role if the user is an agent on the Enterprise plan or above
|
16
|
+
# @attr [Integer] default_group_id The id of the user's default group
|
17
|
+
# @attr [String] details Any details you want to store about the user, such as an address
|
18
|
+
# @attr [String] email The user's primary email address.
|
19
|
+
# @attr [Integer] external_id A unique identifier from another system.
|
20
|
+
# @attr [String] iana_time_zone The time zone for the user
|
21
|
+
# @attr [Integer] id Automatically assigned when the user is created
|
22
|
+
# @attr [String] last_login_at Last time the user signed in to Zendesk Support or made an API request using an API token or basic authentication
|
23
|
+
# @attr [String] locale The user's locale. A BCP-47 compliant tag for the locale. If both "locale" and "locale_id" are present on create or update, "locale_id" is ignored and only "locale" is used.
|
24
|
+
# @attr [Integer] locale_id The user's language identifier
|
25
|
+
# @attr [Boolean] moderator Designates whether the user has forum moderation capabilities
|
26
|
+
# @attr [String] name The user's name
|
27
|
+
# @attr [String] notes Any notes you want to store about the user
|
28
|
+
# @attr [Boolean] only_private_comments true if the user can only create private comments
|
29
|
+
# @attr [Integer] organization_id The id of the user's organization. If the user has more than one organization memberships, the id of the user's default organization
|
30
|
+
# @attr [String] phone The user's primary phone number
|
31
|
+
# @attr [Boolean] report_csv This parameter is inert and has no effect. It may be deprecated in the future. Previously, this parameter determined whether a user could access a CSV report in a legacy Guide dashboard. This dashboard has been removed.
|
32
|
+
# @attr [Boolean] restricted_agent If the agent has any restrictions; false for admins and unrestricted agents, true for other agents
|
33
|
+
# @attr [String] role The user's role. Possible values are "end-user", "agent", or "admin"
|
34
|
+
# @attr [Integer] role_type The user's role id. 0 for a custom agent, 1 for a light agent, 2 for a chat agent, 3 for a chat agent added to the Support account as a contributor (Chat Phase 4), 4 for an admin, and 5 for a billing admin
|
35
|
+
# @attr [Boolean] shared If the user is shared from a different Zendesk Support instance. Ticket sharing accounts only
|
36
|
+
# @attr [Boolean] shared_agent If the user is a shared agent from a different Zendesk Support instance. Ticket sharing accounts only
|
37
|
+
# @attr [Boolean] shared_phone_number Whether the phone number is shared or not.
|
38
|
+
# @attr [String] signature The user's signature. Only agents and admins can have signatures
|
39
|
+
# @attr [Boolean] suspended If the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal
|
40
|
+
# @attr [Array] tags The user's tags. Only present if your account has user tagging enabled
|
41
|
+
# @attr [String] ticket_restriction Specifies which tickets the user has access to. Possible values are: "organization", "groups", "assigned", "requested", null. "groups" and "assigned" are valid only for agents. If you pass an invalid value to an end user (for example, "groups"), they will be assigned to "requested", regardless of their previous access
|
42
|
+
# @attr [String] time_zone The user's time zone.
|
43
|
+
# @attr [Boolean] two_factor_auth_enabled If two factor authentication is enabled
|
44
|
+
# @attr [String] updated_at The time the user was last updated
|
45
|
+
# @attr [Object] user_fields Values of custom fields in the user's profile.
|
46
|
+
# @attr [Boolean] verified Any of the user's identities is verified.
|
47
|
+
# @todo Show User Related Information => https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user-related-information
|
48
|
+
# @todo Show Self => https://developer.zendesk.com/api-reference/ticketing/users/users/#show-self
|
49
|
+
# @todo Merge End Users => https://developer.zendesk.com/api-reference/ticketing/users/users/#merge-end-users
|
50
|
+
# @todo Request User Create => https://developer.zendesk.com/api-reference/ticketing/users/users/#request-user-create
|
51
|
+
class Users < SupportOps::Zendesk::Base
|
52
|
+
# @!parse
|
53
|
+
# # Creates/updates a user
|
54
|
+
# #
|
55
|
+
# # @author Jason Colyer
|
56
|
+
# # @since 1.0.0
|
57
|
+
# # @return [Object] Instance of {SupportOps::Zendesk::Users}
|
58
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#save!}
|
59
|
+
# # @see
|
60
|
+
# # https://developer.zendesk.com/api-reference/ticketing/users/users/#create-user
|
61
|
+
# # Zendesk API > Users > Create User
|
62
|
+
# # @see
|
63
|
+
# # https://developer.zendesk.com/api-reference/ticketing/users/users/#update-user
|
64
|
+
# # Zendesk API > Users > Update User
|
65
|
+
# # @example
|
66
|
+
# # require 'support_ops_zendesk'
|
67
|
+
# #
|
68
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
69
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
70
|
+
# # config.username = 'jason@example.com'
|
71
|
+
# # config.token = 'abc123'
|
72
|
+
# # end
|
73
|
+
# #
|
74
|
+
# # new_user = SupportOps::Zendesk::Users.new
|
75
|
+
# # new_user.custom_role_id = 123456
|
76
|
+
# # new_user.email = 'roge@example.org'
|
77
|
+
# # new_user.name = 'Roger Wilco'
|
78
|
+
# # new_user.organization_id = 57542
|
79
|
+
# # new_user.role = 'agent'
|
80
|
+
# # new_user.role_type = 0
|
81
|
+
# #
|
82
|
+
# # new_user.save!
|
83
|
+
# #
|
84
|
+
# # pp new_user.id
|
85
|
+
# # # => 9873843
|
86
|
+
# # @example
|
87
|
+
# # require 'support_ops_zendesk'
|
88
|
+
# #
|
89
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
90
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
91
|
+
# # config.username = 'jason@example.com'
|
92
|
+
# # config.token = 'abc123'
|
93
|
+
# # end
|
94
|
+
# #
|
95
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
96
|
+
# # existing_user.name = 'Roger Wilco II'
|
97
|
+
# #
|
98
|
+
# # existing_user.save!
|
99
|
+
# #
|
100
|
+
# # pp existing_user.name
|
101
|
+
# # # => "Roger Wilco II"
|
102
|
+
# def save!; end
|
103
|
+
# @!parse
|
104
|
+
# # Deletes a user
|
105
|
+
# #
|
106
|
+
# # @author Jason Colyer
|
107
|
+
# # @since 1.0.0
|
108
|
+
# # @return [Boolean]
|
109
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#delete!}
|
110
|
+
# # @see
|
111
|
+
# # https://developer.zendesk.com/api-reference/ticketing/users/users/#delete-user
|
112
|
+
# # Zendesk API > Users > Delete User
|
113
|
+
# # @example
|
114
|
+
# # require 'support_ops_zendesk'
|
115
|
+
# #
|
116
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
117
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
118
|
+
# # config.username = 'jason@example.com'
|
119
|
+
# # config.token = 'abc123'
|
120
|
+
# # end
|
121
|
+
# #
|
122
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
123
|
+
# # existing_user.delete!
|
124
|
+
# def delete!; end
|
125
|
+
# @!parse
|
126
|
+
# # List the organization details of a user.
|
127
|
+
# #
|
128
|
+
# # @author Jason Colyer
|
129
|
+
# # @since 1.0.0
|
130
|
+
# # @return [Various]
|
131
|
+
# # - If there is no organization, it returns nil
|
132
|
+
# # - If there is an organization, a {SupportOps::Zendesk::Organizations} instance
|
133
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#organization}
|
134
|
+
# # @example
|
135
|
+
# # require 'support_ops_zendesk'
|
136
|
+
# #
|
137
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
138
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
139
|
+
# # config.username = 'jason@example.com'
|
140
|
+
# # config.token = 'abc123'
|
141
|
+
# # end
|
142
|
+
# #
|
143
|
+
# # user = SupportOps::Zendesk::Users.get!(9873843)
|
144
|
+
# # org = user.organization
|
145
|
+
# # pp org.name
|
146
|
+
# # # => "Bob's Burgers"
|
147
|
+
# def organization; end
|
148
|
+
# @!parse
|
149
|
+
# # Creates or updates a user
|
150
|
+
# #
|
151
|
+
# # @author Jason Colyer
|
152
|
+
# # @since 1.0.0
|
153
|
+
# # @return [Object]
|
154
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#create_or_update!}
|
155
|
+
# # @see
|
156
|
+
# # https://developer.zendesk.com/api-reference/ticketing/users/users/#create-or-update-user
|
157
|
+
# # Zendesk API > Users > Create Or Update User
|
158
|
+
# # @example
|
159
|
+
# # require 'support_ops_zendesk'
|
160
|
+
# #
|
161
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
162
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
163
|
+
# # config.username = 'jason@example.com'
|
164
|
+
# # config.token = 'abc123'
|
165
|
+
# # end
|
166
|
+
# #
|
167
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
168
|
+
# # existing_user.name = 'Roger Wilco II'
|
169
|
+
# #
|
170
|
+
# # existing_user.create_or_update!
|
171
|
+
# #
|
172
|
+
# # pp existing_user.name
|
173
|
+
# # # => "Roger Wilco II"
|
174
|
+
# def create_or_update!; end
|
175
|
+
# @!parse
|
176
|
+
# # Lists requested ticketrs for a user
|
177
|
+
# #
|
178
|
+
# # @author Jason Colyer
|
179
|
+
# # @since 1.0.0
|
180
|
+
# # @return [Array]
|
181
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#tickets}
|
182
|
+
# # @see
|
183
|
+
# # https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
|
184
|
+
# # Zendesk API > Tickets > List Tickets
|
185
|
+
# # @example
|
186
|
+
# # require 'support_ops_zendesk'
|
187
|
+
# #
|
188
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
189
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
190
|
+
# # config.username = 'jason@example.com'
|
191
|
+
# # config.token = 'abc123'
|
192
|
+
# # end
|
193
|
+
# #
|
194
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
195
|
+
# # tickets = existing_user.tickets
|
196
|
+
# #
|
197
|
+
# # pp tickets.count
|
198
|
+
# # # => 28
|
199
|
+
# def tickets; end
|
200
|
+
# @!parse
|
201
|
+
# # Lists CCd tickets for a user
|
202
|
+
# #
|
203
|
+
# # @author Jason Colyer
|
204
|
+
# # @since 1.0.0
|
205
|
+
# # @return [Array]
|
206
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#ccd_tickets}
|
207
|
+
# # @see
|
208
|
+
# # https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
|
209
|
+
# # Zendesk API > Tickets > List Tickets
|
210
|
+
# # @example
|
211
|
+
# # require 'support_ops_zendesk'
|
212
|
+
# #
|
213
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
214
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
215
|
+
# # config.username = 'jason@example.com'
|
216
|
+
# # config.token = 'abc123'
|
217
|
+
# # end
|
218
|
+
# #
|
219
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
220
|
+
# # tickets = existing_user.ccd_tickets
|
221
|
+
# #
|
222
|
+
# # pp tickets.count
|
223
|
+
# # # => 2
|
224
|
+
# def ccd_tickets; end
|
225
|
+
# @!parse
|
226
|
+
# # Lists assigned tickets for a user
|
227
|
+
# #
|
228
|
+
# # @author Jason Colyer
|
229
|
+
# # @since 1.0.0
|
230
|
+
# # @return [Array]
|
231
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#assigned_tickets}
|
232
|
+
# # @see
|
233
|
+
# # https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets
|
234
|
+
# # Zendesk API > Tickets > List Tickets
|
235
|
+
# # @example
|
236
|
+
# # require 'support_ops_zendesk'
|
237
|
+
# #
|
238
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
239
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
240
|
+
# # config.username = 'jason@example.com'
|
241
|
+
# # config.token = 'abc123'
|
242
|
+
# # end
|
243
|
+
# #
|
244
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
245
|
+
# # tickets = existing_user.assigned_tickets
|
246
|
+
# #
|
247
|
+
# # pp tickets.count
|
248
|
+
# # # => 56
|
249
|
+
# def assigned_tickets; end
|
250
|
+
# @!parse
|
251
|
+
# # List organization members for a user
|
252
|
+
# #
|
253
|
+
# # @author Jason Colyer
|
254
|
+
# # @since 1.0.0
|
255
|
+
# # @return [Array]
|
256
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#organization_memberships}
|
257
|
+
# # @see
|
258
|
+
# # https://developer.zendesk.com/api-reference/ticketing/organizations/organization_memberships/#list-memberships
|
259
|
+
# # Zendesk API > Organization Memberships > List Memberships
|
260
|
+
# # @example
|
261
|
+
# # require 'support_ops_zendesk'
|
262
|
+
# #
|
263
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
264
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
265
|
+
# # config.username = 'jason@example.com'
|
266
|
+
# # config.token = 'abc123'
|
267
|
+
# # end
|
268
|
+
# #
|
269
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
270
|
+
# # memberships = existing_user.organization_memberships
|
271
|
+
# #
|
272
|
+
# # pp memberships.map { |m| m.organization_id }
|
273
|
+
# # # => [123, 854]
|
274
|
+
# def organization_memberships; end
|
275
|
+
# @!parse
|
276
|
+
# # List group members for a user
|
277
|
+
# #
|
278
|
+
# # @author Jason Colyer
|
279
|
+
# # @since 1.0.0
|
280
|
+
# # @return [Array]
|
281
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#group_memberships}
|
282
|
+
# # @see
|
283
|
+
# # https://developer.zendesk.com/api-reference/ticketing/groups/group_memberships/#list-memberships
|
284
|
+
# # Zendesk API > Group Memberships > List Memberships
|
285
|
+
# # @example
|
286
|
+
# # require 'support_ops_zendesk'
|
287
|
+
# #
|
288
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
289
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
290
|
+
# # config.username = 'jason@example.com'
|
291
|
+
# # config.token = 'abc123'
|
292
|
+
# # end
|
293
|
+
# #
|
294
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
295
|
+
# # memberships = existing_user.group_memberships
|
296
|
+
# #
|
297
|
+
# # pp memberships.map { |m| m.group_id }
|
298
|
+
# # # => [28, 59]
|
299
|
+
# def group_memberships; end
|
300
|
+
# @!parse
|
301
|
+
# # Sets the password for a user
|
302
|
+
# #
|
303
|
+
# # @author Jason Colyer
|
304
|
+
# # @since 1.0.0
|
305
|
+
# # @return [Boolean]
|
306
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#set_password!}
|
307
|
+
# # @see
|
308
|
+
# # https://developer.zendesk.com/api-reference/ticketing/users/user_passwords/#set-a-users-password
|
309
|
+
# # Zendesk API > User Password > Set a User's Password
|
310
|
+
# # @example
|
311
|
+
# # require 'support_ops_zendesk'
|
312
|
+
# #
|
313
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
314
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
315
|
+
# # config.username = 'jason@example.com'
|
316
|
+
# # config.token = 'abc123'
|
317
|
+
# # end
|
318
|
+
# #
|
319
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
320
|
+
# # existing_user.password = 'Test123!'
|
321
|
+
# #
|
322
|
+
# # existing_user.set_password!
|
323
|
+
# def set_password!; end
|
324
|
+
# @!parse
|
325
|
+
# # Lists the organizations a user
|
326
|
+
# #
|
327
|
+
# # @author Jason Colyer
|
328
|
+
# # @since 1.0.0
|
329
|
+
# # @return [Array]
|
330
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#organizations}
|
331
|
+
# # @example
|
332
|
+
# # require 'support_ops_zendesk'
|
333
|
+
# #
|
334
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
335
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
336
|
+
# # config.username = 'jason@example.com'
|
337
|
+
# # config.token = 'abc123'
|
338
|
+
# # end
|
339
|
+
# #
|
340
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
341
|
+
# # orgs = existing_user.organizations
|
342
|
+
# #
|
343
|
+
# # pp orgs.map { |o| o.id }
|
344
|
+
# # # => [123, 854]
|
345
|
+
# def organizations; end
|
346
|
+
# @!parse
|
347
|
+
# # Lists the groups a user
|
348
|
+
# #
|
349
|
+
# # @author Jason Colyer
|
350
|
+
# # @since 1.0.0
|
351
|
+
# # @return [Array]
|
352
|
+
# # @note This is inherited from {SupportOps::Zendesk::Base#groups}
|
353
|
+
# # @example
|
354
|
+
# # require 'support_ops_zendesk'
|
355
|
+
# #
|
356
|
+
# # SupportOps::Zendesk::Configuration.configure do |config|
|
357
|
+
# # config.url = 'https://gitlab.zendesk.com/api/v2'
|
358
|
+
# # config.username = 'jason@example.com'
|
359
|
+
# # config.token = 'abc123'
|
360
|
+
# # end
|
361
|
+
# #
|
362
|
+
# # existing_user = SupportOps::Zendesk::Users.get!(9873843)
|
363
|
+
# # groups = existing_user.groups
|
364
|
+
# #
|
365
|
+
# # pp groups.map { |g| g.id }
|
366
|
+
# # # => [28, 59]
|
367
|
+
# def groups; end
|
368
|
+
|
369
|
+
define_attributes :active, :alias, :created_at, :custom_role_id,
|
370
|
+
:default_group_id, :details, :email, :external_id,
|
371
|
+
:iana_time_zone, :id, :last_login_at, :locale,
|
372
|
+
:locale_id, :moderator, :name, :notes,
|
373
|
+
:only_private_comments, :organization_id, :password,
|
374
|
+
:phone, :report_csv, :restricted_agent, :role,
|
375
|
+
:role_type, :shared, :shared_agent,
|
376
|
+
:shared_phone_number, :signature, :suspended, :tags,
|
377
|
+
:ticket_restriction, :time_zone,
|
378
|
+
:two_factor_auth_enabled, :updated_at, :user_fields,
|
379
|
+
:verified
|
380
|
+
readonly_attributes :id, :created_at, :last_login_at, :updated_at
|
381
|
+
|
382
|
+
##
|
383
|
+
# Lists users in the Zendesk system
|
384
|
+
#
|
385
|
+
# @author Jason Colyer
|
386
|
+
# @since 1.0.0
|
387
|
+
# @overload list(key: value)
|
388
|
+
# @param external_id [String optional] TList users by external id.
|
389
|
+
# External id has to be unique for each user under the same account.
|
390
|
+
# @param permission_set [Integer optional] For custom roles which is
|
391
|
+
# available on the Enterprise plan and above. You can only filter by
|
392
|
+
# one role ID per request
|
393
|
+
# @param role [String optional] Filters the results by role. Possible
|
394
|
+
# values are "end-user", "agent", or "admin". Allowed values are
|
395
|
+
# "end-user", "agent", or "admin".
|
396
|
+
# @param roles [Array optional] Filters the results by more than one
|
397
|
+
# role
|
398
|
+
# @param limit [Integer optional] The limit to the number of tickets
|
399
|
+
# returned. Default to 0 (i.e. no limit)
|
400
|
+
# @return [Array]
|
401
|
+
# @see
|
402
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users
|
403
|
+
# Zendesk API > USers > List Users
|
404
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
405
|
+
# @example
|
406
|
+
# require 'support_ops_zendesk'
|
407
|
+
#
|
408
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
409
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
410
|
+
# config.username = 'jason@example.com'
|
411
|
+
# config.token = 'abc123'
|
412
|
+
# end
|
413
|
+
#
|
414
|
+
# users = SupportOps::Zendesk::Users.list(limit: 250)
|
415
|
+
# pp users.count
|
416
|
+
# # => 250
|
417
|
+
# pp users.last.email
|
418
|
+
# # => "gabe@example.com"
|
419
|
+
def self.list(**args)
|
420
|
+
args[:external_id] = nil unless args[:external_id]
|
421
|
+
args[:permission_set] = nil unless args[:permission_set]
|
422
|
+
args[:role] = nil unless args[:role]
|
423
|
+
args[:roles] = [] unless args[:roles]
|
424
|
+
args[:limit] = 0 unless args[:limit]
|
425
|
+
params = ''
|
426
|
+
params += args[:roles].map { |r| "role[]=#{r}" }.join('&') unless args[:roles].count.zero?
|
427
|
+
params += '&' unless args[:roles].count.zero?
|
428
|
+
params += "external_id=#{args[:external_id]}&" unless args[:external_id].nil?
|
429
|
+
params += "permission_set=#{args[:permission_set]}&" unless args[:permission_set].nil?
|
430
|
+
params += "role=#{args[:role]}&" unless args[:role].nil?
|
431
|
+
users = []
|
432
|
+
opts = "#{params}page[size]=100"
|
433
|
+
loop do
|
434
|
+
response = client.connection.get("users?#{opts}")
|
435
|
+
body = Oj.load(response.body)
|
436
|
+
users += body['users'].map { |t| Users.new(t) }
|
437
|
+
break if args[:limit].to_i.positive? && users.count >= args[:limit].to_i
|
438
|
+
break unless body['meta']['has_more']
|
439
|
+
|
440
|
+
opts = body['links']['next'].split('?').last
|
441
|
+
end
|
442
|
+
return users if args[:limit].to_i.zero?
|
443
|
+
|
444
|
+
users.first(args[:limit].to_i)
|
445
|
+
end
|
446
|
+
|
447
|
+
##
|
448
|
+
# Returns an approximate count of users in the account. If the count exceeds 100,000, it is updated every 24 hours.
|
449
|
+
#
|
450
|
+
# @author Jason Colyer
|
451
|
+
# @since 1.0.0
|
452
|
+
# @return [Hash]
|
453
|
+
# @see
|
454
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#count-users
|
455
|
+
# Zendesk API > Users > Count Users
|
456
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
457
|
+
# @example
|
458
|
+
# require 'support_ops_zendesk'
|
459
|
+
#
|
460
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
461
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
462
|
+
# config.username = 'jason@example.com'
|
463
|
+
# config.token = 'abc123'
|
464
|
+
# end
|
465
|
+
#
|
466
|
+
# users = SupportOps::Zendesk::Users.count
|
467
|
+
# pp users['value']
|
468
|
+
# # => 102
|
469
|
+
def self.count
|
470
|
+
response = client.connection.get('users/count')
|
471
|
+
Oj.load(response.body)['count']
|
472
|
+
end
|
473
|
+
|
474
|
+
##
|
475
|
+
# Locates a specific user in the Zendesk system
|
476
|
+
#
|
477
|
+
# @author Jason Colyer
|
478
|
+
# @since 1.0.0
|
479
|
+
# @see
|
480
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user
|
481
|
+
# Zendesk API > Users > Show User
|
482
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
483
|
+
# @example
|
484
|
+
# require 'support_ops_zendesk'
|
485
|
+
#
|
486
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
487
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
488
|
+
# config.username = 'jason@example.com'
|
489
|
+
# config.token = 'abc123'
|
490
|
+
# end
|
491
|
+
#
|
492
|
+
# user = SupportOps::Zendesk::Users.get(13983927615772)
|
493
|
+
# pp user.email
|
494
|
+
# # => "gabe@example.com"
|
495
|
+
def self.get(object)
|
496
|
+
if object.is_a? Users
|
497
|
+
Users.new(id: id).find
|
498
|
+
else
|
499
|
+
Users.new(id: object).find
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|
503
|
+
##
|
504
|
+
# Locates a specific user in the Zendesk system
|
505
|
+
#
|
506
|
+
# @author Jason Colyer
|
507
|
+
# @since 1.0.0
|
508
|
+
# @see
|
509
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user
|
510
|
+
# Zendesk API > Users > Show User
|
511
|
+
# @see SupportOps::Zendesk::Configuration Setting up a client
|
512
|
+
# @example
|
513
|
+
# require 'support_ops_zendesk'
|
514
|
+
#
|
515
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
516
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
517
|
+
# config.username = 'jason@example.com'
|
518
|
+
# config.token = 'abc123'
|
519
|
+
# end
|
520
|
+
#
|
521
|
+
# user = SupportOps::Zendesk::Users.get!(13983927615772)
|
522
|
+
# pp user.email
|
523
|
+
# # => "gabe@example.com"
|
524
|
+
def self.get!(object)
|
525
|
+
if object.is_a? Users
|
526
|
+
Users.new(id: id).find!
|
527
|
+
else
|
528
|
+
Users.new(id: object).find!
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
##
|
533
|
+
# Locates up to 100 users within Zendesk.
|
534
|
+
#
|
535
|
+
# @author Jason Colyer
|
536
|
+
# @since 1.0.0
|
537
|
+
# @param user_ids [Array] The ticket IDs to find
|
538
|
+
# @return [Array]
|
539
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/users/users/#show-many-users Zendesk API > Users > Show Many Users
|
540
|
+
# @example
|
541
|
+
# require 'support_ops_zendesk'
|
542
|
+
#
|
543
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
544
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
545
|
+
# config.username = 'jason@example.com'
|
546
|
+
# config.token = 'abc123'
|
547
|
+
# end
|
548
|
+
#
|
549
|
+
# users = SupportOps::Zendesk::Users.get_many([255, 256])
|
550
|
+
# pp users.map { |u| u.name }
|
551
|
+
# # => ["Alice", "Bob"]
|
552
|
+
def self.get_many(user_ids)
|
553
|
+
raise 'The parameter must be an Array' unless user_ids.is_a? Array
|
554
|
+
raise 'You can only get a maximum of 100 users at a time' if user_ids.count > 100
|
555
|
+
|
556
|
+
response = client.connection.get("users/show_many?ids=#{user_ids.join(',')}")
|
557
|
+
Oj.load(response.body)['users'].map { |u| Users.new(u) }
|
558
|
+
end
|
559
|
+
|
560
|
+
##
|
561
|
+
# Deletes multiple users via a batch job
|
562
|
+
#
|
563
|
+
# @author Jason Colyer
|
564
|
+
# @since 1.0.0
|
565
|
+
# @param user_ids [Array] An array of user IDs
|
566
|
+
# @return [object] A {SupportOps::Zendesk::JobStatuses} instance
|
567
|
+
# @see
|
568
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#bulk-delete-users
|
569
|
+
# Zendesk API > Users > Bulk Delete Users
|
570
|
+
# @example
|
571
|
+
# require 'support_ops_zendesk'
|
572
|
+
#
|
573
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
574
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
575
|
+
# config.username = 'jason@example.com'
|
576
|
+
# config.token = 'abc123'
|
577
|
+
# end
|
578
|
+
#
|
579
|
+
# delete = SupportOps::Zendesk::Users.delete_many!([35436, 35437])
|
580
|
+
# pp delete.id
|
581
|
+
# # => "82de0b044094f0c67893ac9fe64f1a99"
|
582
|
+
def self.delete_many!(user_ids)
|
583
|
+
raise 'The parameter must be an Array' unless user_ids.is_a? Array
|
584
|
+
raise 'You can only delete a maximum of 100 users at a time' if user_ids.count > 100
|
585
|
+
|
586
|
+
response = client.connection.delete("users/destroy_many?ids=#{user_ids.join(',')}")
|
587
|
+
raise "Failed to users users => #{body['details']}" if response.status != 200
|
588
|
+
JobStatuses.new(Oj.load(response.body)['job_status'])
|
589
|
+
end
|
590
|
+
|
591
|
+
##
|
592
|
+
# Creates multiple users via a batch job
|
593
|
+
#
|
594
|
+
# @author Jason Colyer
|
595
|
+
# @since 1.0.0
|
596
|
+
# @param users [Array] An array of {SupportOps::Zendesk::Users} instances
|
597
|
+
# @return [object] A {SupportOps::Zendesk::JobStatuses} instance
|
598
|
+
# @see
|
599
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#create-many-users
|
600
|
+
# Zendesk API > Users > Create Many Users
|
601
|
+
# @example
|
602
|
+
# require 'support_ops_zendesk'
|
603
|
+
#
|
604
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
605
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
606
|
+
# config.username = 'jason@example.com'
|
607
|
+
# config.token = 'abc123'
|
608
|
+
# end
|
609
|
+
#
|
610
|
+
# user1 = SupportOps::Zendesk::Users.new
|
611
|
+
# user1.name = 'Alice'
|
612
|
+
# user1.email = 'alice@example.com'
|
613
|
+
# user2 = SupportOps::Zendesk::Users.new
|
614
|
+
# user2.name = 'Bob'
|
615
|
+
# user2.email = 'bob@example.com'
|
616
|
+
#
|
617
|
+
# creates = SupportOps::Zendesk::Users.create_many!([user1, user2])
|
618
|
+
# pp creates.id
|
619
|
+
# # => "82de0b044094f0c67893ac9fe64f1a99"
|
620
|
+
def self.create_many!(users)
|
621
|
+
raise 'The parameter must be an Array' unless users.is_a? Array
|
622
|
+
raise 'You can only create a maximum of 100 users at a time' if users.count > 100
|
623
|
+
raise 'You can only use SupportOps::Zendesk::Users instances in the Array' unless users.reject { |t| t.is_a? SupportOps::Zendesk::Users }.count.zero?
|
624
|
+
|
625
|
+
data = { users: users.map { |u| to_hash(u).compact } }.to_json
|
626
|
+
response = client.connection.post('users/create_many', data)
|
627
|
+
raise "Failed to create users => #{body['details']}" if response.status != 200
|
628
|
+
JobStatuses.new(Oj.load(response.body)['job_status'])
|
629
|
+
end
|
630
|
+
|
631
|
+
##
|
632
|
+
# Updates multiple users via a batch job
|
633
|
+
#
|
634
|
+
# @author Jason Colyer
|
635
|
+
# @since 1.0.0
|
636
|
+
# @param users [Array] An array of {SupportOps::Zendesk::Users} instances
|
637
|
+
# @return [object] A {SupportOps::Zendesk::JobStatuses} instance
|
638
|
+
# @see
|
639
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#update-many-users
|
640
|
+
# Zendesk API > Users > Update Many Users
|
641
|
+
# @example
|
642
|
+
# require 'support_ops_zendesk'
|
643
|
+
#
|
644
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
645
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
646
|
+
# config.username = 'jason@example.com'
|
647
|
+
# config.token = 'abc123'
|
648
|
+
# end
|
649
|
+
#
|
650
|
+
# user1 = SupportOps::Zendesk::Users.get!(123)
|
651
|
+
# user1.name = 'Alice2'
|
652
|
+
# user2 = SupportOps::Zendesk::Users.get!(456)
|
653
|
+
# user2.name = 'Bob2'
|
654
|
+
#
|
655
|
+
# updates = SupportOps::Zendesk::Users.update_many!([user1, user2])
|
656
|
+
# pp updates.id
|
657
|
+
# # => "82de0b044094f0c67893ac9fe64f1a99"
|
658
|
+
def self.update_many!(users)
|
659
|
+
raise 'The parameter must be an Array' unless users.is_a? Array
|
660
|
+
raise 'You can only update a maximum of 100 users at a time' if users.count > 100
|
661
|
+
raise 'You can only use SupportOps::Zendesk::Tickets instances in the Array' unless users.reject { |t| t.is_a? SupportOps::Zendesk::Users }.count.zero?
|
662
|
+
|
663
|
+
data = { users: users.map { |u| to_hash(u).compact } }.to_json
|
664
|
+
response = client.connection.put('users/update_many', data)
|
665
|
+
raise "Failed to update users => #{body['details']}" if response.status != 200
|
666
|
+
JobStatuses.new(Oj.load(response.body)['job_status'])
|
667
|
+
end
|
668
|
+
|
669
|
+
##
|
670
|
+
# Create or update multiple users via a batch job
|
671
|
+
#
|
672
|
+
# @author Jason Colyer
|
673
|
+
# @since 1.0.0
|
674
|
+
# @param users [Array] An array of {SupportOps::Zendesk::Users} instances
|
675
|
+
# @return [object] A {SupportOps::Zendesk::JobStatuses} instance
|
676
|
+
# @see
|
677
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#create-or-update-many-users
|
678
|
+
# Zendesk API > Users > Create Or Update Many Users
|
679
|
+
# @example
|
680
|
+
# require 'support_ops_zendesk'
|
681
|
+
#
|
682
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
683
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
684
|
+
# config.username = 'jason@example.com'
|
685
|
+
# config.token = 'abc123'
|
686
|
+
# end
|
687
|
+
#
|
688
|
+
# user1 = SupportOps::Zendesk::Users.get!(123)
|
689
|
+
# user1.name = 'Alice2'
|
690
|
+
# user2 = SupportOps::Zendesk::Users.new
|
691
|
+
# user2.name = 'Bob'
|
692
|
+
# user2.email = 'bob@example.com'
|
693
|
+
#
|
694
|
+
# updates = SupportOps::Zendesk::Users.create_or_update_many!([user1, user2])
|
695
|
+
# pp updates.id
|
696
|
+
# # => "82de0b044094f0c67893ac9fe64f1a99"
|
697
|
+
def self.create_or_update_many!(users)
|
698
|
+
raise 'The parameter must be an Array' unless users.is_a? Array
|
699
|
+
raise 'You can only create or update a maximum of 100 users at a time' if users.count > 100
|
700
|
+
raise 'You can only use SupportOps::Zendesk::Tickets instances in the Array' unless users.reject { |t| t.is_a? SupportOps::Zendesk::Users }.count.zero?
|
701
|
+
|
702
|
+
data = { users: users.map { |u| to_hash(u).compact } }.to_json
|
703
|
+
response = client.connection.put('users/create_or_update_many', data)
|
704
|
+
raise "Failed to create or update users => #{body['details']}" if response.status != 200
|
705
|
+
JobStatuses.new(Oj.load(response.body)['job_status'])
|
706
|
+
end
|
707
|
+
|
708
|
+
##
|
709
|
+
# Logout up to 100 users
|
710
|
+
#
|
711
|
+
# @author Jason Colyer
|
712
|
+
# @since 1.0.0
|
713
|
+
# @param user_ids [Array] An array of user IDs
|
714
|
+
# @return [Boolean]
|
715
|
+
# @see
|
716
|
+
# https://developer.zendesk.com/api-reference/ticketing/users/users/#logout-many-users
|
717
|
+
# Zendesk API > Users > Logout many users
|
718
|
+
# @example
|
719
|
+
# require 'support_ops_zendesk'
|
720
|
+
#
|
721
|
+
# SupportOps::Zendesk::Configuration.configure do |config|
|
722
|
+
# config.url = 'https://gitlab.zendesk.com/api/v2'
|
723
|
+
# config.username = 'jason@example.com'
|
724
|
+
# config.token = 'abc123'
|
725
|
+
# end
|
726
|
+
#
|
727
|
+
# logout = SupportOps::Zendesk::Users.logout_many!([123, 456])
|
728
|
+
# pp logout.id
|
729
|
+
# # => true
|
730
|
+
def self.logout_many(user_ids)
|
731
|
+
raise 'The parameter must be an Array' unless user_ids.is_a? Array
|
732
|
+
raise 'You can only logout a maximum of 100 users at a time' if user_ids.count > 100
|
733
|
+
|
734
|
+
response = client.connection.delete("users/logout_many?ids=#{user_ids.join(',')}")
|
735
|
+
raise "Failed to logout users => #{body['details']}" if response.status != 202
|
736
|
+
true
|
737
|
+
end
|
738
|
+
|
739
|
+
private
|
740
|
+
|
741
|
+
##
|
742
|
+
# @private
|
743
|
+
def get_record
|
744
|
+
response = self.client.connection.get("users/#{self.id}")
|
745
|
+
return nil if response.status != 200
|
746
|
+
|
747
|
+
Oj.load(response.body)['user']
|
748
|
+
end
|
749
|
+
|
750
|
+
##
|
751
|
+
# @private
|
752
|
+
def create_record
|
753
|
+
response = self.client.connection.post("users", { user: attributes_for_save }.to_json)
|
754
|
+
body = Oj.load(response.body)
|
755
|
+
raise "Failed to create user => #{body}" if response.status != 201
|
756
|
+
body['user']
|
757
|
+
end
|
758
|
+
|
759
|
+
##
|
760
|
+
# @private
|
761
|
+
def update_record
|
762
|
+
raise "Failed to update user => You didn't change anything in the object" if attributes_for_save.keys == [:id]
|
763
|
+
response = self.client.connection.put("users/#{self.id}", { user: attributes_for_save }.to_json)
|
764
|
+
body = Oj.load(response.body)
|
765
|
+
raise "Failed to update user #{self.id} => #{body}" if response.status != 200
|
766
|
+
body['user']
|
767
|
+
end
|
768
|
+
|
769
|
+
##
|
770
|
+
# @private
|
771
|
+
def delete_record
|
772
|
+
response = self.client.connection.delete("users/#{self.id}")
|
773
|
+
body = Oj.load(response.body)
|
774
|
+
raise "Failed to delete user => #{body}" if response.status != 200
|
775
|
+
true
|
776
|
+
end
|
777
|
+
|
778
|
+
##
|
779
|
+
# @private
|
780
|
+
def organization_record
|
781
|
+
return nil if self.organization_id.nil?
|
782
|
+
|
783
|
+
Organizations.get(self.organization_id)
|
784
|
+
end
|
785
|
+
|
786
|
+
##
|
787
|
+
# @private
|
788
|
+
def create_or_update_record
|
789
|
+
response = self.client.connection.post('users/create_or_update', { user: attributes_for_save }.to_json)
|
790
|
+
body = Oj.load(response.body)
|
791
|
+
raise "Failed to create or update user => #{body}" unless [200, 201].include?(response.status)
|
792
|
+
body['user']
|
793
|
+
end
|
794
|
+
|
795
|
+
##
|
796
|
+
# @private
|
797
|
+
def tickets_record
|
798
|
+
list = []
|
799
|
+
opts = 'page[size]=100'
|
800
|
+
loop do
|
801
|
+
response = self.client.connection.get("users/#{self.id}/tickets/requested?#{opts}")
|
802
|
+
body = Oj.load(response.body)
|
803
|
+
list += body['tickets'].map { |t| Tickets.new(t) }
|
804
|
+
break unless body['meta']['has_more']
|
805
|
+
|
806
|
+
opts = body['links']['next'].split('?').last
|
807
|
+
end
|
808
|
+
list
|
809
|
+
end
|
810
|
+
|
811
|
+
##
|
812
|
+
# @private
|
813
|
+
def ccd_ticket_record
|
814
|
+
list = []
|
815
|
+
opts = 'page[size]=100'
|
816
|
+
loop do
|
817
|
+
response = self.client.connection.get("users/#{self.id}/tickets/ccd?#{opts}")
|
818
|
+
body = Oj.load(response.body)
|
819
|
+
list += body['tickets'].map { |t| Tickets.new(t) }
|
820
|
+
break unless body['meta']['has_more']
|
821
|
+
|
822
|
+
opts = body['links']['next'].split('?').last
|
823
|
+
end
|
824
|
+
list
|
825
|
+
end
|
826
|
+
|
827
|
+
##
|
828
|
+
# @private
|
829
|
+
def assigned_ticket_record
|
830
|
+
list = []
|
831
|
+
page = 1
|
832
|
+
loop do
|
833
|
+
response = self.client.connection.get("users/#{self.id}/tickets/assigned?page=#{page}")
|
834
|
+
body = Oj.load(response.body)
|
835
|
+
list += body['tickets'].map { |t| Tickets.new(t) }
|
836
|
+
break unless body['tickets'].count == 100
|
837
|
+
|
838
|
+
page += 1
|
839
|
+
end
|
840
|
+
list
|
841
|
+
end
|
842
|
+
|
843
|
+
##
|
844
|
+
# @private
|
845
|
+
def organization_memberships_record
|
846
|
+
response = client.connection.get("users/#{self.id}/organization_memberships?page[size]=100")
|
847
|
+
Oj.load(response.body)['organization_memberships'].map { |m| OrganizationMemberships.new(m) }
|
848
|
+
end
|
849
|
+
|
850
|
+
##
|
851
|
+
# @private
|
852
|
+
def group_memberships_record
|
853
|
+
response = client.connection.get("users/#{self.id}/group_memberships?page[size]=100")
|
854
|
+
Oj.load(response.body)['group_memberships'].map { |m| GroupMemberships.new(m) }
|
855
|
+
end
|
856
|
+
|
857
|
+
##
|
858
|
+
# @private
|
859
|
+
def set_password_record
|
860
|
+
response = client.connection.post "users/#{self.id}/password", { password: self.password }.to_json
|
861
|
+
body = Oj.load(response.body)
|
862
|
+
raise "Failed to set user password => #{body['details']}" if response.status != 200
|
863
|
+
true
|
864
|
+
end
|
865
|
+
|
866
|
+
##
|
867
|
+
# @private
|
868
|
+
def organizations_record
|
869
|
+
orgs = []
|
870
|
+
memberships = self.organization_memberships
|
871
|
+
memberships.each do |m|
|
872
|
+
orgs.push(Organizations.get!(m.organization_id))
|
873
|
+
end
|
874
|
+
orgs
|
875
|
+
end
|
876
|
+
|
877
|
+
##
|
878
|
+
# @private
|
879
|
+
def groups_record
|
880
|
+
groups = []
|
881
|
+
memberships = self.group_memberships
|
882
|
+
memberships.each do |m|
|
883
|
+
groups.push(Groups.get!(m.group_id))
|
884
|
+
end
|
885
|
+
groups
|
886
|
+
end
|
887
|
+
end
|
888
|
+
end
|
889
|
+
end
|