Sha256: af6b900e22425384ee1f621967c6412be09b060976064f78d5dd71af3095ad32
Contents?: true
Size: 1.58 KB
Versions: 2
Compression:
Stored size: 1.58 KB
Contents
require 'intercom/service/base_service' require 'intercom/api_operations/find_all' require 'intercom/api_operations/find' require 'intercom/api_operations/load' require 'intercom/api_operations/save' require 'intercom/utils' module Intercom module Service class Conversation < BaseService include ApiOperations::FindAll include ApiOperations::List include ApiOperations::Find include ApiOperations::Load include ApiOperations::Save def collection_class Intercom::Conversation end def mark_read(id) @client.put("/conversations/#{id}", read: true) end def reply(reply_data) id = reply_data.delete(:id) collection_name = Utils.resource_class_to_collection_name(collection_class) response = @client.post("/#{collection_name}/#{id}/reply", reply_data.merge(:conversation_id => id)) collection_class.new.from_response(response) end def open(reply_data) reply reply_data.merge(message_type: 'open', type: 'admin') end def close(reply_data) reply reply_data.merge(message_type: 'close', type: 'admin') end def snooze(reply_data) snoozed_until = reply_data.fetch(:snoozed_until) { fail 'snoozed_until field is required' } reply reply_data.merge(message_type: 'snoozed', type: 'admin') end def assign(reply_data) assignee_id = reply_data.fetch(:assignee_id) { fail 'assignee_id is required' } reply reply_data.merge(message_type: 'assignment', assignee_id: assignee_id, type: 'admin') end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
intercom-3.7.0 | lib/intercom/service/conversation.rb |
intercom-3.6.2 | lib/intercom/service/conversation.rb |