2014-09-02 18:07:02 +05:30
|
|
|
class AssemblaService < Service
|
|
|
|
include HTTParty
|
|
|
|
|
2015-04-26 12:48:37 +05:30
|
|
|
prop_accessor :token, :subdomain
|
2014-09-02 18:07:02 +05:30
|
|
|
validates :token, presence: true, if: :activated?
|
|
|
|
|
|
|
|
def title
|
|
|
|
'Assembla'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
'Project Management Software (Source Commits Endpoint)'
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def self.to_param
|
2014-09-02 18:07:02 +05:30
|
|
|
'assembla'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
|
|
|
{ type: 'text', name: 'token', placeholder: '' },
|
|
|
|
{ type: 'text', name: 'subdomain', placeholder: '' }
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def self.supported_events
|
2015-04-26 12:48:37 +05:30
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(data)
|
|
|
|
return unless supported_events.include?(data[:object_kind])
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
url = "https://atlas.assembla.com/spaces/#{subdomain}/github_tool?secret_key=#{token}"
|
2015-04-26 12:48:37 +05:30
|
|
|
AssemblaService.post(url, body: { payload: data }.to_json, headers: { 'Content-Type' => 'application/json' })
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|