Skip to content

Unfuddle App #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added apps/unfuddle/assets/images/icon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/unfuddle/assets/images/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions apps/unfuddle/assets/views/button/overlay.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<h3>Edit the message details</h3>
{{#each tickets}}
{{#ticket}}
<ol>
<li>
<label for="title">Message Title</label>
<input name="title" value="{{subject}}">
</li>
<li>
<label for="description">Message Body</label>
<textarea name="body">
{{content.text}} \n
https://{{../../company.subdomain}}.supportbee.com/tickets/{{id}}
</textarea>
</li>
</ol>
{{/ticket}}
{{/each}}
31 changes: 31 additions & 0 deletions apps/unfuddle/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Unfuddle
slug: unfuddle
access: public

description: "Send messages to Unfuddle"

category: project-management

tags:
- unfuddle
- project management

developer:
name: Mohnish G J
email: [email protected]
twitter: "mohnishgj"
github: boddhisattva

# The following config keys are used by Action Handlers
# Set button 'overlay' to true, if you want to have an overlay
# The valid values for screens are [ticket, all, unassigned, my, groups]
# Remove the following section if you do not want to define Action Handlers

action:
button:
overlay: true
screens:
- ticket
- all
- unassigned
label: Send To Unfuddle
50 changes: 50 additions & 0 deletions apps/unfuddle/unfuddle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module Unfuddle
module ActionHandler
def button
ticket = payload.tickets.first
html = ''
http.basic_auth(settings.username, settings.password)
begin
response = create_message(payload.overlay.title,payload.overlay.body)
html = message_html_comment(response['Location'], payload.overlay.title) if response and response['Location']
comment_on_ticket(ticket, html)
response
rescue Exception => e
return [500, e.message]
end
[200, "Message successfully created on Unfuddle"]
end
end
end

module Unfuddle
class Base < SupportBeeApp::Base
string :subdomain, :required => true, :label => 'Subdomain'
string :username, :required => true, :label => 'Username'
password :password, :required => true
string :project_id, :required => true, :label => 'Enter Project ID'
boolean :use_ssl, :default => true, :label => 'Use SSL'

white_list :subdomain, :username, :use_ssl, :project_id

private

def create_message(title, body)
response = http.post "https://#{settings.subdomain}.unfuddle.com/api/v1/projects/#{settings.project_id}/messages.json" do |req|
req.headers['Content-Type'] = 'application/json'
req.body = {message:{title:title, body:body}}.to_json
end
response.status == 201 ? response : false
end

def message_html_comment(target_url, message_title)
"Message created in Unfuddle<br/> <a href='#{target_url}'>#{message_title}</a>"
end

def comment_on_ticket(ticket, html)
ticket.comment(:html => html)
end

end
end