Class: ZendeskSupportAPI::Groups
- Inherits:
-
Object
- Object
- ZendeskSupportAPI::Groups
- Defined in:
- lib/zendesk_support_api/groups.rb
Overview
Groups class - developer.zendesk.com/rest_api/docs/support/groups
Class Method Summary collapse
-
.assignable(client) ⇒ Array
Shows assignable groups (first 100).
-
.create(client, group) ⇒ String|Hash
Create a group.
-
.delete(client, gid) ⇒ String
Deletes a group.
-
.group_object(group, users) ⇒ Hash
Creates a group hash (for mappping the user into the group Hash).
-
.list(client) ⇒ Array
Lists groups (first 100).
-
.next_page(res) ⇒ nil|String
Returns the string of the next_page for pagination.
-
.show(client, gid) ⇒ Hash
Shows info about a specific group.
-
.update(client, gid, group) ⇒ String|Hash
Updates a group.
-
.user_map(groups, users) ⇒ String
Function to return a string that side-loads users.
Class Method Details
.assignable(client) ⇒ Array
Shows assignable groups (first 100)
87 88 89 |
# File 'lib/zendesk_support_api/groups.rb', line 87 def self.assignable(client) client.request(:get, 'assignable.json')['groups'] end |
.create(client, group) ⇒ String|Hash
Create a group
128 129 130 131 132 133 |
# File 'lib/zendesk_support_api/groups.rb', line 128 def self.create(client, group) res = client.request(:post, 'groups.json', group: group) return "Creation failed: #{res['details']}" if res['error'] res end |
.delete(client, gid) ⇒ String
Deletes a group
171 172 173 174 175 176 |
# File 'lib/zendesk_support_api/groups.rb', line 171 def self.delete(client, gid) res = client.request(:delete, "groups/#{gid}.json") return "Deletion of #{gid} failed: #{res['error']}" if res['error'] "Group #{gid} has been deleted" end |
.group_object(group, users) ⇒ Hash
Creates a group hash (for mappping the user into the group Hash)
20 21 22 23 |
# File 'lib/zendesk_support_api/groups.rb', line 20 def self.group_object(group, users) group['user'] = users.select { |u| u['id'] == group['user_id'] } group end |
.list(client) ⇒ Array
Lists groups (first 100)
61 62 63 |
# File 'lib/zendesk_support_api/groups.rb', line 61 def self.list(client) client.request(:get, 'groups.json')['groups'] end |
.next_page(res) ⇒ nil|String
Returns the string of the next_page for pagination
35 36 37 |
# File 'lib/zendesk_support_api/groups.rb', line 35 def self.next_page(res) (res['next_page'].nil? ? nil : res['next_page'].split('/').last) end |
.show(client, gid) ⇒ Hash
Shows info about a specific group
106 107 108 |
# File 'lib/zendesk_support_api/groups.rb', line 106 def self.show(client, gid) client.request(:get, "groups/#{gid}.json")['group'] end |
.update(client, gid, group) ⇒ String|Hash
Updates a group
154 155 156 157 158 159 |
# File 'lib/zendesk_support_api/groups.rb', line 154 def self.update(client, gid, group) res = client.request(:post, "groups/#{gid}.json", group: group) return "Update failed: #{res['details']}" if res['error'] res end |
.user_map(groups, users) ⇒ String
Function to return a string that side-loads users
10 11 12 |
# File 'lib/zendesk_support_api/groups.rb', line 10 def self.user_map(groups, users) groups.map { |g| group_object(g, users) } end |