Class: Readiness::Zendesk::OAuthClients
- Inherits:
-
Client
- Object
- Client
- Readiness::Zendesk::OAuthClients
show all
- Defined in:
- lib/support_readiness/zendesk/oauth_clients.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Constructor Details
#initialize(object = {}) ⇒ OAuthClients
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 28
def initialize(object = {})
@company = object['company']
@created_at = object['created_at']
@description = object['description']
@id = object['id']
@identifier = object['identifier']
@name = object['name']
@redirect_uri = object['redirect_uri']
@secret = object['secret']
@unique_id = object['unique_id']
@updated_at = object['updated_at']
@user_id = object['user_id']
end
|
Instance Attribute Details
#company ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def company
@company
end
|
#created_at ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def created_at
@created_at
end
|
#description ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def description
@description
end
|
#id ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def id
@id
end
|
#identifier ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def identifier
@identifier
end
|
#name ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def name
@name
end
|
#redirect_uri ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def redirect_uri
@redirect_uri
end
|
#secret ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def secret
@secret
end
|
#unique_id ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def unique_id
@unique_id
end
|
#updated_at ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def updated_at
@updated_at
end
|
#user_id ⇒ Object
17
18
19
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 17
def user_id
@user_id
end
|
Class Method Details
.find(client, cid) ⇒ Object
Locates an OAuth client within Zendesk. This will not exit on error (except Authentication errors)
94
95
96
97
98
99
100
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 94
def self.find(client, cid)
response = client.connection.get("oauth/clients/#{cid}")
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: cid }) unless response.status == 200
return OAuthClients.new(Oj.load(response.body)['client']) if response.status == 200
Oj.load(response.body)
end
|
.find!(client, cid) ⇒ Object
Locates an OAuth client within Zendesk. This will exit on error
121
122
123
124
125
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 121
def self.find!(client, cid)
response = client.connection.get("oauth/clients/#{cid}")
handle_request_error(1, 'Zendesk', response.status, { action: 'Find OAuth client', id: cid }) unless response.status == 200
OAuthClients.new(Oj.load(response.body)['client'])
end
|
.find_by_name(client, name, cache = nil) ⇒ Object
Locates an OAuth client within Zendesk by name. Can utilize a cache for quicker results
146
147
148
149
150
151
152
153
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 146
def self.find_by_name(client, name, cache = nil)
oauth_clients = if cache.nil?
OAuthClients.list(client)
else
cache
end
oauth_clients.detect { |o| o.name == name }
end
|
.list(client) ⇒ Array
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/support_readiness/zendesk/oauth_clients.rb', line 60
def self.list(client)
array = []
opts = 'page[size]=100'
loop do
response = client.connection.get("oauth/clients?#{opts}")
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
body = Oj.load(response.body)
array += body['clients'].map { |c| OAuthClients.new(c) }
break unless body['meta']['has_more']
opts = body['links']['next'].split('?').last
end
array
end
|