Packages

Pivo is an Elixir interface for the Pivotal Tracker REST API V5.

Current section

Files

Jump to
pivo lib pivo.ex
Raw

lib/pivo.ex

defmodule Pivo do
@moduledoc """
Interface to Pivotal's Tracker API.
"""
alias Pivo.{ActionRouter, TrackerAPI}
alias Pivo.Resources.Comment
@doc """
Deletes a comment.
"""
def destroy_comment(project_id, story_id, comment_id)
when is_integer(project_id) and is_integer(story_id) and is_integer(comment_id) do
Comment
|> ActionRouter.destroy(
path_params: [project_id: project_id, story_id: story_id, comment_id: comment_id]
)
|> TrackerAPI.request()
end
@doc """
Gets a comment.
"""
def fetch_comment(project_id, story_id, comment_id)
when is_integer(project_id) and is_integer(story_id) and is_integer(comment_id) do
Comment
|> ActionRouter.fetch(
path_params: [project_id: project_id, story_id: story_id, comment_id: comment_id]
)
|> TrackerAPI.request()
end
@doc """
Updates a comment.
"""
def update_comment(project_id, story_id, comment_id, update_map)
when is_integer(project_id) and is_integer(story_id) and is_integer(comment_id) and
is_map(update_map) do
Comment
|> ActionRouter.update(update_map,
path_params: [project_id: project_id, story_id: story_id, comment_id: comment_id]
)
|> TrackerAPI.request()
end
@doc """
Add a new comment.
"""
def create_comment(project_id, story_id, create_map)
when is_integer(project_id) and is_integer(story_id) and is_map(create_map) do
Comment
|> ActionRouter.create(create_map, path_params: [project_id: project_id, story_id: story_id])
|> TrackerAPI.request()
end
@doc """
Returns the specified story's comments.
"""
def get_selected_comments(project_id, story_id)
when is_integer(project_id) and is_integer(story_id) do
Comment
|> ActionRouter.get_selected(path_params: [project_id: project_id, story_id: story_id])
|> TrackerAPI.request()
end
alias Pivo.Resources.Me
@doc """
Returns information from the user's profile plus the list of projects to which the user has access.
"""
def fetch_me do
Me
|> ActionRouter.fetch()
|> TrackerAPI.request()
end
@doc """
Update the person's personal settings and return their profile and list of projects.
"""
def update_me(update_map) when is_map(update_map) do
Me
|> ActionRouter.update(update_map)
|> TrackerAPI.request()
end
alias Pivo.Resources.Project
@doc """
Permanently delete the specified project.
"""
def destroy_project(id) when is_integer(id) do
Project
|> ActionRouter.destroy(path_params: [project_id: id])
|> TrackerAPI.request()
end
@doc """
Fetch the content of the specified project.
"""
def fetch_project(id) when is_integer(id) do
Project
|> ActionRouter.fetch(path_params: [project_id: id])
|> TrackerAPI.request()
end
@doc """
Update the specified project.
"""
def update_project(id, update_map) when is_integer(id) and is_map(update_map) do
Project
|> ActionRouter.update(update_map, path_params: [project_id: id])
|> TrackerAPI.request()
end
@doc """
Create a new empty project.
"""
def create_project(create_map) when is_map(create_map) do
Project
|> ActionRouter.create(create_map)
|> TrackerAPI.request()
end
@doc """
Get all of a user's active projects.
"""
def get_all_projects do
Project
|> ActionRouter.get_all()
|> TrackerAPI.request()
end
alias Pivo.Resources.Story
@doc """
Deletes a story.
"""
def destroy_story(project_id, story_id) when is_integer(project_id) and is_integer(story_id) do
Story
|> ActionRouter.destroy(path_params: [project_id: project_id, story_id: story_id])
|> TrackerAPI.request()
end
@doc """
Returns the specified story.
"""
def fetch_story(project_id, story_id) when is_integer(project_id) and is_integer(story_id) do
Story
|> ActionRouter.fetch(path_params: [project_id: project_id, story_id: story_id])
|> TrackerAPI.request()
end
@doc """
Updates a story.
"""
def update_story(project_id, story_id, update_map)
when is_integer(project_id) and is_integer(story_id) and is_map(update_map) do
Story
|> ActionRouter.update(update_map, path_params: [project_id: project_id, story_id: story_id])
|> TrackerAPI.request()
end
@doc """
Create a new story.
"""
def create_story(project_id, create_map) when is_integer(project_id) and is_map(create_map) do
Story
|> ActionRouter.create(create_map, path_params: [project_id: project_id])
|> TrackerAPI.request()
end
@doc """
Provides selected stories. (Paginated)
"""
def get_paginated_stories(project_id) when is_integer(project_id) do
Story
|> ActionRouter.get_paginated(path_params: [project_id: project_id])
|> TrackerAPI.request()
end
end