ex_trello v0.4.0 ExTrello

Provides access interface to the Trello API.

Summary

Functions

Fetch action associated with action_id

GET OAuthAuthorizeToken

GET OAuthAuthorizeToken

Fetch board with board_id

Fetch board with board_id. See reference for list of options

Fetch cards associated to %ExTrello.Model.Board{} or board id

Fetch cards associated to %ExTrello.Model.Board{} or board id. See reference for detailed list of options

Fetch all boards of authenticated user

Fetch all boards of authenticated user. See reference for detailed list of options

Fetch all boards of given username or Trello User ID. See reference for detailed list of options

Fetch card associated with given id or shortlink

Fetch card associated with given id or shortlink with options. See reference for detailed list of options

Provides OAuth configuration settings for accessing trello server

Provides OAuth configuration settings for accessing trello server

Create board with supplied name

Create board with supplied name. See reference for detailed list of options

Create a card for a given %List{} or list id

Create a card for a given %List{} or list id using provided options. See reference for detailed list of options

Create a comment on a given card

Edit board with supplied field values. See reference for detailed list of options

Edit a card. A comprehensive list of all properties that can be passed can be found in the reference

GET OAuthGetRequestToken

Functions

access_token(verifier, request_token, request_token_secret)

Specs

access_token(String.t, String.t, String.t) ::
  {:ok, String.t} |
  {:error, String.t}

GET OAuthGetAccessToken

Examples

ExTrello.access_token("OAUTH_VERIFIER", "OAUTH_TOKEN", "OAUTH_TOKEN_SECRET")
action(action_id)

Fetch action associated with action_id.

Examples

ExTrello.action("57a5108615c475280d511795")

Reference

https://developers.trello.com/advanced-reference/action#actions-idaction

authorize_url(oauth_token)

Specs

authorize_url(String.t) ::
  {:ok, String.t} |
  {:error, String.t}

GET OAuthAuthorizeToken

Examples

token = ExTrello.request_token
ExTrello.authorize_url(token.oauth_token)

Returns the URL you should redirect the user to for authorization

authorize_url(oauth_token, options)

Specs

authorize_url(String.t, Map.t) ::
  {:ok, String.t} |
  {:error, String.t}

GET OAuthAuthorizeToken

Examples

token = ExTrello.request_token("http://localhost:4000/auth/trello/callback/1234")
ExTrello.authorize_url(token.oauth_token, %{return_url: "http://localhost:4000/auth/trello/callback/1234", scope: "read,write", expiration: "never", name: "Example Authentication"})

Returns the URL you should redirect the user to for authorization

board(id)

Specs

Fetch board with board_id.

Examples

ExTrello.board("57663306e4b15193fcc97483")

Reference

https://developers.trello.com/advanced-reference/board#get-1-boards-board-id

board(id, options)

Specs

Fetch board with board_id. See reference for list of options.

Examples

ExTrello.board("57663306e4b15193fcc97483", [actions_display: true])

Reference

https://developers.trello.com/advanced-reference/board#get-1-boards-board-id

board_cards(board_or_id)

Specs

Fetch cards associated to %ExTrello.Model.Board{} or board id.

Examples

# Using a board_id
ExTrello.board_cards("57663306e4b15193fcc97483")

# Using a Board struct (Useful in case you're passing this struct around, you should just use the `cards: "all"` flag to fetch a board and its cards in the same request)
# board = %ExTrello.Model.Board{id: "57663306e4b15193fcc97483" blah blah blah}
board |> ExTrello.board_cards

Reference

https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-cards

board_cards(board_or_id, options)

Fetch cards associated to %ExTrello.Model.Board{} or board id. See reference for detailed list of options.

Examples

# Using a board_id
ExTrello.board_cards("57663306e4b15193fcc97483", attachments: true, checklists: "all")

# Using a Board struct (Useful in case you're passing this struct around, you should just use the `cards: "all"` flag to fetch a board and its cards in the same request)
# board = %ExTrello.Model.Board{id: "57663306e4b15193fcc97483" blah blah blah}
board |> ExTrello.board_cards(members: true)

Reference

https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-cards

boards()

Specs

boards :: [ExTrello.Model.Board] | []

Fetch all boards of authenticated user.

Examples

ExTrello.boards()
boards(options)

Specs

boards(Keyword.t) :: [ExTrello.Model.Board] | []

Fetch all boards of authenticated user. See reference for detailed list of options.

Examples

ExTrello.boards([filter: "pinned,public", fields: "shortLink,subscribed"])

Reference

https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-boards

boards(user, options)

Specs

boards(String.t, Keyword.t) ::
  [ExTrello.Model.Board] |
  []

Fetch all boards of given username or Trello User ID. See reference for detailed list of options.

Examples

ExTrello.boards("trello")

Reference

https://developers.trello.com/advanced-reference/member#get-1-members-idmember-or-username-boards

card(card_id_or_shortlink)

Fetch card associated with given id or shortlink.

Examples

# Using card id
ExTrello.card("56e8fa38abbbdd74b978c3cd")

# Using shortlink
ExTrello.card("JyUbYknO")

Reference

https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink

card(card_id_or_shortlink, options)

