Class: Readiness::Zendesk::TicketUserTypes
- Defined in:
- lib/support_readiness/zendesk/ticket_user_types.rb
Overview
Defines the class TicketUserTypes within the module Readiness::Zendesk.
Instance Attribute Summary collapse
Class Method Summary collapse
-
.find_by_name(client, name) ⇒ Object
Locates a ticket user type within Zendesk by name.
-
.list ⇒ Array
Lists ticket user types.
Instance Method Summary collapse
-
#initialize(object = {}) ⇒ TicketUserTypes
constructor
Creates a new TicketUserTypes 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 = {}) ⇒ TicketUserTypes
Creates a new Readiness::Zendesk::TicketUserTypes instance
24 25 26 27 |
# File 'lib/support_readiness/zendesk/ticket_user_types.rb', line 24 def initialize(object = {}) @id = object['id'] @name = object['name'] end |
Instance Attribute Details
#id ⇒ Object
13 14 15 |
# File 'lib/support_readiness/zendesk/ticket_user_types.rb', line 13 def id @id end |
#name ⇒ Object
13 14 15 |
# File 'lib/support_readiness/zendesk/ticket_user_types.rb', line 13 def name @name end |
Class Method Details
.find_by_name(client, name) ⇒ Object
Locates a ticket user type within Zendesk by name. If not found, will assume a user email (and will exit on error)
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/support_readiness/zendesk/ticket_user_types.rb', line 68 def self.find_by_name(client, name) type = TicketUserTypes.list.detect { |r| r.name == name } if type.nil? search = Search.users(client, "email:#{name}") if search.count == 1 type = TicketUserTypes.new({ 'id' => search.first.id, 'name' => search.first.email }) end end type end |
.list ⇒ Array
Lists ticket user types
41 42 43 44 45 46 |
# File 'lib/support_readiness/zendesk/ticket_user_types.rb', line 41 def self.list [ { 'id' => 'agent', 'name' => 'Agent' }, { 'id' => 'end_user', 'name' => 'End User' } ].map { |r| TicketUserTypes.new(r) } end |