Class: PivotaltrackerService

Inherits:
Service
  • Object
show all
Includes:
HTTParty
Defined in:
app/models/project_services/pivotaltracker_service.rb

Overview

Schema Information

Table name: services

id                    :integer          not null, primary key
type                  :string
title                 :string
project_id            :integer
created_at            :datetime         not null
updated_at            :datetime         not null
active                :boolean          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
category              :string           default("common"), not null
default               :boolean          default(FALSE)
wiki_page_events      :boolean          default(TRUE)

Instance Method Summary collapse

Methods inherited from Service

#activated?, #async_execute, available_services_names, boolean_accessor, #can_test?, #category, create_from_template, #help, #initialize_properties, #issue_tracker?, prop_accessor, #reset_updated_properties, #template?, #test, #updated_properties

Instance Method Details

#descriptionObject


35
36
37
# File 'app/models/project_services/pivotaltracker_service.rb', line 35

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

#execute(data) ⇒ Object


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/project_services/pivotaltracker_service.rb', line 53

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

  url = 'https://www.pivotaltracker.com/services/v5/source_commits'
  data[:commits].each do |commit|
    message = {
      'source_commit' => {
        'commit_id' => commit[:id],
        'author' => commit[:author][:name],
        'url' => commit[:url],
        'message' => commit[:message]
      }
    }
    PivotaltrackerService.post(
      url,
      body: message.to_json,
      headers: {
        'Content-Type' => 'application/json',
        'X-TrackerToken' => token
      }
    )
  end
end

#fieldsObject


43
44
45
46
47
# File 'app/models/project_services/pivotaltracker_service.rb', line 43

def fields
  [
    { type: 'text', name: 'token', placeholder: '' }
  ]
end

#supported_eventsObject


49
50
51
# File 'app/models/project_services/pivotaltracker_service.rb', line 49

def supported_events
  %w(push)
end

#titleObject


31
32
33
# File 'app/models/project_services/pivotaltracker_service.rb', line 31

def title
  'PivotalTracker'
end

#to_paramObject


39
40
41
# File 'app/models/project_services/pivotaltracker_service.rb', line 39

def to_param
  'pivotaltracker'
end