Fetch card associated with given id or shortlink with options. See reference for detailed list of options.

Examples

ExTrello.card("JyUbYknO", list: true)

Reference

https://developers.trello.com/advanced-reference/card#get-1-cards-card-id-or-shortlink

configure(oauth)

Specs

configure(Keyword.t) :: :ok

Provides OAuth configuration settings for accessing trello server.

The specified configuration applies globally. Use ExTrello.configure/2 for setting different configurations on each processes.

Examples

ExTrello.configure(
  app_key: System.get_env("TRELLO_APP_KEY"),
  app_secret: System.get_env("TRELLO_APP_SECRET"),
  access_token: System.get_env("TRELLO_ACCESS_TOKEN"),
  access_token_secret: System.get_env("TRELLO_ACCESS_SECRET")
)
configure(scope, oauth)

Specs

configure(:global | :process, Keyword.t) :: :ok

Provides OAuth configuration settings for accessing trello server.

Options

The scope can have one of the following values.

  • :global - configuration is shared for all processes.

  • :process - configuration is isolated for each process.

Examples

ExTrello.configure(
  :process,
  app_key: System.get_env("TRELLO_APP_KEY"),
  app_secret: System.get_env("TRELLO_APP_SECRET"),
  access_token: System.get_env("TRELLO_ACCESS_TOKEN"),
  access_token_secret: System.get_env("TRELLO_ACCESS_SECRET")
)
create_board(name)

Specs

create_board(String.t) :: ExTrello.Model.Board.t | nil

Create board with supplied name.

Examples

# Bad
ExTrello.create_board(123) #=> %ExTrello.Error{code: 422, message: "You must provide a name with a length between 1 and 16384 to create a board."}

# Good
ExTrello.create_board("TrelloHub")

Reference

https://developers.trello.com/advanced-reference/board#post-1-boards

create_board(name, options)

Specs

create_board(String.t, Keyword.t) ::
  ExTrello.Model.Board.t |
  nil

Create board with supplied name. See reference for detailed list of options.

Examples

# Bad
ExTrello.create_board(123) #=> %ExTrello.Error{code: 422, message: "You must provide a name with a length between 1 and 16384 to create a board."}

# Good
ExTrello.create_board("TrelloHub", desc: "An application to synchronize your Trello boards with your GitHub activity.", powerups: "all")

Reference

https://developers.trello.com/advanced-reference/board#post-1-boards

create_card(list_or_id, name)

Create a card for a given %List{} or list id.

Examples

board = ExTrello.board("57663306e4b15193fcc97483", lists: "all")
%ExTrello.Model.List{id: id} = List.first(board.lists) # This happens to be my Icebox list
ExTrello.create_card(id, "Should definitely improve documentation and tests for this project.")

Reference

https://developers.trello.com/advanced-reference/card#post-1-cards

create_card(list_or_id, name, options)

Create a card for a given %List{} or list id using provided options. See reference for detailed list of options.

Examples

board = ExTrello.board("57663306e4b15193fcc97483", lists: "all", members: "all")

List.first(board.lists) # This happens to be my Icebox list
|> ExTrello.create_card("This card will be at the top of the list.", pos: "top", idMembers: Enum.map(board.members, &(&1.id)) |> Enum.join(","))

Reference

https://developers.trello.com/advanced-reference/card#post-1-cards

create_comment(card_or_id_or_shortlink, text)

Create a comment on a given card.

Examples

ExTrello.create_comment("JyUbYknO", "Passed code review, moving this to the `Complete` list.")

Reference

https://developers.trello.com/advanced-reference/card#post-1-cards-card-id-or-shortlink-actions-comments

edit_board(id, options)

Specs

edit_board(String.t, Keyword.t) ::
  ExTrello.Model.Board.t |
  nil

Edit board with supplied field values. See reference for detailed list of options.

Examples

# Capture the id of our newly created board.
%ExTrello.Model.Board{id: id} = ExTrello.create_board("Some name")
# Let's edit the name of our new board.
ExTrello.edit_board(id, name: "Another name entirely.")

Reference

https://developers.trello.com/advanced-reference/board#put-1-boards-board-id

edit_card(card_or_id_or_shortlink, properties_to_edit)

Edit a card. A comprehensive list of all properties that can be passed can be found in the reference.

Examples

# Using ID
ExTrello.edit_card("56e8fa38abbbdd74b978c3cd", name: "A different name now.", desc: "Honestly does anyone even read these?", pos: "top", idList: "57663322ac7d147b2c337e34")

# Using Shortlink
ExTrello.edit_card("JyUbYknO", closed: true, subscribed: false)

# Using a %ExTrello.Model.Card{} struct
ExTrello.card("JyUbYknO")
|> ExTrello.edit_card(name: "I passed an ExTrello.Model.Card struct to the function to edit this card.")

Reference

https://developers.trello.com/advanced-reference/card#put-1-cards-card-id-or-shortlink

request_token(return_url)

Specs

GET OAuthGetRequestToken

Examples

ExTrello.request_token("http://localhost:4000/auth/trello/callback/1234")

Reference

https://trello.com/app-key

start(type, args)

false