Permalink
Browse files

Add tenderapp.com as a service

  • Loading branch information...
1 parent 11563a0 commit 65399f9d75f4f080b9e49582cb6d3244dae5083d Julien committed Jul 2, 2012
Showing with 40 additions and 0 deletions.
  1. +9 −0 docs/tender
  2. +31 −0 services/tender.rb
View
@@ -0,0 +1,9 @@
+Install Notes
+-------------
+
+If your URL is http://mysite.tenderapp.com, then:
+
+* Your **domain** is `mysite.tenderapp.com`
+
+* You can find your token in the tracker settings:
+ http://mysite.tenderapp.com/settings/trackers
View
@@ -0,0 +1,31 @@
+class Service::Tender < Service
+ string :domain, :token
+ default_events :issues
+
+ def receive_issues
+ raise_config_error 'Missing token' if data['token'].to_s.empty?
+ raise_config_error 'Missing domain' if data['domain'].to_s.empty?
+
+ begin
+ # Nothing to see here really, just reposting the payload as-is
+ http.headers['content-type'] = 'application/json'
+ body = JSON.generate(payload)
+ url = "https://#{data['domain']}/tickets/github/#{data['token']}"
+ http_post url, body
+
+ # Shamelessly copied from the 'web' service
+ rescue Addressable::URI::InvalidURIError, Errno::EHOSTUNREACH
+ raise_missing_error $!.to_s
+ rescue SocketError
+ if $!.to_s =~ /getaddrinfo:/
+ raise_missing_error "Invalid host name."
+ else
+ raise
+ end
+ rescue EOFError
+ raise_config_error "Invalid server response. Make sure the URL uses the correct protocol."
+ end
+ end
+
+ alias receive_pull_request receive_issues
+end

0 comments on commit 65399f9

Please sign in to comment.