Class: DevFlow::TargetProcess

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/devflow/target_process.rb,
lib/devflow/target_process/error.rb

Defined Under Namespace

Classes: ConfigError, RequestError

Constant Summary collapse

BASE_URI =
ENV["TP_BASE_URL"]
USER_ID =
ENV["TP_USER_ID"]
ACCESS_TOKEN =
ENV["TP_ACCESS_TOKEN"]
ENTITY_PATTERN =
/#{BASE_URI}\/entity\/(\d+)/.freeze

Class Method Summary collapse

Class Method Details

.assignmentsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/devflow/target_process.rb', line 27

def self.assignments
  where = "(GeneralUser.Id eq #{USER_ID})and" \
    "(Assignable.EntityState.Name eq 'In Progress')"
  response = request(
    :get,
    "/api/v1/assignments",
    query: { where: where, include: "[Assignable[Id,Name]]" }
  )

  response["Items"].map do |i|
    { id: i["Assignable"]["Id"], name: i["Assignable"]["Name"] }
  end
end

.check_config!Object

Raises:



21
22
23
24
25
# File 'lib/devflow/target_process.rb', line 21

def self.check_config!
  raise ConfigError, "TP_ACCESS_TOKEN" unless ACCESS_TOKEN
  raise ConfigError, "TP_BASE_URL" unless BASE_URI
  raise ConfigError, "TP_ACCESS_TOKEN" unless ACCESS_TOKEN
end

.request(method, *args) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/devflow/target_process.rb', line 41

def self.request(method, *args)
  response = send(method, *args)

  raise TargetProcess::RequestError, response unless response.code == 200

  response
end