Module: TeamworkApi::API::People

Included in:
Client
Defined in:
lib/teamwork_api/api/people.rb

Overview

client methods for People developer.teamwork.com/projects/people

Constant Summary collapse

OPTIONAL_GET_ATTRIBUTES =
[
  :project_id,
  :page,
  :page_size,
  :group_by_company,
  :sort,
  :sort_order,
  :full_profile
].freeze
OPTIONAL_UPDATE_ATTRIBUTES =
[
  :'edit-all-tasks',
  :'view-messages-and-files',
  :'view-tasks-and-milestones',
  :'view-time',
  :'view-notebooks',
  :'view-risk-register',
  :'view-invoices',
  :'view-links',
  :'view-links',
  :'add-tasks',
  :'add-milestones',
  :'add-taskLists',
  :'add-messages',
  :'add-files',
  :'add-time',
  :'add-notebooks',
  :'add-links',
  :'set-privacy',
  :'set-privacy',
  :'is-observing',
  :'can-be-assigned-to-tasks-and-milestones',
  :'project-administrator',
  :'add-people-to-project'
].freeze

Instance Method Summary collapse

Instance Method Details

#add_person_to_project(project_id, person_id) ⇒ Object



54
55
56
57
58
59
# File 'lib/teamwork_api/api/people.rb', line 54

def add_person_to_project(project_id, person_id)
  response =
    put "projects/#{project_id}/people.json",
        add: { userIdList: person_id }
  response.body['STATUS']
end

#people(args = {}) ⇒ Object



48
49
50
51
52
# File 'lib/teamwork_api/api/people.rb', line 48

def people(args = {})
  args = API.params(args).optional(*OPTIONAL_GET_ATTRIBUTES).to_h
  response = get '/people.json', args
  response.body['people']
end

#person(person_id) ⇒ Object



43
44
45
46
# File 'lib/teamwork_api/api/people.rb', line 43

def person(person_id)
  response = get "/people/#{person_id}.json"
  response.body['person']
end

#set_permissions(project_id, person_id, args) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/teamwork_api/api/people.rb', line 61

def set_permissions(project_id, person_id, args)
  args = API.params(args).optional(*OPTIONAL_UPDATE_ATTRIBUTES).to_h
  response =
    put "projects/#{project_id}/people/#{person_id}.json",
        permissions: args
  response.body
end