Class: CC::Service::Asana

Inherits:
CC::Service show all
Defined in:
lib/cc/services/asana.rb

Defined Under Namespace

Classes: Config

Constant Summary collapse

ENDPOINT =
"https://app.asana.com/api/1.0/tasks".freeze

Constants inherited from CC::Service

ABSTRACT_SLUGS, ALL_EVENTS, ConfigurationError, Error

Constants included from Helper

Helper::GREEN_HEX, Helper::RED_HEX

Constants included from HTTP

HTTP::REDIRECT_CODES

Instance Attribute Summary

Attributes inherited from CC::Service

#config, #event, #payload

Instance Method Summary collapse

Methods inherited from CC::Service

by_slug, inherited, #initialize, load_services, #receive, services, slug

Methods included from Helper

#changed, #color, #compare_url, #details_url, #emoji, #hex_color, #improved?, #repo_name

Methods included from HTTP

#ca_file, #formatted_post_response, #http, #http_method, #raw_get, #raw_post, #service_get, #service_post, #service_post_with_redirects

Constructor Details

This class inherits a constructor from CC::Service

Instance Method Details

#receive_issueObject



41
42
43
44
45
46
47
# File 'lib/cc/services/asana.rb', line 41

def receive_issue
  title = %(Fix "#{issue["check_name"]}" issue in #{constant_name})

  body = [issue["description"], details_url].join("\n\n")

  create_task(title, body)
end

#receive_qualityObject



49
50
51
# File 'lib/cc/services/asana.rb', line 49

def receive_quality
  create_task("#{quality_title} - #{details_url}")
end

#receive_testObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/cc/services/asana.rb', line 30

def receive_test
  result = create_task("Test task from Code Climate")
  result.merge(
    message: "Ticket <a href='#{result[:url]}'>#{result[:id]}</a> created.",
  )
rescue CC::Service::HTTPError => ex
  body = JSON.parse(ex.response_body)
  ex.user_message = body["errors"].map { |e| e["message"] }.join(" ")
  raise ex
end

#receive_vulnerabilityObject



53
54
55
56
57
58
# File 'lib/cc/services/asana.rb', line 53

def receive_vulnerability
  formatter = CC::Formatters::TicketFormatter.new(self)
  title = formatter.format_vulnerability_title

  create_task("#{title} - #{details_url}")
end