Class: Readiness::Zendesk::ThemeJobStatuses
- Defined in:
- lib/support_readiness/zendesk/theme_job_statuses.rb
Overview
Defines the class ThemeJobStatuses within the module Readiness::Zendesk.
Instance Attribute Summary collapse
Class Method Summary collapse
-
.find(client, jid) ⇒ Hash
Locates an theme job status within Zendesk.
-
.find!(client, jid) ⇒ Object
Locates a theme job status within Zendesk.
-
.wait_for_completetion(client, job, interval = 5, verbose = true) ⇒ Object
Waits for a job to complete.
Instance Method Summary collapse
-
#initialize(object = {}) ⇒ ThemeJobStatuses
constructor
Creates a new ThemeJobStatuses instance.
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 = {}) ⇒ ThemeJobStatuses
Creates a new Readiness::Zendesk::ThemeJobStatuses instance
24 25 26 27 28 29 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 24 def initialize(object = {}) @data = object['data'] @id = object['id'] @errors = object['errors'] @status = object['status'] end |
Instance Attribute Details
#data ⇒ Object
13 14 15 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 13 def data @data end |
#errors ⇒ Object
13 14 15 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 13 def errors @errors end |
#id ⇒ Object
13 14 15 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 13 def id @id end |
#status ⇒ Object
13 14 15 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 13 def status @status end |
Class Method Details
.find(client, jid) ⇒ Hash
Locates an theme job status within Zendesk. This will not exit on error (except Authentication errors)
50 51 52 53 54 55 56 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 50 def self.find(client, jid) response = client.connection.get("guide/theming/jobs/#{jid}") handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: jid }) unless response.status == 200 return ThemeJobStatuses.new(Oj.load(response.body)) if response.status == 200 Oj.load(response.body) end |
.find!(client, jid) ⇒ Object
Locates a theme job status within Zendesk. This will exit on error
77 78 79 80 81 82 83 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 77 def self.find!(client, jid) response = client.connection.get("guide/theming/jobs/#{jid}") handle_request_error(1, 'Zendesk', response.status, { action: 'Find theme job status', id: jid }) unless response.status == 200 status = ThemeJobStatuses.new(Oj.load(response.body)['job']) status.id = jid if status.id.nil? status 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
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/support_readiness/zendesk/theme_job_statuses.rb', line 124 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 = ThemeJobStatuses.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 |