Class: Basecampeverest::Access

Inherits:
Object
  • Object
show all
Defined in:
lib/basecampeverest/resources/access.rb

Class Method Summary collapse

Class Method Details

.for_calendar(calendar_id) ⇒ Basecampeverest::Project

find the people that have access to a calendar via the Basecamp API

Parameters:

Returns:



19
20
21
22
23
24
25
# File 'lib/basecampeverest/resources/access.rb', line 19

def self.for_calendar(calendar_id)
    url = "/calendars/#{calendar_id}/accesses.json"
    response = Basecampeverest::Connect.get url 

    # parse the response to remove HTTParty info
    response.parsed_response
end

.for_project(project_id) ⇒ Basecampeverest::Project

find the people that have access to a project via the Basecamp API

Parameters:

Returns:



7
8
9
10
11
12
13
# File 'lib/basecampeverest/resources/access.rb', line 7

def self.for_project(project_id)
    url = "/projects/#{project_id}/accesses.json"
    response = Basecampeverest::Connect.get url 

    # parse the response to remove HTTParty info
    response.parsed_response
end

.grant_project(project_id, options = {}) ⇒ Basecampeverest::Project

find the people that have access to a project via the Basecamp API

Parameters:

Returns:



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/basecampeverest/resources/access.rb', line 32

def self.grant_project(project_id, options={})
    post_params = {
      :body => options.to_json,
      :headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
    }
    url = "/projects/#{project_id}/accesses.json"
    response = Basecampeverest::Connect.post url, post_params

    # parse the response to remove HTTParty info
    response.parsed_response
end

.revoke_project(project_id, user_id) ⇒ Basecampeverest::Project

find the people that have access to a project via the Basecamp API

Parameters:

Returns:



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/basecampeverest/resources/access.rb', line 49

def self.revoke_project(project_id, user_id)
    post_params = {
      :body => options.to_json,
      :headers => Basecampeverest::Connect.headers.merge({'Content-Type' => 'application/json'})
    }
    url = "/projects/#{project_id}/accesses/#{user_id}.json"
    response = Basecampeverest::Connect.get url, post_params

    # parse the response to remove HTTParty info
    response.parsed_response
end