zendesk_support_api 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitlab-ci.yml +13 -0
- data/.yardoc/checksums +10 -0
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/README.md +73 -0
- data/lib/zendesk_support_api.rb +10 -0
- data/lib/zendesk_support_api/client.rb +93 -0
- data/lib/zendesk_support_api/deleted_tickets.rb +130 -0
- data/lib/zendesk_support_api/groups.rb +178 -0
- data/lib/zendesk_support_api/jobs.rb +95 -0
- data/lib/zendesk_support_api/organizations.rb +268 -0
- data/lib/zendesk_support_api/search.rb +115 -0
- data/lib/zendesk_support_api/tickets.rb +335 -0
- data/lib/zendesk_support_api/users.rb +317 -0
- data/lib/zendesk_support_api/version.rb +7 -0
- data/zendesk_support_api.gemspec +21 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bcf45ecf6e738bc42b2b2843be87308fd0ac25eec6bdc6f7f05f63dbd2e382a7
|
4
|
+
data.tar.gz: 7649928f9e3b6701d14aa93252dab9c641b71935d7461142f5e1d5130612971d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b6057b660110d703092126a67180c69d989c67078cfc50b0edf6b2543f2efc26b209687fbd162257bc7f9cdd89e2b3174f92d3dadeae1cfc9146704f063ff9d
|
7
|
+
data.tar.gz: 987270880751bad257469be25b4ddf975f622a4a438533d04b89a66bbd093f7db54b291be4b22df02855d39be05b3b47b614622fd11d9ad7c2e23d0c39004d68
|
data/.gitlab-ci.yml
ADDED
data/.yardoc/checksums
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
lib/zendesk_support_api.rb fee89f019b11ec8feb844644e000cec6cad6a695
|
2
|
+
lib/zendesk_support_api/jobs.rb 15e3db660bb16f1a2bc580ce17a9368f81fc9d0e
|
3
|
+
lib/zendesk_support_api/users.rb eb4f8d81f6f9ccf779679f7bfe354c0cc6be8d0c
|
4
|
+
lib/zendesk_support_api/client.rb a9aedf0641e4160b66414e76854e40dd245df1a7
|
5
|
+
lib/zendesk_support_api/groups.rb bcc2a0b1af5bf3552c7838d80f339efbf8636e53
|
6
|
+
lib/zendesk_support_api/search.rb e741717c61809c578afbcd44f9b8e8f18a8c0363
|
7
|
+
lib/zendesk_support_api/tickets.rb 938c32872eeb5459d8d8dae5bb5a9361cb5968d8
|
8
|
+
lib/zendesk_support_api/version.rb 4a0944e207874b5ca81f14ae285d645d6d562928
|
9
|
+
lib/zendesk_support_api/organizations.rb 9e677997416275c0bbccd5aafc1e1f0b7f0bb4c3
|
10
|
+
lib/zendesk_support_api/deleted_tickets.rb 1c58c500e8adf19a910cc02bc7e18650e9751080
|
data/.yardoc/complete
ADDED
File without changes
|
Binary file
|
Binary file
|
data/.yardoc/proxy_types
ADDED
Binary file
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# ZendeskSupportAPI
|
2
|
+
|
3
|
+
|
4
|
+
## Documentation
|
5
|
+
|
6
|
+
Documentation (generated via yard) can be found [here](https://reyloc.gitlab.io/zendesk_support_api/)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
The gem can be installed either via rubygems or bundler:
|
11
|
+
|
12
|
+
### Rubygems
|
13
|
+
|
14
|
+
```bash
|
15
|
+
gem install zendesk_support_api
|
16
|
+
```
|
17
|
+
|
18
|
+
### Bundler
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem "zendesk_support_api"
|
22
|
+
```
|
23
|
+
|
24
|
+
The current requirements for the gem are:
|
25
|
+
|
26
|
+
* 'faraday', '~>1.0.0'
|
27
|
+
* 'oj', '~>3.10.6'
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
Configuration is done through the creation of a `ZendeskSupportAPI::Client`
|
32
|
+
instance:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
require 'zendesk_support_api'
|
36
|
+
|
37
|
+
client = ZendeskSupportAPI::Client.new('user@example.com', '123abc', 'https://zendesk.com/api/v2')
|
38
|
+
```
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
Soon to come
|
43
|
+
|
44
|
+
## Changelog
|
45
|
+
|
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
|
+
* v0.5.0 - Added DeletedTickets functions, Added Tickets functions, Yard synx fixes, updated version number
|
51
|
+
|
52
|
+
## Upcoming changes
|
53
|
+
|
54
|
+
* v0.6.0 - Satisfaction
|
55
|
+
* v0.7.0 - Attachments?
|
56
|
+
* v0.8.0 - Requests
|
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
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday'
|
4
|
+
require 'oj'
|
5
|
+
|
6
|
+
# ZendeskSupportAPI - https://developer.zendesk.com/rest_api/docs/support/introduction
|
7
|
+
module ZendeskSupportAPI
|
8
|
+
require 'zendesk_support_api/client'
|
9
|
+
require 'zendesk_support_api/version'
|
10
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ZendeskSupportAPI
|
4
|
+
# Client class - https://developer.zendesk.com/rest_api/docs/support/introduction#security-and-authentication
|
5
|
+
class Client
|
6
|
+
require 'zendesk_support_api/deleted_tickets'
|
7
|
+
require 'zendesk_support_api/groups'
|
8
|
+
require 'zendesk_support_api/jobs'
|
9
|
+
require 'zendesk_support_api/organizations'
|
10
|
+
require 'zendesk_support_api/search'
|
11
|
+
require 'zendesk_support_api/tickets'
|
12
|
+
require 'zendesk_support_api/users'
|
13
|
+
|
14
|
+
# Create a new instance of Client
|
15
|
+
#
|
16
|
+
# @param user [String] - The API username to use
|
17
|
+
# @param token [String] - The API token to use
|
18
|
+
# @param url [String] - The API URL to use
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# ZendeskSupportAPI::Client.new('user', '123', 'zendesk.com/api')
|
22
|
+
# #=> #<ZendeskSupportAPI::Client:0x00007f88779cb330 @user="user",
|
23
|
+
# #=> @token="123", @url="zendesk.com/api">
|
24
|
+
def initialize(user, token, url)
|
25
|
+
@user = user
|
26
|
+
@token = token
|
27
|
+
@url = url
|
28
|
+
end
|
29
|
+
|
30
|
+
# Make a request to the Zendesk Support API
|
31
|
+
#
|
32
|
+
# @param http_method [Symbol] The HTTP method to utilize
|
33
|
+
# @param endpoint [String] The endpoint to hit
|
34
|
+
# @param params [Hash] Parameters for the request
|
35
|
+
# @return [Hash]
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# client = ZendeskSupportAPI::Client.new('user', '123', 'zendesk.com/api')
|
39
|
+
# client.response(:get, 'users.json')
|
40
|
+
# #=> {users:[{user1},{user2}...{user100}]}
|
41
|
+
|
42
|
+
def request(http_method, endpoint, params = {})
|
43
|
+
response = client.public_send(http_method, endpoint, params)
|
44
|
+
Oj.load(response.body)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Outputs a spinner symbol
|
48
|
+
#
|
49
|
+
# @param string [String] The string to output at the beginning
|
50
|
+
# @param num [Integer] The index of the iteration
|
51
|
+
# @return [String]
|
52
|
+
#
|
53
|
+
# @example
|
54
|
+
# ZendeskSupportAPI::Client.spinner('users', 1) #=> Grabbing users... \
|
55
|
+
# ZendeskSupportAPI::Client.spinner('groups', 3) #=> /
|
56
|
+
|
57
|
+
def spinner(string, num)
|
58
|
+
print "Grabbing #{string}... " if num.to_i == 1
|
59
|
+
symbols = ['-', '\\', '|', '/']
|
60
|
+
print symbols[num.to_i % 4]
|
61
|
+
print "\b"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Handles responses that create jobs
|
65
|
+
#
|
66
|
+
# @param job [Hash] - The output from a request that created a job
|
67
|
+
# @return [Hash]
|
68
|
+
|
69
|
+
def handle_job(job)
|
70
|
+
print 'Checking job'
|
71
|
+
while job['job_status']['status'] != 'completed'
|
72
|
+
print '.'
|
73
|
+
job = ZendeskSupportAPI::Jobs.show(self, job['job_status']['id'])
|
74
|
+
end
|
75
|
+
puts 'completed'
|
76
|
+
job['job_status']['results']
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
# Creates a new Faraday instance
|
82
|
+
#
|
83
|
+
# @return [ZendeskSupportAPI::Client]
|
84
|
+
|
85
|
+
def client
|
86
|
+
@client ||= Faraday.new(@url) do |c|
|
87
|
+
c.request :url_encoded
|
88
|
+
c.adapter Faraday.default_adapter
|
89
|
+
c.basic_auth "#{@user}/token", @token
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ZendeskSupportAPI
|
4
|
+
# Tickets class - https://developer.zendesk.com/rest_api/docs/support/tickets
|
5
|
+
class DeletedTickets
|
6
|
+
# Determines if given string is a valid order function
|
7
|
+
#
|
8
|
+
# @param order [String] The order string to use
|
9
|
+
# @return [Boolean]
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# ZendeskSupportAPI::DeletedTickets.order_valid? 'desc' #=> true
|
13
|
+
# ZendeskSupportAPI::DeletedTickets.order_valid? 'random' #=> false
|
14
|
+
|
15
|
+
def self.order_valid?(order)
|
16
|
+
%w[desc asc].include? order
|
17
|
+
end
|
18
|
+
|
19
|
+
# Prints out the sort_by and order_by string for the url
|
20
|
+
#
|
21
|
+
# @param sort [String] The sort string to use
|
22
|
+
# @param order [String] The order string to use
|
23
|
+
# @return [String]
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
# ZendeskSupportAPI::DeletedTickets.sort_order('id', 'desc')
|
27
|
+
# #=> '&sort_by=id&order_by=desc'
|
28
|
+
|
29
|
+
def self.sort_order(sort, order)
|
30
|
+
"&sort_by=#{sort}&order_by=#{order}"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the string of the next_page for pagination
|
34
|
+
#
|
35
|
+
# @param res [Hash] The Hash containing the response from a request
|
36
|
+
# @return [nil|String]
|
37
|
+
|
38
|
+
def self.next_page(res)
|
39
|
+
(res['next_page'].nil? ? nil : res['next_page'].split('/').last)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Prints out organization_id
|
43
|
+
#
|
44
|
+
# @return [String]
|
45
|
+
#
|
46
|
+
# @example
|
47
|
+
# ZendeskSupportAPI::DeletedTickets.org_id #=> 'organization_id'
|
48
|
+
|
49
|
+
def self.org_id
|
50
|
+
'organization_id'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Selects an object from an array based on a user ID
|
54
|
+
#
|
55
|
+
# @param array [Array] An array of to look in
|
56
|
+
# @param id [Integer] The ID to use
|
57
|
+
# @return [Hash]
|
58
|
+
|
59
|
+
def self.select_obj(array, id)
|
60
|
+
array.select { |a| a['id'] == id }.first
|
61
|
+
end
|
62
|
+
|
63
|
+
# Determines if sort value is valid for delete requests
|
64
|
+
#
|
65
|
+
# @param sort [String] The string to check
|
66
|
+
# @return [Boolean]
|
67
|
+
|
68
|
+
def self.deleted_sort_valid?(sort)
|
69
|
+
%w[id subject deleted_at].includes?(sort)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Lists deleted tickets (first 100)
|
73
|
+
#
|
74
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
75
|
+
# @param sort [String] The sort string to use
|
76
|
+
# @param order [String] The order string to use
|
77
|
+
# @return [Array]
|
78
|
+
|
79
|
+
def self.list_deleted(client, sort = 'id', order = 'asc')
|
80
|
+
return "Invalid sort '#{sort}'" unless delete_sort_valid?(sort)
|
81
|
+
return "Invalid order '#{order}'" unless order_valid?(order)
|
82
|
+
|
83
|
+
url = "deleted_tickets.json?#{sort_order(sort, order)}"
|
84
|
+
client.request(:get, url)['deleted_tickets']
|
85
|
+
end
|
86
|
+
|
87
|
+
# Lists all deleted tickets
|
88
|
+
#
|
89
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
90
|
+
# @return [Array]
|
91
|
+
|
92
|
+
def self.list_all_deleted(client)
|
93
|
+
tickets = []
|
94
|
+
page = 'deleted_tickets.json?page=1'
|
95
|
+
until page.nil?
|
96
|
+
res = client.request(:get, page)
|
97
|
+
client.spinner("tickets (total: #{res['count']})", page.split('=').last)
|
98
|
+
tickets += res['tickets']
|
99
|
+
page = next_page(res)
|
100
|
+
end
|
101
|
+
puts ' ...done'
|
102
|
+
tickets
|
103
|
+
end
|
104
|
+
|
105
|
+
# Restores a deleted ticket
|
106
|
+
#
|
107
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
108
|
+
# @param tid [Integer] The ticket ID to use
|
109
|
+
# @return [nil|String]
|
110
|
+
|
111
|
+
def self.restore(client, tid)
|
112
|
+
res = client.request(:put, "deleted_tickets/#{tid}/restore.json")
|
113
|
+
return "Restore of #{tid} failed: #{res['error']}" if res['error']
|
114
|
+
|
115
|
+
res
|
116
|
+
end
|
117
|
+
|
118
|
+
# Restores several deleted tickets
|
119
|
+
#
|
120
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
121
|
+
# @param tids [Array] Array of ticket IDs to use
|
122
|
+
# @return [ZendeskSupportAPI::Client.handle_job]
|
123
|
+
|
124
|
+
def self.restore_many(client, tids)
|
125
|
+
url = "deleted_tickets/restore_many?ids=#{tids.join(',')}"
|
126
|
+
res = client.request(:put, url)
|
127
|
+
client.handle_job(res)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ZendeskSupportAPI
|
4
|
+
# Groups class - https://developer.zendesk.com/rest_api/docs/support/groups
|
5
|
+
class Groups
|
6
|
+
# Function to return a string that side-loads users
|
7
|
+
#
|
8
|
+
# @return [String]
|
9
|
+
|
10
|
+
def self.user_map(groups, users)
|
11
|
+
groups.map { |g| group_object(g, users) }
|
12
|
+
end
|
13
|
+
|
14
|
+
# Creates a group hash (for mappping the user into the group Hash)
|
15
|
+
#
|
16
|
+
# @param group [Hash] The group details to use
|
17
|
+
# @param users [Array] The Array of users to use
|
18
|
+
# @return [Hash]
|
19
|
+
|
20
|
+
def self.group_object(group, users)
|
21
|
+
group['user'] = users.select { |u| u['id'] == group['user_id'] }
|
22
|
+
group
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns the string of the next_page for pagination
|
26
|
+
#
|
27
|
+
# @param res [Hash] The Hash containing the response from a request
|
28
|
+
# @return [nil|String]
|
29
|
+
#
|
30
|
+
# @example
|
31
|
+
# ZendeskSupportAPI::Users.next_page(response) #=> nil
|
32
|
+
# ZendeskSupportAPI::Users.next_page(response)
|
33
|
+
# #=> "memberships.json?include=users&page=3
|
34
|
+
|
35
|
+
def self.next_page(res)
|
36
|
+
(res['next_page'].nil? ? nil : res['next_page'].split('/').last)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Lists groups (first 100)
|
40
|
+
#
|
41
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
42
|
+
# @return [Array]
|
43
|
+
#
|
44
|
+
# @example
|
45
|
+
# ZendeskSupportAPI::Groups.list(client)
|
46
|
+
# #=> [
|
47
|
+
# #=> {
|
48
|
+
# #=> "name": "DJs",
|
49
|
+
# #=> "created_at": "2009-05-13T00:07:08Z",
|
50
|
+
# #=> "updated_at": "2011-07-22T00:11:12Z",
|
51
|
+
# #=> "id": 211
|
52
|
+
# #=> },
|
53
|
+
# #=> {
|
54
|
+
# #=> "name": "MCs",
|
55
|
+
# #=> "created_at": "2009-08-26T00:07:08Z",
|
56
|
+
# #=> "updated_at": "2010-05-13T00:07:08Z",
|
57
|
+
# #=> "id": 122
|
58
|
+
# #=> }
|
59
|
+
# #=> ]
|
60
|
+
|
61
|
+
def self.list(client)
|
62
|
+
client.request(:get, 'groups.json')['groups']
|
63
|
+
end
|
64
|
+
|
65
|
+
# Shows assignable groups (first 100)
|
66
|
+
#
|
67
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
68
|
+
# @return [Array]
|
69
|
+
#
|
70
|
+
# @example
|
71
|
+
# ZendeskSupportAPI::Groups.assignable(client)
|
72
|
+
# #=> [
|
73
|
+
# #=> {
|
74
|
+
# #=> "name": "DJs",
|
75
|
+
# #=> "created_at": "2009-05-13T00:07:08Z",
|
76
|
+
# #=> "updated_at": "2011-07-22T00:11:12Z",
|
77
|
+
# #=> "id": 211
|
78
|
+
# #=> },
|
79
|
+
# #=> {
|
80
|
+
# #=> "name": "MCs",
|
81
|
+
# #=> "created_at": "2009-08-26T00:07:08Z",
|
82
|
+
# #=> "updated_at": "2010-05-13T00:07:08Z",
|
83
|
+
# #=> "id": 122
|
84
|
+
# #=> }
|
85
|
+
# #=> ]
|
86
|
+
|
87
|
+
def self.assignable(client)
|
88
|
+
client.request(:get, 'assignable.json')['groups']
|
89
|
+
end
|
90
|
+
|
91
|
+
# Shows info about a specific group
|
92
|
+
#
|
93
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
94
|
+
# @param gid [Integer] The Group ID
|
95
|
+
# @return [Hash]
|
96
|
+
#
|
97
|
+
# @example
|
98
|
+
# ZendeskSupportAPI::Groups.show(client, 122)
|
99
|
+
# #=> {
|
100
|
+
# #=> "name": "MCs",
|
101
|
+
# #=> "created_at": "2009-08-26T00:07:08Z",
|
102
|
+
# #=> "updated_at": "2010-05-13T00:07:08Z",
|
103
|
+
# #=> "id": 122
|
104
|
+
# #=> }
|
105
|
+
|
106
|
+
def self.show(client, gid)
|
107
|
+
client.request(:get, "groups/#{gid}.json")['group']
|
108
|
+
end
|
109
|
+
|
110
|
+
# Create a group
|
111
|
+
#
|
112
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
113
|
+
# @param group [Hash] The group details to use
|
114
|
+
# @return [String|Hash]
|
115
|
+
#
|
116
|
+
# @example
|
117
|
+
# group = {
|
118
|
+
# name: 'Test Group'
|
119
|
+
# }
|
120
|
+
# ZendeskSupportAPI::Groups.create(client, group)
|
121
|
+
# #=> {
|
122
|
+
# #=> "name": "Test Group",
|
123
|
+
# #=> "created_at": "2011-04-20T17:49:00Z",
|
124
|
+
# #=> "updated_at": "2011-04-20T17:49:00Z",
|
125
|
+
# #=> "id": 123
|
126
|
+
# #=> }
|
127
|
+
|
128
|
+
def self.create(client, group)
|
129
|
+
res = client.request(:post, 'groups.json', group: group)
|
130
|
+
return "Creation failed: #{res['details']}" if res['error']
|
131
|
+
|
132
|
+
res
|
133
|
+
end
|
134
|
+
|
135
|
+
# Updates a group
|
136
|
+
#
|
137
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
138
|
+
# @param gid [Integer] The group ID to use
|
139
|
+
# @param group [Hash] The group details to use
|
140
|
+
# @return [String|Hash]
|
141
|
+
#
|
142
|
+
# @example
|
143
|
+
# group = {
|
144
|
+
# name: 'Test Group - defunct'
|
145
|
+
# }
|
146
|
+
# ZendeskSupportAPI::Groups.update(client, 123, group)
|
147
|
+
# #=> {
|
148
|
+
# #=> "name": "Test Group - defunct",
|
149
|
+
# #=> "created_at": "2011-04-20T17:49:00Z",
|
150
|
+
# #=> "updated_at": "2011-07-20T17:49:00Z",
|
151
|
+
# #=> "id": 123
|
152
|
+
# #=> }
|
153
|
+
|
154
|
+
def self.update(client, gid, group)
|
155
|
+
res = client.request(:post, "groups/#{gid}.json", group: group)
|
156
|
+
return "Update failed: #{res['details']}" if res['error']
|
157
|
+
|
158
|
+
res
|
159
|
+
end
|
160
|
+
|
161
|
+
# Deletes a group
|
162
|
+
#
|
163
|
+
# @param client [ZendeskSupportAPI::Client] The client instance to use
|
164
|
+
# @param gid [Integer] The group ID to use
|
165
|
+
# @return [String]
|
166
|
+
#
|
167
|
+
# @example
|
168
|
+
# ZendeskSupportAPI::Groups.delete(client, 123)
|
169
|
+
# #=> Group 123 has been deleted
|
170
|
+
|
171
|
+
def self.delete(client, gid)
|
172
|
+
res = client.request(:delete, "groups/#{gid}.json")
|
173
|
+
return "Deletion of #{gid} failed: #{res['error']}" if res['error']
|
174
|
+
|
175
|
+
"Group #{gid} has been deleted"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|