Class: Readiness::Zendesk::Targets
- Defined in:
- lib/support_readiness/zendesk/targets.rb
Overview
Find methods
Create method
Update method
Delete method
Defines the class Targets within the module Readiness::Zendesk.
Instance Attribute Summary collapse
Class Method Summary collapse
-
.find_by_name(client, name, cache = nil) ⇒ Object
Locates a target within Zendesk by name.
-
.list(client) ⇒ Array
Lists targets.
Instance Method Summary collapse
-
#initialize(object = {}) ⇒ Targets
constructor
Creates a new Targets 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 = {}) ⇒ Targets
Creates a new Readiness::Zendesk::Targets instance
28 29 30 31 32 33 34 35 |
# File 'lib/support_readiness/zendesk/targets.rb', line 28 def initialize(object = {}) @active = object['active'] @email = object['email'] @id = object['id'] @subject = object['subject'] @title = object['title'] @type = object['type'] end |
Instance Attribute Details
#active ⇒ Object
17 18 19 |
# File 'lib/support_readiness/zendesk/targets.rb', line 17 def active @active end |
#email ⇒ Object
17 18 19 |
# File 'lib/support_readiness/zendesk/targets.rb', line 17 def email @email end |
#id ⇒ Object
17 18 19 |
# File 'lib/support_readiness/zendesk/targets.rb', line 17 def id @id end |
#subject ⇒ Object
17 18 19 |
# File 'lib/support_readiness/zendesk/targets.rb', line 17 def subject @subject end |
#title ⇒ Object
17 18 19 |
# File 'lib/support_readiness/zendesk/targets.rb', line 17 def title @title end |
#type ⇒ Object
17 18 19 |
# File 'lib/support_readiness/zendesk/targets.rb', line 17 def type @type end |
Class Method Details
.find_by_name(client, name, cache = nil) ⇒ Object
Locates a target within Zendesk by name. Can utilize a cacheh for quicker results
85 86 87 88 89 90 91 92 |
# File 'lib/support_readiness/zendesk/targets.rb', line 85 def self.find_by_name(client, name, cache = nil) list = if cache.nil? Targets.list(client) else cache end list.detect { |c| c.title == name } end |
.list(client) ⇒ Array
Lists targets
55 56 57 58 59 60 |
# File 'lib/support_readiness/zendesk/targets.rb', line 55 def self.list(client) response = client.connection.get 'targets' handle_request_error(0, 'Zendesk', response.status) unless response.status == 200 body = Oj.load(response.body) body['targets'].map { |t| Targets.new(t)} end |