Permalink
Browse files

Merge remote-tracking branch 'origin/master' into mark_answered

  • Loading branch information...
2 parents 66e4be5 + f573e33 commit 65193e7d17aabc00916f4131526078715ba69a6b Prateek Dayal committed Sep 20, 2013
@@ -2,30 +2,42 @@ module AuditTrail
module EventHandler
def ticket_archived
- log_string(:action_type => 'Archived')
+ log_string(action_type: 'Archived')
end
def ticket_unarchived
- log_string(:action_type => 'Unarchived')
+ log_string(action_type: 'Unarchived')
end
def ticket_spammed
- log_string(:action_type => 'Spammed')
+ log_string(action_type: 'Spammed')
end
def ticket_unspammed
- log_string(:action_type => 'Unspammed')
+ log_string(action_type: 'Unspammed')
end
-
def ticket_trashed
- log_string(:action_type => 'Trashed')
+ log_string(action_type: 'Trashed')
end
def ticket_untrashed
- log_string(:action_type => 'Untrashed')
+ log_string(action_type: 'Untrashed')
+ end
+
+ def ticket_assigned_to_agent
+ assignee = payload.assignment.assignee.user
+ log_string(action_type: "Assigned to #{assignee.name} (#{assignee.email})")
end
+ def ticket_assigned_to_group
+ assignee = payload.assignment.assignee.group
+ log_string(action_type: "Assigned to \"#{assignee.name}\" group")
+ end
+
+ def ticket_unassigned
+ log_string(action_type: 'Unassigned')
+ end
end
end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -1,15 +1,15 @@
module Github
module ActionHandler
def button
-
+ ticket = payload.tickets.first
begin
- create_issue(payload.overlay.title, payload.overlay.description)
+ response = create_issue(payload.overlay.title, payload.overlay.description)
+ html = comment_html(response)
+ comment_on_ticket(ticket, html)
rescue Exception => e
return [500, e.message]
end
-
[200, "Ticket sent to Github Issues"]
-
end
end
end
@@ -22,14 +22,27 @@ class Base < SupportBeeApp::Base
string :owner, :required => true, :label => 'Owner'
string :repo, :required => true, :label => 'Repository'
+ def validate
+ errors[:flash] = ["Please fill in all the required fields"] if settings.owner.blank? or settings.repo.blank?
+ errors.empty? ? true : false
+ end
+
private
def create_issue(issue_title, description)
token = settings.oauth_token || settings.token
response = http_post "https://api.github.com/repos/#{settings.owner}/#{settings.repo}/issues?access_token=#{token}" do |req|
- req.body = {:title => issue_title, :body => description}.to_json
+ req.body = {:title => issue_title, :body => description, :labels => ['supportbee']}.to_json
end
end
+ def comment_html(response)
+ "Github Issue created!\n <a href=#{response.body['html_url']}>#{response.body['title']}</a>"
+ end
+
+ def comment_on_ticket(ticket, html)
+ ticket.comment(:html => html)
+ end
+
end
end
View
@@ -180,7 +180,10 @@ def initialize(data = {}, payload = {})
@data = Hashie::Mash.new(data) || {}
@auth = @data[:auth] || {}
@settings = @data[:settings] || {}
+
+ payload = {} if payload.blank?
@payload = pre_process_payload(payload)
+
@store = SupportBeeApp::Store.new(redis_key_prefix: redis_key_prefix)
@errors = {}
end
@@ -291,6 +294,7 @@ def pre_process_payload(raw)
result[:company] = SupportBee::Company.new(auth, raw[:company]) if raw[:company]
result[:comment] = SupportBee::Comment.new(auth, raw[:comment]) if raw[:comment]
result[:agent] = SupportBee::User.new(auth, raw[:agent]) if raw[:agent]
+ result[:assignment] = SupportBee::Assignment.new(auth, raw[:assignment]) if raw[:assignment]
result
end
@@ -1,5 +1,13 @@
module SupportBee
class Assignment < Resource
+ def initialize(data={}, payload={})
+ super(data, payload)
+ if assignee
+ assignee.user = SupportBee::User.new(auth, assignee.user) if assignee.user?
+ assignee.group = SupportBee::Group.new(auth, assignee.group) if assignee.group?
+ end
+ end
+
def refresh
raise NotImplementedError.new('An Assignment cannot be refreshed')
end
Deleted file not rendered
Deleted file not rendered

0 comments on commit 65193e7

Please sign in to comment.