class CitizenCodeScripts::Pivotal

Attributes

token[R]

Public Class Methods

new(token) click to toggle source
# File lib/citizen_code_scripts/begin.rb, line 8
def initialize(token)
  @token = token
end

Public Instance Methods

request(url, method: "GET", body: nil) click to toggle source
# File lib/citizen_code_scripts/begin.rb, line 12
def request(url, method: "GET", body: nil)
  cmd = %Q{curl --silent -X #{method} -H "X-TrackerToken: #{token}"}
  cmd += %Q{ -H "Content-Type: application/json"}

  if body
    cmd += %Q{ -d '#{body}'}
  end

  cmd += %Q{ "#{url}"}

  result = `#{cmd}`

  JSON.parse(result.strip)
end