2013-11-21 07:18:02 -05:00
|
|
|
class AssemblaService < Service
|
2014-09-07 20:54:18 -04:00
|
|
|
prop_accessor :token, :subdomain
|
2013-11-21 07:18:02 -05:00
|
|
|
validates :token, presence: true, if: :activated?
|
|
|
|
|
|
|
|
def title
|
|
|
|
'Assembla'
|
|
|
|
end
|
|
|
|
|
|
|
|
def description
|
|
|
|
'Project Management Software (Source Commits Endpoint)'
|
|
|
|
end
|
|
|
|
|
2016-12-27 07:44:24 -05:00
|
|
|
def self.to_param
|
2013-11-21 07:18:02 -05:00
|
|
|
'assembla'
|
|
|
|
end
|
|
|
|
|
|
|
|
def fields
|
|
|
|
[
|
2017-05-22 06:07:12 -04:00
|
|
|
{ type: 'text', name: 'token', placeholder: '', required: true },
|
2014-01-24 02:42:24 -05:00
|
|
|
{ type: 'text', name: 'subdomain', placeholder: '' }
|
2013-11-21 07:18:02 -05:00
|
|
|
]
|
|
|
|
end
|
|
|
|
|
2016-12-27 07:44:24 -05:00
|
|
|
def self.supported_events
|
2015-02-28 11:33:18 -05:00
|
|
|
%w(push)
|
|
|
|
end
|
|
|
|
|
2015-02-19 00:02:57 -05:00
|
|
|
def execute(data)
|
2015-02-28 11:33:18 -05:00
|
|
|
return unless supported_events.include?(data[:object_kind])
|
2015-02-19 00:02:57 -05:00
|
|
|
|
2014-01-24 02:42:24 -05:00
|
|
|
url = "https://atlas.assembla.com/spaces/#{subdomain}/github_tool?secret_key=#{token}"
|
2018-03-13 18:38:25 -04:00
|
|
|
Gitlab::HTTP.post(url, body: { payload: data }.to_json, headers: { 'Content-Type' => 'application/json' })
|
2013-11-21 07:18:02 -05:00
|
|
|
end
|
|
|
|
end
|