Class: Ehpt::GetProject

Inherits:
Base
  • Object
show all
Defined in:
lib/ehpt/get_project.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#data, #errors, #warnings

Instance Method Summary collapse

Methods inherited from Base

#add_error, #add_warning, call, #error?, #success?, #warning?

Constructor Details

#initialize(token, project_id) ⇒ GetProject

Returns a new instance of GetProject.



5
6
7
8
9
# File 'lib/ehpt/get_project.rb', line 5

def initialize(token, project_id)
  @token = token || ENV['PIVOTAL_TRACKER_TOKEN']
  @project_id = project_id || ENV['PIVOTAL_TRACKER_PROJECT_ID']
  super
end

Instance Attribute Details

#project_idObject (readonly)

Returns the value of attribute project_id.



3
4
5
# File 'lib/ehpt/get_project.rb', line 3

def project_id
  @project_id
end

#tokenObject (readonly)

Returns the value of attribute token.



3
4
5
# File 'lib/ehpt/get_project.rb', line 3

def token
  @token
end

Instance Method Details

#callObject



11
12
13
14
15
16
# File 'lib/ehpt/get_project.rb', line 11

def call
  pt_client = TrackerApi::Client.new(token: token)
  @data = pt_client.project(project_id)
rescue StandardError => e
  add_error(eval(e.message)[:body])
end