@robinpath/freshbooks
0.1.1Node.jsPublicFreshBooks module for RobinPath.
FreshBooks
FreshBooks module for RobinPath.
Package: @robinpath/freshbooks | Category: Finance | Type: Integration
Authentication
freshbooks.setCredentials "your-credentials"
Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.
Use Cases
Use the freshbooks module when you need to:
- listClients -- Use
freshbooks.listClientsto perform this operation - getClient -- Use
freshbooks.getClientto perform this operation - createClient -- Use
freshbooks.createClientto perform this operation - updateClient -- Use
freshbooks.updateClientto perform this operation - listInvoices -- Use
freshbooks.listInvoicesto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
setCredentials | Configure freshbooks credentials. | object |
listClients | listClients | object |
getClient | getClient | object |
createClient | createClient | object |
updateClient | updateClient | object |
listInvoices | listInvoices | object |
getInvoice | getInvoice | object |
createInvoice | createInvoice | object |
updateInvoice | updateInvoice | object |
sendInvoice | sendInvoice | object |
listExpenses | listExpenses | object |
getExpense | getExpense | object |
createExpense | createExpense | object |
listTimeEntries | listTimeEntries | object |
createTimeEntry | createTimeEntry | object |
listPayments | listPayments | object |
createPayment | createPayment | object |
getUser | getUser | object |
getAccount | getAccount | object |
Functions
setCredentials
Configure freshbooks credentials.
Module: freshbooks | Returns: object -- API response.
freshbooks.setCredentials
| Parameter | Type | Required | Description |
|---|---|---|---|
accessToken | string | Yes | accessToken |
accountId | string | Yes | accountId |
listClients
listClients
Module: freshbooks | Returns: object -- API response.
freshbooks.listClients
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getClient
getClient
Module: freshbooks | Returns: object -- API response.
freshbooks.getClient
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createClient
createClient
Module: freshbooks | Returns: object -- API response.
freshbooks.createClient
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateClient
updateClient
Module: freshbooks | Returns: object -- API response.
freshbooks.updateClient
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listInvoices
listInvoices
Module: freshbooks | Returns: object -- API response.
freshbooks.listInvoices
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getInvoice
getInvoice
Module: freshbooks | Returns: object -- API response.
freshbooks.getInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createInvoice
createInvoice
Module: freshbooks | Returns: object -- API response.
freshbooks.createInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
updateInvoice
updateInvoice
Module: freshbooks | Returns: object -- API response.
freshbooks.updateInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
sendInvoice
sendInvoice
Module: freshbooks | Returns: object -- API response.
freshbooks.sendInvoice
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listExpenses
listExpenses
Module: freshbooks | Returns: object -- API response.
freshbooks.listExpenses
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getExpense
getExpense
Module: freshbooks | Returns: object -- API response.
freshbooks.getExpense
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createExpense
createExpense
Module: freshbooks | Returns: object -- API response.
freshbooks.createExpense
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listTimeEntries
listTimeEntries
Module: freshbooks | Returns: object -- API response.
freshbooks.listTimeEntries
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createTimeEntry
createTimeEntry
Module: freshbooks | Returns: object -- API response.
freshbooks.createTimeEntry
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
listPayments
listPayments
Module: freshbooks | Returns: object -- API response.
freshbooks.listPayments
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
createPayment
createPayment
Module: freshbooks | Returns: object -- API response.
freshbooks.createPayment
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getUser
getUser
Module: freshbooks | Returns: object -- API response.
freshbooks.getUser
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
getAccount
getAccount
Module: freshbooks | Returns: object -- API response.
freshbooks.getAccount
| Parameter | Type | Required | Description |
|---|---|---|---|
input | string | No | Input parameter |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
Freshbooks API error (${res.status}): ${t} | Check the error message for details |
freshbooks.setCredentials requires accessToken, accountId. | Check the error message for details |
freshbooks.updateClient requires an ID. | Check the error message for details |
freshbooks.updateInvoice requires an ID. | Check the error message for details |
Freshbooks: "..." not configured. Call freshbooks.setCredentials first. | Check the error message for details |
@desc "List clients and validate result"
do
set $result as freshbooks.listClients
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. List and iterate Clients
Retrieve all items and loop through them.
@desc "Setup authentication"
do
freshbooks.setCredentials $token
enddo
@desc "List clients and iterate results"
do
set $result as freshbooks.listClients
each $item in $result
print $item
end
enddo
2. Create a new item with createClient
Create a new resource and capture the result.
@desc "Setup authentication"
do
freshbooks.setCredentials $token
enddo
@desc "Create client"
do
set $result as freshbooks.createClient
print "Created: " + $result
enddo
3. Create and update workflow
Create an item and then update it.
@desc "Setup authentication"
do
freshbooks.setCredentials $token
enddo
@desc "Create client and update client"
do
set $created as freshbooks.createClient
# Update the created item
freshbooks.updateClient
enddo
4. Check before creating
List existing items and only create if needed.
@desc "Setup authentication"
do
freshbooks.setCredentials $token
enddo
@desc "List clients and create client"
do
set $existing as freshbooks.listClients
if $existing == null
freshbooks.createClient
print "Item created"
else
print "Item already exists"
end
enddo
5. Multi-step FreshBooks workflow
Chain multiple freshbooks operations together.
@desc "Setup authentication"
do
freshbooks.setCredentials $token
enddo
@desc "List clients, get client, and more"
do
set $r_listClients as freshbooks.listClients
set $r_getClient as freshbooks.getClient
set $r_createClient as freshbooks.createClient
print "All operations complete"
enddo
6. Safe listClients with validation
Check results before proceeding.
@desc "Setup authentication"
do
freshbooks.setCredentials $token
enddo
@desc "List clients and validate result"
do
set $result as freshbooks.listClients
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- quickbooks -- QuickBooks module for complementary functionality
- xero -- Xero module for complementary functionality
- invoice -- Invoice module for complementary functionality
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
$ robinpath add @robinpath/freshbooks
