Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcelog/elixir_freshbooks
An Elixir client for the FreshBooks API
https://github.com/marcelog/elixir_freshbooks
Last synced: about 11 hours ago
JSON representation
An Elixir client for the FreshBooks API
- Host: GitHub
- URL: https://github.com/marcelog/elixir_freshbooks
- Owner: marcelog
- License: apache-2.0
- Created: 2015-10-30T13:03:24.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-29T02:03:36.000Z (almost 8 years ago)
- Last Synced: 2024-04-25T10:21:54.680Z (8 months ago)
- Language: Elixir
- Size: 33.2 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/marcelog/elixir_freshbooks.svg)](https://travis-ci.org/marcelog/elixir_freshbooks)
# ElixirFreshbooks
An [Elixir](http://elixir-lang.org/) client for the [FreshBooks](http://freshbooks.com) API.
This is a work *in progress*. This means that there are a limited set of features available (i.e:
the ones I need right now :)) so pull requests to add new features are **highly** appreciated :)----
# Using it with Mix
To use it in your Mix projects, first add it as a dependency:
```elixir
def deps do
[{:elixir_freshbooks, "~> 0.0.7"}]
end
```
Then run mix deps.get to install it.----
# Configuring
In your config.exs, setup the following section:```elixir
config :elixir_freshbooks,
url: "https://sample.freshbooks.com/api/2.1/xml-in",
token: "token"
```In your freshbooks account you should find both values.
----
# Documentation
## Clients
Clients are used via the [Client](https://github.com/marcelog/elixir_freshbooks/blob/master/lib/elixir_freshbooks/client.ex) module.
```elixir
alias ElixirFreshbooks.Client, as: C
```### Creating
```elixir
> C.create(
"first_name", "last_name", "organization", "[email protected]",
"username", "password"
)
%ElixirFreshbooks.Client{
email: "[email protected]",
first_name: "first_name",
id: 4422,
last_name: "last_name",
organization: "organization",
username: "username",
password: "password"
}
```Both `username` and `password` are optional arguments.
### Updating
```elixir
> C.update %ElixirFreshbooks.Client{id: 4422, password: "new_password"}
:ok
```## Invoices
Invoices are used via the [Invoice](https://github.com/marcelog/elixir_freshbooks/blob/master/lib/elixir_freshbooks/invoice.ex) module.
```elixir
alias ElixirFreshbooks.Invoice, as: I
alias ElixirFreshbooks.InvoiceLine, as: L
```### Creating
```elixir
# Create a new invoice for the client_id 4422, add one line with the given
# name, description, unit_cost, and quantity.
> I.create 4422, "sent", ["note1", "note2", "note3"], [
L.new("Line Name", "Line Description", 2, 4)
]
%ElixirFreshbooks.Invoice{
client_id: 4422,
id: 9932,
lines: [
%ElixirFreshbooks.InvoiceLine{
description: "Line Description",
name: "Line Name",
quantity: 4,
type: "item",
unit_cost: 2
}
],
notes: ["note1", "note2", "note3"],
status: "sent"
}
```### Adding taxes
```elixir
# Taxes are in percent only, not absolute values.
> item = L.new("Line Name", "Line Description", 2, 4) |>
L.tax("tax name", 7) |>
L.tax("another tax", 3)
> I.create 4422, "sent", ["note1", "note2", "note3"], [item]```
## Payments
Payments are used via the [Payment](https://github.com/marcelog/elixir_freshbooks/blob/master/lib/elixir_freshbooks/payment.ex) module.
```elixir
alias ElixirFreshbooks.Payment, as: P
```### Creating
```elixir
> P.create 889, 10.50, "Credit Card", ["note1", "note2", "note3"]
%ElixirFreshbooks.Payment{
invoice_id: 889,
amount: 10.50,
id: 778,
notes: ["note1", "note2", "note3"],
type: "Credit Card"
}
```## Expenses
Expenses are used via the [Expense](https://github.com/marcelog/elixir_freshbooks/blob/master/lib/elixir_freshbooks/expense.ex) module.
```elixir
alias ElixirFreshbooks.Expense, as: E
```### Creating
```elixir
> E.create 1, 1994955, 1.23, "test vendor", ["note1", "note2"]
%ElixirFreshbooks.Expense{
amount: 1.23,
category_id: 1994955,
client_id: nil,
date: "2015-12-06",
id: 320343,
notes: ["note1", "note2"],
project_id: nil,
staff_id: 1,
vendor: "test vendor"
}
```
----# License
The source code is released under Apache 2 License.Check [LICENSE](https://github.com/marcelog/elixir_freshbooks/blob/master/LICENSE) file for more information.