Skip to content

Commit da18e4e

Browse files
committed
Add README with example usage
1 parent f324105 commit da18e4e

File tree

2 files changed

+79
-3
lines changed

2 files changed

+79
-3
lines changed

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Python Manager API
2+
3+
This is a Python module to access the API provided by Manager accounting
4+
software.
5+
6+
## WARNING
7+
8+
Use at your own risk! Always test API usage on a test business first!
9+
Not responsible for any data loss or other problems (see license).
10+
11+
## Description
12+
13+
There is no official API documentation, but the API is meant to be self
14+
documenting by browsing `/api` on a Manager server.
15+
16+
This module design is meant to automate much of the work, eliminate the
17+
need to worry about GUID, and perform basic type checking and validation.
18+
19+
## Installation
20+
21+
`pip install manager_api`
22+
23+
## Configuration
24+
25+
To open a business, you need the server URL, username, password, and the
26+
business name. It is recommended to create a separate user with suitable
27+
permissions for the API access.
28+
29+
If using the local (personal) edition, first use the trial copy of the
30+
server edition to create a user, then use http://localhost:55667 as the
31+
server URL.
32+
33+
## Example Usage
34+
35+
```
36+
#!/usr/bin/env python3
37+
# -*- coding: utf-8 -*-
38+
39+
from manager_api import Business
40+
41+
42+
# Open the business. NOTE: Always use a test business first!
43+
business = Business("http://localhost:55667", "apiuser", "password", "Test Business")
44+
45+
# Retrieve the 10 most recent payments and display source account, payee, and total amount.
46+
payments = business.Payment.list()[:10]
47+
for p in payments:
48+
p.read()
49+
p.PaidFrom.read()
50+
if p.Payee == "Customer":
51+
p.Customer.read()
52+
p_to = p.Customer.Name
53+
elif p.Payee == "Supplier":
54+
p.Supplier.read()
55+
p_to = p.Supplier.Name
56+
else:
57+
p_to = p.Contact
58+
p_amt = sum([l.Amount for l in p.Lines])
59+
print(f"{p.Key} : {p_amt} : {p.PaidFrom.Name} -> {p_to}")
60+
61+
# Create a copy of the first payment with a line item doubled.
62+
print("Creating new payment")
63+
p = payments[0]
64+
p.Key = None
65+
p.Lines[0].Amount *= 2
66+
p.Reference = "Test"
67+
p.create()
68+
p_amt = sum([l.Amount for l in p.Lines])
69+
print(f"{p.Key} : {p_amt} : {p.PaidFrom.Name} -> {p_to}")
70+
71+
print("Updating the payment")
72+
p.Reference = "Updated"
73+
p.update()
74+
75+
print("Deleting the payment")
76+
p.delete()
77+
```

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='manager-api',
5-
description='Publishes your Lektor site to Google App Engine.',
5+
description='Python module to access the API provided by Manager accounting software ',
66
url='https://github.com/isotherm/python-manager-api/',
77
version='0.1',
88
author=u'Kirk Meyer',
@@ -13,8 +13,7 @@
1313
'manager_api'
1414
],
1515
install_requires=[
16-
'pydantic',
17-
'uplink',
16+
'pydantic==1.10.4',
1817
],
1918
classifiers=[
2019
'Development Status :: 3 - Alpha',

0 commit comments

Comments
 (0)