CardsAPI

How to Use

local Trello = TrelloModule.new(TrelloKey, TrelloToken) -- Initializing the module
local TrelloLists = Trello.Lists -- Initializing the ListsAPI
local TrelloCards = Trello.Cards -- Initializing the CardsAPI

Functions

TrelloCards:CreateCard(CardName, ListID, ExtraData)

Creates a new Trello card.

CardName is the name you want to set for the card, ListID is the list's ID you want it to be created in, and ExtraData are optional extra arguments.

Returns the new card's information. If it fails to create the card, it returns false.

local Trello = TrelloModule.new(TrelloKey, TrelloToken) -- Initializing the module
local TrelloLists = Trello.Lists -- Initializing the ListsAPI
local TrelloCards = Trello.Cards -- Initializing the CardsAPI

local ListID = TrelloLists:GetListID('BoardID', 'Example List')

local NewCard = TrelloCards:CreateCard('Example Card', ListID, {
    Description = 'Example Description',
    Labels = {'Label1', 'Label2'}
})

if not NewCard then
    print('Failed to Create Card.')
else
    print(NewCard.id)
end

TrelloCards:DeleteCard(CardID)

Deletes a Trello card.

CardID is the ID of the card you want to delete.

Returns true or false depending on if it successfully deleted the card or not.

local Trello = TrelloModule.new(TrelloKey, TrelloToken) -- Initializing the module
local TrelloLists = Trello.Lists -- Initializing the ListsAPI
local TrelloCards = Trello.Cards -- Initializing the CardsAPI

local ListID = TrelloLists:GetListID('BoardID', 'Example List')

local NewCard = TrelloCards:CreateCard('Example Card', ListID, {
    Description = 'Example Description',
    Labels = {'Label1', 'Label2'}
})

wait(5)

local DeletedCard = TrelloCards:DeleteCard(NewCard.id)

if not DeletedCard then
    print('Failed to Delete Card.')
else
    print('Deleted Card.')
end

TrelloCards:GetCardByName(ListID, CardName)

Gets a Trello card's info from ListID and CardName.

ListID is the list's ID that the card is in, and the CardName is the name of the card you want to get.

Returns the card's information. If there is no card found with that name or an error occurs, it returns false.

local Trello = TrelloModule.new(TrelloKey, TrelloToken) -- Initializing the module
local TrelloLists = Trello.Lists -- Initializing the ListsAPI
local TrelloCards = Trello.Cards -- Initializing the CardsAPI

local ListID = TrelloLists:GetListID('BoardID', 'Example List')

local Card = TrelloCards:GetCardByName(ListID, 'Example Card')

if not Card then
    print('Failed to Get Card By Name.')
else
    print(Card.id)
end

TrelloCards:GetCardsInList(ListID)

Gets all cards in a list.

ListID is the ID of the list you want to get all the cards of.

Returns an array of all cards, or false if it fails.

local Trello = TrelloModule.new(TrelloKey, TrelloToken) -- Initializing the module
local TrelloLists = Trello.Lists -- Initializing the ListsAPI
local TrelloCards = Trello.Cards -- Initializing the CardsAPI

local ListID = TrelloLists:GetListID('BoardID', 'Example List')

local Cards = TrelloCards:GetCardsInList(ListID)

for _, object in pairs(Cards) do
    print(object.name)
    print(object.id)
end

Last updated