Class: ZendeskAPI::AgentAvailability
- Inherits:
-
DataResource
- Object
- Data
- DataResource
- ZendeskAPI::AgentAvailability
- Defined in:
- lib/zendesk_api/resources.rb
Overview
client.agent_availabilities.fetch client.agent_availabilities.find 20401208368 both return consistently - ZendeskAPI::AgentAvailability
Instance Attribute Summary
Attributes inherited from DataResource
Attributes inherited from Data
#association, #attributes, #errors, #response
Class Method Summary collapse
- .find(client, id) ⇒ Object
- .model_key ⇒ Object
-
.search(client, args_hash) ⇒ Object
Examples: ZendeskAPI::AgentAvailability.search(client, { channel_status: ‘support:online’ }) ZendeskAPI::AgentAvailability.search(client, { agent_status_id: 1 }) Just pass a hash that includes the key and value you want to search for, it gets turned into a query string on the format of filter=value Returns a collection of AgentAvailability objects.
Instance Method Summary collapse
- #channels ⇒ Object
-
#initialize(client, attributes = {}) ⇒ AgentAvailability
constructor
A new instance of AgentAvailability.
Methods inherited from DataResource
Methods included from Verbs
Methods inherited from Data
#==, #attributes_for_save, #id, inherited, #loaded_associations, #method_missing, namespace, new_from_response, #new_record?, #path, resource_name, resource_path, #respond_to_missing?, singular_resource_name, subclasses, #to_json, #to_s
Methods included from Associations
Constructor Details
#initialize(client, attributes = {}) ⇒ AgentAvailability
Returns a new instance of AgentAvailability.
37 38 39 40 |
# File 'lib/zendesk_api/resources.rb', line 37 def initialize(client, attributes = {}) nested_attributes = attributes.delete('attributes') super(client, attributes.merge(nested_attributes)) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ZendeskAPI::Data
Class Method Details
.find(client, id) ⇒ Object
42 43 44 45 |
# File 'lib/zendesk_api/resources.rb', line 42 def self.find(client, id) attributes = client.connection.get("#{resource_path}/#{id}").body.fetch(model_key, {}) new(client, attributes) end |
.model_key ⇒ Object
33 34 35 |
# File 'lib/zendesk_api/resources.rb', line 33 def self.model_key "data" end |
.search(client, args_hash) ⇒ Object
Examples:
ZendeskAPI::AgentAvailability.search(client, { channel_status: 'support:online' })
ZendeskAPI::AgentAvailability.search(client, { agent_status_id: 1 })
Just pass a hash that includes the key and value you want to search for, it gets turned into a query string
on the format of filter[key]=value
Returns a collection of AgentAvailability objects
53 54 55 56 57 58 |
# File 'lib/zendesk_api/resources.rb', line 53 def self.search(client, args_hash) query_string = args_hash.map { |k, v| "filter[#{k}]=#{v}" }.join("&") client.connection.get("#{resource_path}?#{query_string}").body.fetch(model_key, []).map do |attributes| new(client, attributes) end end |
Instance Method Details
#channels ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/zendesk_api/resources.rb', line 60 def channels @channels ||= begin channel_attributes_array = @client.connection.get(attributes['links']['self']).body.fetch('included') channel_attributes_array.map do |channel_attributes| nested_attributes = channel_attributes.delete('attributes') Channel.new(@client, channel_attributes.merge(nested_attributes)) end end end |