zendesk_support_api 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4914120c422052e97716f808fe888ec810bee8977f4fcd9d275cc6b1705c4ca0
4
- data.tar.gz: 4cded8d95430a510322e44f0310f18ce9c01a5776a4dac4ab476eaee487fbecf
3
+ metadata.gz: c78cf01ac68e20c32f2e1d3ac3d47a9b4574012200718e33d06f3f92d75d9a68
4
+ data.tar.gz: f066e3f7c5fbfd5008a8a2d8b3fff4ba416c8d9e5a3373a7f8b8d586126c5fb9
5
5
  SHA512:
6
- metadata.gz: 0065aa4ea3865fd6169a1650ed126d1748e290190dd5a5755c72fda7e37f6f365599e1f73fe178c07d68aa6ed2fed202cad6f6768fec91567c86dd2dafc2817a
7
- data.tar.gz: 89c5da1d7258032fe2c56369a7d31e69131137012ada8573618b61693be110ac8a5e0b5bb196afa4cdca0ad1a1e20c21b7ddaa4c51da58f4ddda62e1aef7f162
6
+ metadata.gz: f55d3a02c043022f70047bfe080d1227a9f1ea4dd9355f6e670ddb33187fd7bd6b79fbf207a99c671616ab0f370e56d4f9b8a510b966d50947a7c6e9ccf5c46e
7
+ data.tar.gz: 4eeb5abd58621fc511552e686859e68e95cbec5b8cca8363b93c1b9a57cdb2e1f01860b21158351a5290e44b3c929307b231bfd3f65917d7e8fc3a6451211492
@@ -1,7 +1,8 @@
1
1
  lib/zendesk_support_api.rb fee89f019b11ec8feb844644e000cec6cad6a695
2
2
  lib/zendesk_support_api/jobs.rb 15e3db660bb16f1a2bc580ce17a9368f81fc9d0e
3
3
  lib/zendesk_support_api/users.rb eb4f8d81f6f9ccf779679f7bfe354c0cc6be8d0c
4
- lib/zendesk_support_api/client.rb f73dc3643644c6bf5f1a82593971b78a47b384fc
4
+ lib/zendesk_support_api/client.rb 19147ca149a521a068e8a8818ad9b26091df0542
5
5
  lib/zendesk_support_api/groups.rb bcc2a0b1af5bf3552c7838d80f339efbf8636e53
6
6
  lib/zendesk_support_api/search.rb e741717c61809c578afbcd44f9b8e8f18a8c0363
7
- lib/zendesk_support_api/version.rb e6591152418f6cbe5b2a2ff5d68799f735ed597d
7
+ lib/zendesk_support_api/version.rb b95930e804ad2f9d4718efe8b3c740f79304913f
8
+ lib/zendesk_support_api/organizations.rb 684c74525f26697a7a6e5fca921a1a937b0d20c8
Binary file
Binary file
data/README.md CHANGED
@@ -43,13 +43,31 @@ Soon to come
43
43
 
44
44
  ## Changelog
45
45
 
46
- * v0.1.0
47
- * Initial creation of gem
48
- * v0.2.0
49
- * Added Search functions
50
- * Fixed some yard syntax/formatting
51
- * Changed version number
52
- * v0.3.0
53
- * Changed version number
54
- * Added Group functions
55
- * Added User.groups function
46
+ * v0.1.0 - Initial creation of gem
47
+ * v0.2.0 - Added Search functions, Fixed some yard syntax/formatting, Changed version number
48
+ * v0.3.0 - Changed version number, Added Group functions, Added User.groups function
49
+ * v0.4.0 - Added Organization functions, Changed version number
50
+
51
+ ## Upcoming changes
52
+
53
+ * v0.5.0 - Requests
54
+ * v0.6.0 - Tickets
55
+ * v0.7.0 - Attachments?
56
+ * v0.8.0 - Satisfaction
57
+ * v0.9.0 - Sessions
58
+ * v0.10.0 - Tags
59
+ * v0.11.0 - Views
60
+ * v0.12.0 - Triggers
61
+ * v0.13.0 - Automations
62
+ * v0.14.0 - SLA
63
+ * v0.15.0 - Targets
64
+ * v0.16.0 - Macros
65
+ * v0.17.0 - Brands
66
+ * v0.18.0 - Locales
67
+ * v0.19.0 - Schedules
68
+ * v0.20.0 - Ticket Forms
69
+ * v0.21.0 - Ticket Fields
70
+ * v0.22.0 - User Fields
71
+ * v0.23.0 - Organization Fields
72
+ * v0.24.0 - Account Settings
73
+ * v1.0.0 - Usage details, any polishing needed
@@ -5,6 +5,7 @@ module ZendeskSupportAPI
5
5
  class Client
6
6
  require 'zendesk_support_api/groups'
7
7
  require 'zendesk_support_api/jobs'
8
+ require 'zendesk_support_api/organizations'
8
9
  require 'zendesk_support_api/search'
9
10
  require 'zendesk_support_api/users'
10
11
 
