BigW Consortium Gitlab

assembla_service.rb 812 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
  validates :token, presence: true, if: :activated?

  def title
    'Assembla'
  end

  def description
    'Project Management Software (Source Commits Endpoint)'
  end

15
  def self.to_param
16 17 18 19 20
    'assembla'
  end

  def fields
    [
21
      { type: 'text', name: 'token', placeholder: '', required: true },
22
      { type: 'text', name: 'subdomain', placeholder: '' }
23 24 25
    ]
  end

26
  def self.supported_events
27 28 29
    %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