Module: Assistly::Client::Interaction
- Included in:
- Assistly::Client
- Defined in:
- lib/assistly/client/interaction.rb
Overview
Defines methods related to interactions
Instance Method Summary collapse
-
#create_inbound_interaction(*args) ⇒ Array
Creates an interaction from a customer.
- #create_interaction(*args) ⇒ Object
-
#create_outbound_interaction(to, subject, body, *args) ⇒ Object
Create an interaction from an agent.
-
#interactions(*args) ⇒ Object
Returns extended information of up to 100 interactions.
Instance Method Details
#create_inbound_interaction(*args) ⇒ Array
Creates an interaction from a customer
44 45 46 47 48 49 50 51 52 |
# File 'lib/assistly/client/interaction.rb', line 44 def create_inbound_interaction(*args) = args.last.is_a?(Hash) ? args.pop : {} response = post('interactions', ) if response['success'] return response['results'] else return response end end |
#create_interaction(*args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/assistly/client/interaction.rb', line 21 def create_interaction(*args) = args.last.is_a?(Hash) ? args.pop : {} if [:direction].to_s == "outbound" .delete(:direction) to = .delete(:customer_email) subject = .delete(:interaction_subject) body = .delete(:interaction_body) create_outbound_interaction(to, subject, body, ) else create_inbound_interaction() end end |
#create_outbound_interaction(to, subject, body, *args) ⇒ Object
Create an interaction from an agent
Assistly's API doesn't support creating a new case/interaction initiated by an agent so we'll use send an email to the customer directly that is BCC'd to the support email address which will create the ticket
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/assistly/client/interaction.rb', line 62 def create_outbound_interaction(to, subject, body, *args) raise Assistly::SupportEmailNotSet if support_email.blank? = args.last.is_a?(Hash) ? args.pop : {} .merge!(:to => to, :subject => subject, :body => body, :from => support_email, :bcc => support_email) headers = { "x-assistly-customer-email" => to, "x-assistly-interaction-direction" => "out", "x-assistly-case-status" => [:status]||"open"} headers.merge!([:headers]) if [:headers] .merge!(:headers => headers) Pony.mail() end |
#interactions(*args) ⇒ Object
Returns extended information of up to 100 interactions
@option options [Boolean, String, Integer] @example Return extended information for 12345 Assistly.interactions(:since_id => 12345) Assistly.interactions(:since_id => 12345, :count => 5)
15 16 17 18 19 |
# File 'lib/assistly/client/interaction.rb', line 15 def interactions(*args) = args.last.is_a?(Hash) ? args.pop : {} response = get("interactions",) response end |