Module: Bugsnag::Api::Client::Collaborators

Included in:
Bugsnag::Api::Client
Defined in:
lib/bugsnag/api/client/collaborators.rb

Overview

Methods for the Organizations Collaborators API

Instance Method Summary collapse

Instance Method Details

#collaborator(org_id, collaborator_id, options = {}) ⇒ Sawyer::Resource

View a Collaborator



13
14
15
# File 'lib/bugsnag/api/client/collaborators.rb', line 13

def collaborator(org_id, collaborator_id, options = {})
  get "organizations/#{org_id}/collaborators/#{collaborator_id}", options
end

#collaborators(org_id = nil, project_id = nil, options = {}) ⇒ Array<Sawyer::Resource>

List Collaborators

Parameters:

  • per_page (Hash)

    a customizable set of options

Returns:

  • (Array<Sawyer::Resource>)

    List of Collaborators

See Also:



26
27
28
29
30
31
32
33
34
# File 'lib/bugsnag/api/client/collaborators.rb', line 26

def collaborators(org_id = nil, project_id = nil, options = {})
  if !org_id.nil?
    paginate "organizations/#{org_id}/collaborators", options
  elsif !project_id.nil?
    paginate "projects/#{project_id}/collaborators", options
  else
    raise ArgumentError, "Must supply either an org_id or a project_id"
  end
end

#delete_collaborator(org_id, id, options = {}) ⇒ Object

Delete a Collaborator



69
70
71
# File 'lib/bugsnag/api/client/collaborators.rb', line 69

def delete_collaborator(org_id, id, options = {})
  boolean_from_response :delete, "organizations/#{org_id}/collaborators/#{id}", options
end

#invite_collaborators(org_id, emails, options = {}) ⇒ Array<Sawyer::Resource>

Invite Collaborators

Parameters:

  • project_ids (Hash)

    a customizable set of options

  • admin (Hash)

    a customizable set of options

Returns:

  • (Array<Sawyer::Resource>)

    Collaborator details

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/bugsnag/api/client/collaborators.rb', line 44

def invite_collaborators(org_id, emails, options = {})
  case emails
  when String
    post "organizations/#{org_id}/collaborators", options.merge({:email => emails})
  when Array
    post "organizations/#{org_id}/collaborators/bulk_invite", options.merge({:emails => emails})
  else
    raise ArgumentError, "Emails must be a String or an Array"
  end
end

#update_collaborator_permissions(org_id, id, options = {}) ⇒ Sawyer::Resource

Update a Collaborator's permissions

Parameters:

  • project_ids (Hash)

    a customizable set of options

  • admin (Hash)

    a customizable set of options

Returns:

  • (Sawyer::Resource)

    Collaborator details

See Also:



61
62
63
# File 'lib/bugsnag/api/client/collaborators.rb', line 61

def update_collaborator_permissions(org_id, id, options = {})
  patch "organizations/#{org_id}/collaborators/#{id}", options
end

#view_collaborator_projects(org_id, id, options = {}) ⇒ Array<Sawyer::Resource>

View Projects a Collaborator has access to

Parameters:

  • sort (Hash)

    a customizable set of options

  • direction (Hash)

    a customizable set of options

  • per_page (Hash)

    a customizable set of options

Returns:

  • (Array<Sawyer::Resource>)

    A list of projects the collaborator belongs to

See Also:



80
81
82
# File 'lib/bugsnag/api/client/collaborators.rb', line 80

def view_collaborator_projects(org_id, id, options = {})
  paginate "organizations/#{org_id}/collaborators/#{id}/projects", options
end