BigW Consortium Gitlab

assembla_service.rb 786 Bytes
Newer Older
1 2 3
class AssemblaService < Service
  include HTTParty

4
  prop_accessor :token, :subdomain
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  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
    [
21 22
      { type: 'text', name: 'token', placeholder: '' },
      { type: 'text', name: 'subdomain', placeholder: '' }
23 24 25
    ]
  end

26 27 28 29
  def supported_events
    %w(push)
  end

30
  def execute(data)
31
    return unless supported_events.include?(data[:object_kind])
32

33
    url = "https://atlas.assembla.com/spaces/#{subdomain}/github_tool?secret_key=#{token}"
34
    AssemblaService.post(url, body: { payload: data }.to_json, headers: { 'Content-Type' => 'application/json' })
35 36
  end
end