From 5d3ac7b9b771a876697c5a3e0b4d2613c8d42aa8 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 30 May 2019 15:38:09 +1000 Subject: [PATCH] Added config options for sending user email/sending operators email when opening new ticket. Added internal switch for new tickets --- lib/supportpal.rb | 17 +++++++++++------ lib/supportpal/config.rb | 2 ++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/supportpal.rb b/lib/supportpal.rb index 6aca36d..c7fea3a 100644 --- a/lib/supportpal.rb +++ b/lib/supportpal.rb @@ -10,7 +10,7 @@ class Error < StandardError; end class Session include HTTParty # Uncomment to debug output - #debug_output $stdout + debug_output $stdout def initialize(options) # Make a class variable @@ -46,12 +46,17 @@ def open_new_ticket(subject, message, options = {}) params['text'] = message params['user'] = @config[:ticket_user_id] - params['user'] = options['operator_id'] if options['operator_id'] - params['user'] = options['user_id'] if options['user_id'] + params['user'] = options[:operator_id] if options[:operator_id] + params['user'] = options[:user_id] if options[:user_id] - params['department'] = (options['department']) ? options['department'] : @config[:ticket_department_id] - params['status'] = (options['status']) ? options['status'] : @config[:ticket_status] - params['priority'] = (options['priority']) ? options['priority'] : @config[:ticket_priority] + params['department'] = (options[:department]) ? options[:department] : @config[:ticket_department_id] + params['status'] = (options[:status]) ? options[:status] : @config[:ticket_status] + params['priority'] = (options[:priority]) ? options[:priority] : @config[:ticket_priority] + + params['internal'] = options[:internal] if options[:internal] + + params['send_user_email'] = (options[:send_user_email]) ? options[:send_user_email] : @config[:ticket_send_user_email] + params['send_operators_email'] = (options[:send_operators_email]) ? options[:send_operators_email] : @config[:ticket_send_operators_email] @http_options.merge!({ body: params }) res = self.class.post('/api/ticket/ticket', @http_options) diff --git a/lib/supportpal/config.rb b/lib/supportpal/config.rb index 010fb12..ed31da8 100644 --- a/lib/supportpal/config.rb +++ b/lib/supportpal/config.rb @@ -8,6 +8,8 @@ def default_config :ticket_priority => 1, # Low :ticket_user_id => nil, # Operator or user :ticket_department_id => nil, + :ticket_send_user_email => false, # Send an email to the user who opens the ticket when ticket opens + :ticket_send_operators_email => false, # Send an email to all operators when ticket opens :auth_token => nil, # SupportPal token } end