@@ -0,0 +1,268 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ZendeskSupportAPI
4
+ # Organizations class - https://developer.zendesk.com/rest_api/docs/support/organizations
5
+ class Organizations
6
+ # Prints out organizations
7
+ #
8
+ # @return [String]
9
+
10
+ def self.orgs
11
+ 'organizations'
12
+ end
13
+
14
+ # Lists Organizations (first 100)
15
+ #
16
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
17
+ # @return [Array]
18
+ #
19
+ # @example
20
+ # ZendeskSupportAPI::Organizations.list(client)
21
+ # #=> [
22
+ # #=> {
23
+ # #=> "url": "https://zendesk.com/api/v2/organizations/1.json",
24
+ # #=> "id": 1,
25
+ # #=> "name": "One Organization",
26
+ # #=> ...
27
+ # #=> },
28
+ # #=> ...
29
+ # #=> {
30
+ # #=> "url": "https://zendesk.com/api/v2/organizations/100.json",
31
+ # #=> "id: 100,
32
+ # #=> "name": "Other Organization",
33
+ # #=> ...
34
+ # #=> }
35
+ # #=> ]
36
+
37
+ def self.list(client)
38
+ client.request(:get, "#{orgs}.json")[orgs]
39
+ end
40
+
41
+ # Shows info about an organization
42
+ #
43
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
44
+ # @param oid [Integer] The Organization ID to use
45
+ # @return [Hash]
46
+ #
47
+ # @example
48
+ # ZendeskSupportAPI::Organizations.show(client, 123)
49
+ # #=> {
50
+ # #=> "url": "https://zendesk.com/api/v2/organizations/1.json",
51
+ # #=> "id": 1,
52
+ # #=> "name": "One Organization",
53
+ # #=> ...
54
+ # #=> }
55
+
56
+ def self.show(client, oid)
57
+ client.request(:get, "#{orgs}/#{oid}.json")['organization']
58
+ end
59
+
60
+ # Show several organizations
61
+ #
62
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
63
+ # @param oids [Array] An Array of Organization IDs to show
64
+ # @return [Array]
65
+ #
66
+ # @example
67
+ # ZendeskSupportAPI::Organizations.show(client, [1,2])
68
+ # #=> [
69
+ # #=> {
70
+ # #=> "url": "https://zendesk.com/api/v2/organizations/1.json",
71
+ # #=> "id": 1,
72
+ # #=> "name": "One Organization",
73
+ # #=> ...
74
+ # #=> },
75
+ # #=> {
76
+ # #=> "url": "https://zendesk.com/api/v2/organizations/2.json",
77
+ # #=> "id": 2,
78
+ # #=> "name": "Two Organization",
79
+ # #=> ...
80
+ # #=> }
81
+ # #=> ]
82
+
83
+ def self.show_many(client, oids)
84
+ ids = "ids=#{oids.join(',')}"
85
+ client.request(:get, "#{orgs}/show_many.json?#{ids}")[orgs]
86
+ end
87
+
88
+ # Creates an organization
89
+ #
90
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
91
+ # @param org [Hash] The organization info to use
92
+ # @return [Hash|String]
93
+ #
94
+ # @example
95
+ # org = {
96
+ # name: 'Test Organization',
97
+ # }
98
+ # ZendeskSupportAPI::Organizations.create(client, org)
99
+ # #=> {
100
+ # #=> "url": "",
101
+ # #=> "id": 123,
102
+ # #=> "name": "Test Organization",
103
+ # #=> ...
104
+ # #=> }
105
+
106
+ def self.create(client, org)
107
+ res = client.request(:post, "#{orgs}.json", organization: org)
108
+ return "Creation failed: #{res['details']}" if res['error']
109
+
110
+ res['organization']
111
+ end
112
+
113
+ # Creates many organizations
114
+ #
115
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
116
+ # @param users [Array] The organizations to create
117
+ # @return [ZendeskSupportAPI::Client.handle_job]
118
+
119
+ def self.create_many(client, orgs)
120
+ url = "#{orgs}/create_many.json"
121
+ res = client.request(:post, url, organizations: orgs)
122
+ client.handle_job(res)
123
+ end
124
+
125
+ # Creates or updates an organization
126
+ #
127
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
128
+ # @param org [Hash] The organization info to use
129
+ # @return [Hash|String]
130
+ #
131
+ # @example
132
+ # org = {
133
+ # name: 'Test Organization',
134
+ # }
135
+ # ZendeskSupportAPI::Organizations.create_or_update(client, org)
136
+ # #=> {
137
+ # #=> "url": "",
138
+ # #=> "id": 123,
139
+ # #=> "name": "Test Organization",
140
+ # #=> ...
141
+ # #=> }
142
+
143
+ def self.create_or_update(client, org)
144
+ url = "#{orgs}/create_or_update.json"
145
+ res = client.request(:post, url, organization: org)
146
+ return "Create/Update failed: #{res['description']}" if res['error']
147
+
148
+ res['organization']
149
+ end
150
+
151
+ # Updates an organization
152
+ #
153
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
154
+ # @param oid [Integer] The Organization ID to use
155
+ # @param org [Hash] The organization info to use
156
+ # @return [Hash|String]
157
+ #
158
+ # @example
159
+ # ZendeskSupportAPI::Organizations.update(client, 123, org)
160
+ # #=> {organization}
161
+
162
+ def self.update(client, oid, org)
163
+ res = client.request(:post, "#{orgs}/#{oid}.json", organization: org)
164
+ return "Update of #{uid} failed: #{res['error']}" if res['error']
165
+
166
+ res['organization']
167
+ end
168
+
169
+ # Updates many organizations
170
+ #
171
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
172
+ # @param orgs [Array] The organizations to update
173
+ # @return [ZendeskSupportAPI::Client.handle_job]
174
+
175
+ def self.update_many(client, orgs)
176
+ url = "#{orgs}/update_many.json"
177
+ res = client.request(:put, url, organizations: orgs)
178
+ client.handle_job(res)
179
+ end
180
+
181
+ # Deletes an organization
182
+ #
183
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
184
+ # @param oid [Integer] The Organization ID to delete
185
+ # @return [String]
186
+ #
187
+ # @example
188
+ # ZendeskSupportAPI::Organizations.delete(client, 123)
189
+ # #=> Organization 123 has been deleted
190
+ # ZendeskSupportAPI::Organizations.delete(client, 123)
191
+ # #=> "Deletion of 123 failed: RecordNotFound"
192
+
193
+ def self.delete(client, oid)
194
+ res = client.request(:delete, "#{orgs}/#{oid}.json")
195
+ return "Deletion of #{oid} failed: #{res['error']}" if res['error']
196
+
197
+ "Organization #{uid} has been deleted"
198
+ end
199
+
200
+ # Deletes many organizations
201
+ #
202
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
203
+ # @param ids [Array] The array of Organization IDs to delete
204
+ # @return [ZendeskSupportAPI::Client.handle_job
205
+
206
+ def self.bulk_delete(client, ids)
207
+ url = "#{orgs}/destroy_many.json?ids=#{ids.join(',')}"
208
+ res = client.request(:delete, url)
209
+ client.handle_job(res)
210
+ end
211
+
212
+ # Searches for orgs by their external_id (first 100)
213
+ #
214
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
215
+ # @param eid [String] The External ID to use
216
+ # @return [Array]
217
+ #
218
+ # @example
219
+ # ZendeskSupportAPI::Organizations.search_by_external_id(client, 'abc123')
220
+ # #=> [
221
+ # #=> {
222
+ # #=> "url": "https://zendesk.com/api/v2/organizations/1.json",
223
+ # #=> "id": 1,
224
+ # #=> "name": "One Organization",
225
+ # #=> ...
226
+ # #=> },
227
+ # #=> ...
228
+ # #=> {
229
+ # #=> "url": "https://zendesk.com/api/v2/organizations/100.json",
230
+ # #=> "id: 100,
231
+ # #=> "name": "Other Organization",
232
+ # #=> ...
233
+ # #=> }
234
+ # #=> ]
235
+
236
+ def self.search_by_external_id(client, eid)
237
+ client.request(:get, "#{orgs}/search.json?external_id=#{eid}")[orgs]
238
+ end
239
+
240
+ # Get an Organization's members
241
+ # @param client [ZendeskSupportAPI::Client] The client instance to use
242
+ # @param oid [Integer] The Organization ID to use
243
+ # @return [Array]
244
+ #
245
+ # @example
246
+ # ZendeskSupportAPI::Organizations.members(client, 123)
247
+ # #=> [
248
+ # #=> {
249
+ # #=> "id": 1,
250
+ # #=> "name": "Albert",
251
+ # #=> "email": "albert@example.com",
252
+ # #=> ...
253
+ # #=> },
254
+ # #=> ...
255
+ # #=> {
256
+ # #=> "id": 22,
257
+ # #=> "name": "Victor",
258
+ # #=> "email": "victor@example.com",
259
+ # #=> ...
260
+ # #=> }
261
+ # #=> ]
262
+
263
+ def self.members(client, oid)
264
+ url = "#{orgs}/#{oid}/organization_memberships.json?include=users"
265
+ client.request(:get, url)['users']
266
+ end
267
+ end
268
+ end
@@ -3,5 +3,5 @@
3
3
  module ZendeskSupportAPI
4
4
  # Outputs the gem version
5
5
 
6
- VERSION = '0.3.0'
6
+ VERSION = '0.4.0'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_support_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Colyer
@@ -55,6 +55,7 @@ files:
55
55
  - lib/zendesk_support_api/client.rb
56
56
  - lib/zendesk_support_api/groups.rb
57
57
  - lib/zendesk_support_api/jobs.rb
58
+ - lib/zendesk_support_api/organizations.rb
58
59
  - lib/zendesk_support_api/search.rb
59
60
  - lib/zendesk_support_api/users.rb
60
61
  - lib/zendesk_support_api/version.rb