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
24 25 26 27 28 |
# File 'lib/zendesk_support_api/client.rb', line 24 def initialize(user, token, url) @user = user @token = token @url = url end |
Instance Method Details
#handle_job(job) ⇒ Hash
Handles responses that create jobs
69 70 71 72 73 74 75 76 77 |
# File 'lib/zendesk_support_api/client.rb', line 69 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
42 43 44 45 |
# File 'lib/zendesk_support_api/client.rb', line 42 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
57 58 59 60 61 62 |
# File 'lib/zendesk_support_api/client.rb', line 57 def spinner(string, num) print "Grabbing #{string}... " if num.to_i == 1 symbols = ['-', '\\', '|', '/'] print symbols[num.to_i % 4] print "\b" end |