module Nearmiss::Client::Projects

Methods for the Projects API

Public Instance Methods

create_project(options = {}) click to toggle source

Create a project

@param options [Hash] Project information. @option options [String] :name e.g. Berkeley Art Museum @option options [String] :project_id e.g. 10611.70 @return [Sawyer::Resource] Newly created project info

# File lib/nearmiss-ruby/client/projects.rb, line 33
def create_project(options = {})
  post 'projects', options
end
delete_project(project, options = {}) click to toggle source

Delete a project

@param project [String] Project ID @return [Boolean] Indicating success of deletion

# File lib/nearmiss-ruby/client/projects.rb, line 60
def delete_project(project, options = {})
  boolean_from_response :delete, "projects/#{project}", options
end
Also aliased as: remove_project
edit_project(project, options = {}) click to toggle source

Edit a project

@param options [Hash] Project information. @option options [String] :name e.g. Berkeley Art Museum @option options [String] :project_id e.g. 10611.70

@return

[Sawyer::Resource] Newly created project info

@example Update a project

@client.edit_project('some_id', {
  name: "New name of project",
  project_id: "1043.32"
})
# File lib/nearmiss-ruby/client/projects.rb, line 51
def edit_project(project, options = {})
  patch "#{project_path(project)}", options
end
list_projects(options = {})
Alias for: projects
project(project, options = {}) click to toggle source

Get a single project

@param project [String] UUID of project to fetch @return [Sawyer::Resource] Project information

# File lib/nearmiss-ruby/client/projects.rb, line 23
def project(project, options = {})
  get "#{project_path(project)}", options
end
projects(options = {}) click to toggle source

List projects

@note Shows a list of projects for the users organization aka account

@return [Array<Sawyer::Resource>] List of projects

# File lib/nearmiss-ruby/client/projects.rb, line 13
def projects(options = {})
  paginate "projects", options
end
Also aliased as: list_projects
remove_project(project, options = {})
Alias for: delete_project

Private Instance Methods

project_path(id) click to toggle source
# File lib/nearmiss-ruby/client/projects.rb, line 67
def project_path(id)
  if uuid?(id)
    "projects/#{id}"
  else
    "project/#{id}"
  end
end