Class: ZendeskSupportAPI::Client
- Inherits:
-
Object
- Object
- ZendeskSupportAPI::Client
- Defined in:
- lib/zendesk_support_api/client.rb
Overview
Instance Method Summary collapse
-
#handle_job(job) ⇒ Hash
Handles responses that create jobs.
-
#initialize(user, token, url) ⇒ Client
constructor
Create a new instance of Client.
-
#request(http_method, endpoint, params = {}) ⇒ Hash
Make a request to the Zendesk Support API.
-
#spinner(string, num) ⇒ String
Outputs a spinner symbol.
Constructor Details
#initialize(user, token, url) ⇒ Client
Create a new instance of Client
20 21 22 23 24 |
# File 'lib/zendesk_support_api/client.rb', line 20 def initialize(user, token, url) @user = user @token = token @url = url end |
Instance Method Details
#handle_job(job) ⇒ Hash
Handles responses that create jobs
65 66 67 68 69 70 71 72 73 |
# File 'lib/zendesk_support_api/client.rb', line 65 def handle_job(job) print 'Checking job' while job['job_status']['status'] != 'completed' print '.' job = ZendeskSupportAPI::Jobs.show(self, job['job_status']['id']) end puts 'completed' job['job_status']['results'] end |
#request(http_method, endpoint, params = {}) ⇒ Hash
Make a request to the Zendesk Support API
38 39 40 41 |
# File 'lib/zendesk_support_api/client.rb', line 38 def request(http_method, endpoint, params = {}) response = client.public_send(http_method, endpoint, params) Oj.load(response.body) end |
#spinner(string, num) ⇒ String
Outputs a spinner symbol
53 54 55 56 57 58 |
# File 'lib/zendesk_support_api/client.rb', line 53 def spinner(string, num) print "Grabbing #{string}... " if num.to_i == 1 symbols = ['-', '\\', '|', '/'] print symbols[num.to_i % 4] print "\b" end |