debian-mirror-gitlab/app/models/project_services/assembla_service.rb

58 lines
1.6 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
# == Schema Information
#
# Table name: services
#
2015-04-26 12:48:37 +05:30
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# project_id :integer
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# properties :text
# template :boolean default(FALSE)
# push_events :boolean default(TRUE)
# issues_events :boolean default(TRUE)
# merge_requests_events :boolean default(TRUE)
# tag_push_events :boolean default(TRUE)
# note_events :boolean default(TRUE), not null
# build_events :boolean default(FALSE), not null
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
def to_param
'assembla'
end
def fields
[
{ type: 'text', name: 'token', placeholder: '' },
{ type: 'text', name: 'subdomain', placeholder: '' }
]
end
2015-04-26 12:48:37 +05:30
def supported_events
%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