Class: CC::Service::StashPullRequests

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

Defined Under Namespace

Classes: Config

Constant Summary collapse

STASH_STATES =
{
  "error" => "FAILED",
  "failure" => "FAILED",
  "pending" => "INPROGRESS",
  "skipped" => "SUCCESSFUL",
  "success" => "SUCCESSFUL",
}.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_pull_requestObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cc/services/stash_pull_requests.rb', line 37

def receive_pull_request
  setup_http

  params = {
    description: description,
    key: "Code Climate",
    name: "Code Climate",
    state: state,
    url:  @payload["details_url"],
  }
  service_post(url, params.to_json)
end

#receive_testObject



27
28
29
30
31
32
33
34
35
# File 'lib/cc/services/stash_pull_requests.rb', line 27

def receive_test
  setup_http

  service_get(test_url)

  { ok: true, message: "Test succeeded" }
rescue HTTPError => e
  { ok: false, message: e.message }
end