Class: Readiness::Zendesk::AppJobStatuses
- Inherits:
-
Client
- Object
- Client
- Readiness::Zendesk::AppJobStatuses
show all
- Defined in:
- lib/support_readiness/zendesk/app_job_statuses.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
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 24
def initialize(object = {})
@app_id = object['app_id']
@app_url = object['app_url']
@id = object['id']
@message = object['message']
@progress = object['progress']
@retry_in = object['retry_in']
@status = object['status']
@total = object['total']
end
|
Instance Attribute Details
#app_id ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def app_id
@app_id
end
|
#app_url ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def app_url
@app_url
end
|
#id ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def id
@id
end
|
#message ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def message
@message
end
|
#progress ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def progress
@progress
end
|
#retry_in ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def retry_in
@retry_in
end
|
#status ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def status
@status
end
|
#total ⇒ Object
13
14
15
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 13
def total
@total
end
|
Class Method Details
.find(client, jid) ⇒ Hash
Locates an app job status within Zendesk. This will not exit on error (except Authentication errors)
54
55
56
57
58
59
60
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 54
def self.find(client, jid)
response = client.connection.get("apps/job_statuses/#{jid}")
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: jid }) unless response.status == 200
return AppJobStatuses.new(Oj.load(response.body)) if response.status == 200
Oj.load(response.body)
end
|
.find!(client, jid) ⇒ Object
Locates an app job status within Zendesk. This will exit on error
81
82
83
84
85
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 81
def self.find!(client, jid)
response = client.connection.get("apps/job_statuses/#{jid}")
handle_request_error(1, 'Zendesk', response.status, { action: 'Find app job status', id: jid }) unless response.status == 200
AppJobStatuses.new(Oj.load(response.body))
end
|
.wait_for_completetion(client, job, interval = 5, verbose = true) ⇒ Object
Waits for a job to complete. Be mindful of API limits when setting the wait interval
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/support_readiness/zendesk/app_job_statuses.rb', line 126
def self.wait_for_completetion(client, job, interval = 5, verbose = true)
loop do
puts "Waiting #{interval} seconds before checking #{job.id}" if verbose
sleep interval
print "Rechecking status of #{job.id}..." if verbose
job = AppJobStatuses.find!(client, job.id)
puts "status is #{job.status}" if verbose
break if %w[failed completed].include? job.status
end
puts "Job is finished with status of #{job.status}" if verbose
job
end
|