8000 GitHub - commonledger/sdk-python: The Common Ledger Python SDK
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

commonledger/sdk-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sdk-ruby

Official CommonLedger API library client for ruby

This library is generated by alpaca

Installation

Make sure you have pip installed

$ pip install commonledger-sdk

Versions

Works with [ 2.6 / 2.7 / 3.2 / 3.3 ]

Usage

import common_ledger

# Then we instantiate a client (as shown below)

Build a client

Without any authentication
client = common_ledger.Client()

# If you need to send options
client = common_ledger.Client({}, options)
Basic authentication
auth = { 'username': 'pksunkara', 'password': 'password' }

client = common_ledger.Client(auth, options)
Oauth acess token
client = common_ledger.Client('1a2b3', options)
Oauth client secret
auth = { 'client_id': '09a8b7', 'client_secret': '1a2b3' }

client = common_ledger.Client(auth, options)

Response information

response = client.klass('args').method('args')

response.body
# >>> 'Hello world!'

response.code
# >>> 200

response.headers
# >>> {'content-type': 'text/html'}
HTML response
response.body
# >>> 'The username is pksunkara!'
JSON response
response.body
# >>> {'user': 'pksunkara'}

Request body information

RAW request
body = 'username=pksunkara'
FORM request
body = {'user': 'pksunkara'}
JSON request
body = {'user': 'pksunkara'}

Client Options

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

Method Options

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

Authentication api

Using OAuth 2.0 to connect to Common Ledger

auth = client.auth()
Requesting a Token (POST /auth/token)

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)

Accounts api

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")
Add account (POST /core.account/add)

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)
View account (GET /core.account/view/:account_id)
response = accounts.view(options)
Update account (POST /core.account/update/:account_id)

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)
Delete account (GET /core.account/delete/:account_id)

Deletes an account from the chart of accounts

response = accounts.delete(options)

Tax api

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 (POST /core.tax/add)

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 (GET /core.tax/view/:tax_id)

View a tax rate

response = tax.view(options)
Update (POST /core.tax/update/:tax_id)

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)

Journals api

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 (POST /core.journal/add)

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 (GET /core.journal/view/:journal_id)

View a journal entry

response = journals.view(options)
Add (POST /core.journal/update/:journal_id)

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)

Contributors

Here is a list of [Contributors]((https://github.org/commonledger/sdk-python/contributors)

TODO

License

MIT

Bug Reports

Report here.

Contact

Common Ledger (api@commonledger.com)

About

The Common Ledger Python SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0