Module: Nearmiss::Client::Projects

Included in:
Nearmiss::Client
Defined in:
lib/nearmiss-ruby/client/projects.rb

Overview

Methods for the Projects API

Instance Method Summary collapse

Instance Method Details

#create_project(options = {}) ⇒ Sawyer::Resource

Create a project

Parameters:

  • options (Hash) (defaults to: {})

    Project information.

Options Hash (options):

  • :name (String)

    e.g. Berkeley Art Museum

  • :project_id (String)

    e.g. 10611.70

Returns:

  • (Sawyer::Resource)

    Newly created project info



33
34
35
# File 'lib/nearmiss-ruby/client/projects.rb', line 33

def create_project(options = {})
  post 'projects', options
end

#delete_project(project, options = {}) ⇒ Boolean Also known as: remove_project

Delete a project

Parameters:

  • project (String)

    Project ID

Returns:

  • (Boolean)

    Indicating success of deletion



60
61
62
# File 'lib/nearmiss-ruby/client/projects.rb', line 60

def delete_project(project, options = {})
  boolean_from_response :delete, "projects/#{project}", options
end

#edit_project(project, options = {}) ⇒ Object

Edit a project

Examples:

Update a project

@client.edit_project('some_id', {
  name: "New name of project",
  project_id: "1043.32"
})

Parameters:

  • options (Hash) (defaults to: {})

    Project information.

Options Hash (options):

  • :name (String)

    e.g. Berkeley Art Museum

  • :project_id (String)

    e.g. 10611.70

Returns:

  • Sawyer::Resource

    Newly created project info



51
52
53
# File 'lib/nearmiss-ruby/client/projects.rb', line 51

def edit_project(project, options = {})
  patch "#{project_path(project)}", options
end

#project(project, options = {}) ⇒ Sawyer::Resource

Get a single project

Parameters:

  • project (String)

    UUID of project to fetch

Returns:

  • (Sawyer::Resource)

    Project information



23
24
25
# File 'lib/nearmiss-ruby/client/projects.rb', line 23

def project(project, options = {})
  get "#{project_path(project)}", options
end

#projects(options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_projects

Note:

Shows a list of projects for the users organization aka account

List projects

Returns:

  • (Array<Sawyer::Resource>)

    List of projects



13
14
15
# File 'lib/nearmiss-ruby/client/projects.rb', line 13

def projects(options = {})
  paginate "projects", options
end