Official CommonLedger API library client for ruby
This library is generated by alpaca
Make sure you have pip installed
$ pip install commonledger-sdk
Works with [ 2.6 / 2.7 / 3.2 / 3.3 ]
import common_ledger
# Then we instantiate a client (as shown below)
client = common_ledger.Client()
# If you need to send options
client = common_ledger.Client({}, options)
auth = { 'username': 'pksunkara', 'password': 'password' }
client = common_ledger.Client(auth, options)
client = common_ledger.Client('1a2b3', options)
auth = { 'client_id': '09a8b7', 'client_secret': '1a2b3' }
client = common_ledger.Client(auth, options)
response = client.klass('args').method('args')
response.body
# >>> 'Hello world!'
response.code
# >>> 200
response.headers
# >>> {'content-type': 'text/html'}
response.body
# >>> 'The username is pksunkara!'
response.body
# >>> {'user': 'pksunkara'}
body = 'username=pksunkara'
body = {'user': 'pksunkara'}
body = {'user': 'pksunkara'}
The following options are available while instantiating a client:
- base: Base url for the api
- api_version: Default version of the api (to be used in url)
- user_agent: Default user-agent for all requests
- headers: Default headers for all requests
- request_type: Default format of the request body
The following options are available while calling a method of an api:
- api_version: Version of the api (to be used in url)
- headers: Headers for the request
- query: Query parameters for the url
- body: Body of the request
- request_type: Format of the request body
Using OAuth 2.0 to connect to Common Ledger
auth = client.auth()
After redirecting to /auth/authorise this endpoint will return an access token
The following arguments are required:
- client_id: The application client_id
- client_secret: The application client_secret
- code: The code from the authorise request
- redirect_url: The redirect_uri used to set up the application
- grant_type: Either 'authorization_code' when requesting an access token, or 'refresh_token' when refreshing an old access token
response = auth.token("2a7b7aaa9f05280218629fa5325eee93f448ae62", "f448ae1dcac1bb3f82f460e1b86b639c28ede333", "d6b5cdf4650d52450c90fa6dc5d527652250a159", "http://example.com/oauth_callback", "authorization_code", options)
Manages data relating to the Chart of Accounts
The following arguments are required:
- account_id: The account UUID
accounts = client.accounts("75e6a24c-772b-11e3-8005-6163636f756e")
Creates a new account in the chart of accounts
The following arguments are required:
- organisation_id: The organisation the account belongs to
- account_number: The account code
- name: The account name
- classification: The account classification
- type: The type of classification for the account
- tax: The tax code that applies to the account
- currency: The currency code that applies to the account
response = accounts.add("863f2548-7284-11e3-9710-6163636f756e", "200", "Business Tax Account 1", "ASSET", "BANK", "NONE", "NZD", options)
response = accounts.view(options)
Updates an existing account in the chart of accounts
The following arguments are required:
- organisation_id: The organisation the account belongs to
- account_number: The account code
- name: The account name
- classification: The account classification
- type: The type of classification for the account
- tax: The tax code that applies to the account
- currency: The currency code that applies to the account
response = accounts.update("863f2548-7284-11e3-9710-6163636f756e", "200", "Business Tax Account 1", "ASSET", "BANK", "NONE", "NZD", options)
Deletes an account from the chart of accounts
response = accounts.delete(options)
Collection of different tax rates and their codes
The following arguments are required:
- tax_id: The tax UUID
tax = client.tax("9136fee6-02da-426d-aa01-2b50c17b8a2f")
Add a new tax rate
The following arguments are required:
- organisation_id: The UUID of the organisation this tax rate belongs to
- name: The name of this tax rate
- type: The tax type (tax code)
- display_rate: The rate to display this tax at
- effective_rate: The rate that gets applied for this tax
response = tax.add("863f2548-7284-11e3-9710-6163636f756e", "15% GST on Income", "OUTPUT2", 15, 15, options)
View a tax rate
response = tax.view(options)
Update an existing tax rate
The following arguments are required:
- organisation_id: The UUID of the organisation this tax rate belongs to
- name: The name of this tax rate
- type: The tax type (tax code)
- display_rate: The rate to display this tax at
- effective_rate: The rate that gets applied for this tax
response = tax.update("863f2548-7284-11e3-9710-6163636f756e", "15% GST on Income", "OUTPUT2", 15, 15, options)
Manages journal entries and journal lines
The following arguments are required:
- jo 78A5 urnal_id: The journal entry UUID
journals = client.journals("76afff0a-7368-11e3-9c55-6a6f75726e61")
Add a new journal entry
The following arguments are required:
- organisation_id: The UUID of the organisation this journal entry belongs to
- journal_number: The journal number this journal entry belongs to
- journal_type: The type of journal entry this is
- datetime: The timestamp this journal entry was recorded
- notes: Any notes this journal entry has
- lines: An array of journal lines that make up this journal entry
response = journals.add("863f2548-7284-11e3-9710-6163636f756e", "200", "", "2012-09-11T00:00:00+12:00", "Common Ledger is the best!", "...", options)
View a journal entry
response = journals.view(options)
Add a new journal entry
The following arguments are required:
- organisation_id: The UUID of the organisation this journal entry belongs to
- journal_number: The journal number this journal entry belongs to
- journal_type: The type of journal entry this is
- datetime: The timestamp this journal entry was recorded
- notes: Any notes this journal entry has
- lines: An array of journal lines that make up this journal entry
response = journals.update("863f2548-7284-11e3-9710-6163636f756e", "200", "", "2012-09-11T00:00:00+12:00", "Common Ledger is the best!", "...", options)
Here is a list of [Contributors]((https://github.org/commonledger/sdk-python/contributors)
MIT
Report here.
Common Ledger (api@commonledger.com)