Class: ZendeskSupportAPI::Organizations
- Inherits:
-
Object
- Object
- ZendeskSupportAPI::Organizations
- Defined in:
- lib/zendesk_support_api/organizations.rb
Overview
Organizations class - developer.zendesk.com/rest_api/docs/support/organizations
Class Method Summary collapse
-
.bulk_delete(client, ids) ⇒ ZendeskSupportAPI::Client.handle_job
Deletes many organizations.
-
.create(client, org) ⇒ Hash|String
Creates an organization.
-
.create_many(client, orgs) ⇒ ZendeskSupportAPI::Client.handle_job
Creates many organizations.
-
.create_or_update(client, org) ⇒ Hash|String
Creates or updates an organization.
-
.delete(client, oid) ⇒ String
Deletes an organization.
-
.list(client) ⇒ Array
Lists Organizations (first 100).
-
.members(client, oid) ⇒ Array
Get an Organization’s members.
-
.orgs ⇒ String
Prints out organizations.
-
.search_by_external_id(client, eid) ⇒ Array
Searches for orgs by their external_id (first 100).
-
.show(client, oid) ⇒ Hash
Shows info about an organization.
-
.show_many(client, oids) ⇒ Array
Show several organizations.
-
.update(client, oid, org) ⇒ Hash|String
Updates an organization.
-
.update_many(client, orgs) ⇒ ZendeskSupportAPI::Client.handle_job
Updates many organizations.
Class Method Details
.bulk_delete(client, ids) ⇒ ZendeskSupportAPI::Client.handle_job
Deletes many organizations
206 207 208 209 210 |
# File 'lib/zendesk_support_api/organizations.rb', line 206 def self.bulk_delete(client, ids) url = "#{orgs}/destroy_many.json?ids=#{ids.join(',')}" res = client.request(:delete, url) client.handle_job(res) end |
.create(client, org) ⇒ Hash|String
Creates an organization
106 107 108 109 110 111 |
# File 'lib/zendesk_support_api/organizations.rb', line 106 def self.create(client, org) res = client.request(:post, "#{orgs}.json", organization: org) return "Creation failed: #{res['details']}" if res['error'] res['organization'] end |
.create_many(client, orgs) ⇒ ZendeskSupportAPI::Client.handle_job
Creates many organizations
119 120 121 122 123 |
# File 'lib/zendesk_support_api/organizations.rb', line 119 def self.create_many(client, orgs) url = "#{orgs}/create_many.json" res = client.request(:post, url, organizations: orgs) client.handle_job(res) end |
.create_or_update(client, org) ⇒ Hash|String
Creates or updates an organization
143 144 145 146 147 148 149 |
# File 'lib/zendesk_support_api/organizations.rb', line 143 def self.create_or_update(client, org) url = "#{orgs}/create_or_update.json" res = client.request(:post, url, organization: org) return "Create/Update failed: #{res['description']}" if res['error'] res['organization'] end |
.delete(client, oid) ⇒ String
Deletes an organization
193 194 195 196 197 198 |
# File 'lib/zendesk_support_api/organizations.rb', line 193 def self.delete(client, oid) res = client.request(:delete, "#{orgs}/#{oid}.json") return "Deletion of #{oid} failed: #{res['error']}" if res['error'] "Organization #{uid} has been deleted" end |
.list(client) ⇒ Array
Lists Organizations (first 100)
37 38 39 |
# File 'lib/zendesk_support_api/organizations.rb', line 37 def self.list(client) client.request(:get, "#{orgs}.json")[orgs] end |
.members(client, oid) ⇒ Array
Get an Organization’s members
263 264 265 266 |
# File 'lib/zendesk_support_api/organizations.rb', line 263 def self.members(client, oid) url = "#{orgs}/#{oid}/organization_memberships.json?include=users" client.request(:get, url)['users'] end |
.orgs ⇒ String
Prints out organizations
10 11 12 |
# File 'lib/zendesk_support_api/organizations.rb', line 10 def self.orgs 'organizations' end |
.search_by_external_id(client, eid) ⇒ Array
Searches for orgs by their external_id (first 100)
236 237 238 |
# File 'lib/zendesk_support_api/organizations.rb', line 236 def self.search_by_external_id(client, eid) client.request(:get, "#{orgs}/search.json?external_id=#{eid}")[orgs] end |
.show(client, oid) ⇒ Hash
Shows info about an organization
56 57 58 |
# File 'lib/zendesk_support_api/organizations.rb', line 56 def self.show(client, oid) client.request(:get, "#{orgs}/#{oid}.json")['organization'] end |
.show_many(client, oids) ⇒ Array
Show several organizations
83 84 85 86 |
# File 'lib/zendesk_support_api/organizations.rb', line 83 def self.show_many(client, oids) ids = "ids=#{oids.join(',')}" client.request(:get, "#{orgs}/show_many.json?#{ids}")[orgs] end |
.update(client, oid, org) ⇒ Hash|String
Updates an organization
162 163 164 165 166 167 |
# File 'lib/zendesk_support_api/organizations.rb', line 162 def self.update(client, oid, org) res = client.request(:post, "#{orgs}/#{oid}.json", organization: org) return "Update of #{uid} failed: #{res['error']}" if res['error'] res['organization'] end |
.update_many(client, orgs) ⇒ ZendeskSupportAPI::Client.handle_job
Updates many organizations
175 176 177 178 179 |
# File 'lib/zendesk_support_api/organizations.rb', line 175 def self.update_many(client, orgs) url = "#{orgs}/update_many.json" res = client.request(:put, url, organizations: orgs) client.handle_job(res) end |