Skip to content

Commit 1640056

Browse files
author
Ted Spence
committed
First code commit
1 parent 64c9948 commit 1640056

File tree

97 files changed

+4282
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+4282
-0
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = [
3+
"setuptools>=42",
4+
"wheel"
5+
]
6+
build-backend = "setuptools.build_meta"

setup.cfg

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[metadata]
2+
name = lockstep-sdk
3+
version = 2021.39.690
4+
author = Lockstep
5+
author_email = [email protected]
6+
description = Lockstep Platform SDK for Python
7+
long_description = file: README.md
8+
long_description_content_type = text/markdown
9+
url = https://github.com/Lockstep-Network/lockstep-sdk-python
10+
project_urls =
11+
Bug Tracker = https://github.com/Lockstep-Network/lockstep-sdk-python/issues
12+
classifiers =
13+
Programming Language :: Python :: 3
14+
License :: OSI Approved :: MIT License
15+
Operating System :: OS Independent
16+
17+
[options]
18+
package_dir =
19+
= src
20+
packages = find:
21+
python_requires = >=3.6
22+
23+
[options.packages.find]
24+
where = src

src/LockstepApi.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#
2+
# Lockstep Software Development Kit for Python
3+
#
4+
# (c) 2021-2022 Lockstep, Inc.
5+
#
6+
# For the full copyright and license information, please view the LICENSE
7+
# file that was distributed with this source code.
8+
#
9+
# @author Ted Spence <[email protected]>
10+
# @copyright 2021-2022 Lockstep, Inc.
11+
# @version 2021.39
12+
# @link https://github.com/Lockstep-Network/lockstep-sdk-python
13+
#
14+
15+
from src.clients.ActivitiesClient import ActivitiesClient
16+
from src.clients.ApiKeysClient import ApiKeysClient
17+
from src.clients.AppEnrollmentsClient import AppEnrollmentsClient
18+
from src.clients.ApplicationsClient import ApplicationsClient
19+
from src.clients.AttachmentsClient import AttachmentsClient
20+
from src.clients.CodeDefinitionsClient import CodeDefinitionsClient
21+
from src.clients.CompaniesClient import CompaniesClient
22+
from src.clients.ContactsClient import ContactsClient
23+
from src.clients.CreditMemoAppliedClient import CreditMemoAppliedClient
24+
from src.clients.CurrenciesClient import CurrenciesClient
25+
from src.clients.CustomFieldDefinitionsClient import CustomFieldDefinitionsClient
26+
from src.clients.CustomFieldValuesClient import CustomFieldValuesClient
27+
from src.clients.DefinitionsClient import DefinitionsClient
28+
from src.clients.EmailsClient import EmailsClient
29+
from src.clients.InvoiceHistoryClient import InvoiceHistoryClient
30+
from src.clients.InvoicesClient import InvoicesClient
31+
from src.clients.LeadsClient import LeadsClient
32+
from src.clients.MigrationClient import MigrationClient
33+
from src.clients.NotesClient import NotesClient
34+
from src.clients.PaymentApplicationsClient import PaymentApplicationsClient
35+
from src.clients.PaymentsClient import PaymentsClient
36+
from src.clients.ProvisioningClient import ProvisioningClient
37+
from src.clients.ReportsClient import ReportsClient
38+
from src.clients.StatusClient import StatusClient
39+
from src.clients.SyncClient import SyncClient
40+
from src.clients.UserAccountsClient import UserAccountsClient
41+
from src.clients.UserRolesClient import UserRolesClient
42+
from src.models.LockstepResponse import LockstepResponse
43+
import requests
44+
import urllib.parse
45+
46+
class LockstepApi():
47+
48+
"""
49+
Construct a new LockstepApi client object
50+
"""
51+
def __init__(self, env: str):
52+
self.activities = ActivitiesClient(self)
53+
self.apiKeys = ApiKeysClient(self)
54+
self.appEnrollments = AppEnrollmentsClient(self)
55+
self.applications = ApplicationsClient(self)
56+
self.attachments = AttachmentsClient(self)
57+
self.codeDefinitions = CodeDefinitionsClient(self)
58+
self.companies = CompaniesClient(self)
59+
self.contacts = ContactsClient(self)
60+
self.creditMemoApplied = CreditMemoAppliedClient(self)
61+
self.currencies = CurrenciesClient(self)
62+
self.customFieldDefinitions = CustomFieldDefinitionsClient(self)
63+
self.customFieldValues = CustomFieldValuesClient(self)
64+
self.definitions = DefinitionsClient(self)
65+
self.emails = EmailsClient(self)
66+
self.invoiceHistory = InvoiceHistoryClient(self)
67+
self.invoices = InvoicesClient(self)
68+
self.leads = LeadsClient(self)
69+
self.migration = MigrationClient(self)
70+
self.notes = NotesClient(self)
71+
self.paymentApplications = PaymentApplicationsClient(self)
72+
self.payments = PaymentsClient(self)
73+
self.provisioning = ProvisioningClient(self)
74+
self.reports = ReportsClient(self)
75+
self.status = StatusClient(self)
76+
self.sync = SyncClient(self)
77+
self.userAccounts = UserAccountsClient(self)
78+
self.userRoles = UserRolesClient(self)
79+
if env == "sbx":
80+
self.serverUrl = "https://api.sbx.lockstep.io/"
81+
elif env == "prd":
82+
self.serverUrl = "https://api.lockstep.io/"
83+
else:
84+
self.serverUrl = env
85+
self.version = "2021.39"
86+
87+
"""
88+
Configure this API client to use API Key authentication
89+
"""
90+
def with_api_key(self, apiKey: str):
91+
self.apiKey = apiKey
92+
self.bearerToken = None
93+
94+
"""
95+
Configure this API client to use Bearer Token authentication
96+
"""
97+
def with_bearer_token(self, bearerToken: str):
98+
self.apiKey = None
99+
self.bearerToken = bearerToken
100+
101+
"""
102+
Send a request and parse the result
103+
"""
104+
def send_request(self, method: str, path: str, body: object, query_params: object) -> LockstepResponse:
105+
if query_params != None:
106+
url = urllib.parse.urljoin(self.serverUrl, path) + "?" + urllib.parse.urlencode(query_params)
107+
else:
108+
url = urllib.parse.urljoin(self.serverUrl, path)
109+
110+
if self.apiKey != None:
111+
headers = {"Accept": "application/json", "Api-Key": self.apiKey}
112+
elif self.bearerToken != None:
113+
headers = {"Accept": "application/json", "Authorization": "Bearer " + self.bearerToken}
114+
else:
115+
headers = {"Accept": "application/json"}
116+
117+
response = requests.request("GET", url, headers=headers)
118+
return response
119+

src/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from LockstepApi import LockstepApi

src/clients/ActivitiesClient.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#
2+
# Lockstep Software Development Kit for Python
3+
#
4+
# (c) 2021-2022 Lockstep, Inc.
5+
#
6+
# For the full copyright and license information, please view the LICENSE
7+
# file that was distributed with this source code.
8+
#
9+
# @author Ted Spence <[email protected]>
10+
# @copyright 2021-2022 Lockstep, Inc.
11+
# @version 2021.39
12+
# @link https://github.com/Lockstep-Network/lockstep-sdk-python
13+
#
14+
15+
from src.LockstepApi import LockstepApi
16+
from src.models.LockstepResponse import LockstepResponse
17+
from src.models.ActivityModel import ActivityModel
18+
19+
class ActivitiesClient:
20+
21+
def __init__(self, client: LockstepApi):
22+
self.client = client
23+
24+
# Retrieves the Activity specified by this unique identifier, optionally including nested data sets.
25+
#
26+
# An Activity contains information about work being done on a specific accounting task. You can use Activities to track information about who has been assigned a specific task, the current status of the task, the name and description given for the particular task, the priority of the task, and any amounts collected, paid, or credited for the task.
27+
#
28+
# @param id [uuid] The unique Lockstep Platform ID number of this Activity
29+
# @param include [string] To fetch additional data on this object, specify the list of elements to retrieve. Available collections: Attachments, CustomFields, and Notes
30+
def retrieve_activity(self, id: str, include: str) -> LockstepResponse:
31+
path = f"/api/v1/Activities/{id}"
32+
return self.client.send_request("GET", path, None, {id: str, include: str})
33+
34+
# Updates an activity that matches the specified id with the requested information.
35+
#
36+
# The PATCH method allows you to change specific values on the object while leaving other values alone. As input you should supply a list of field names and new values. If you do not provide the name of a field, that field will remain unchanged. This allows you to ensure that you are only updating the specific fields desired.
37+
#
38+
# An Activity contains information about work being done on a specific accounting task. You can use Activities to track information about who has been assigned a specific task, the current status of the task, the name and description given for the particular task, the priority of the task, and any amounts collected, paid, or credited for the task.
39+
#
40+
# @param id [uuid] The unique Lockstep Platform ID number of the Activity to update
41+
# @param body [object] A list of changes to apply to this Activity
42+
def update_activity(self, id: str, body: object) -> LockstepResponse:
43+
path = f"/api/v1/Activities/{id}"
44+
return self.client.send_request("PATCH", path, body, {id: str, body: object})
45+
46+
# Delete the Activity referred to by this unique identifier.
47+
#
48+
# An Activity contains information about work being done on a specific accounting task. You can use Activities to track information about who has been assigned a specific task, the current status of the task, the name and description given for the particular task, the priority of the task, and any amounts collected, paid, or credited for the task.
49+
#
50+
# @param id [uuid] The unique Lockstep Platform ID number of the Activity to delete
51+
def delete_activity(self, id: str) -> LockstepResponse:
52+
path = f"/api/v1/Activities/{id}"
53+
return self.client.send_request("DELETE", path, None, {id: str})
54+
55+
# Creates one or more activities from a given model.
56+
#
57+
# An Activity contains information about work being done on a specific accounting task. You can use Activities to track information about who has been assigned a specific task, the current status of the task, the name and description given for the particular task, the priority of the task, and any amounts collected, paid, or credited for the task.
58+
#
59+
# @param body [ActivityModel] The Activities to create
60+
def create_activities(self, body: list[ActivityModel]) -> LockstepResponse:
61+
path = f"/api/v1/Activities"
62+
return self.client.send_request("POST", path, body, {body: list[ActivityModel]})
63+
64+
# Queries Activities for this account using the specified filtering, sorting, nested fetch, and pagination rules requested.
65+
#
66+
# More information on querying can be found on the [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight) page on the Lockstep Developer website.
67+
#
68+
# An Activity contains information about work being done on a specific accounting task. You can use Activities to track information about who has been assigned a specific task, the current status of the task, the name and description given for the particular task, the priority of the task, and any amounts collected, paid, or credited for the task.
69+
#
70+
# @param filter [string] The filter for this query. See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
71+
# @param include [string] To fetch additional data on this object, specify the list of elements to retrieve. Available collections: Attachments, CustomFields, and Notes
72+
# @param order [string] The sort order for this query. See See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
73+
# @param pageSize [int32] The page size for results (default 200). See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
74+
# @param pageNumber [int32] The page number for results (default 0). See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
75+
def query_activities(self, filter: str, include: str, order: str, pageSize: int, pageNumber: int) -> LockstepResponse:
76+
path = f"/api/v1/Activities/query"
77+
return self.client.send_request("GET", path, None, {filter: str, include: str, order: str, pageSize: int, pageNumber: int})

src/clients/ApiKeysClient.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# Lockstep Software Development Kit for Python
3+
#
4+
# (c) 2021-2022 Lockstep, Inc.
5+
#
6+
# For the full copyright and license information, please view the LICENSE
7+
# file that was distributed with this source code.
8+
#
9+
# @author Ted Spence <[email protected]>
10+
# @copyright 2021-2022 Lockstep, Inc.
11+
# @version 2021.39
12+
# @link https://github.com/Lockstep-Network/lockstep-sdk-python
13+
#
14+
15+
from src.LockstepApi import LockstepApi
16+
from src.models.LockstepResponse import LockstepResponse
17+
from src.models.ApiKeyModel import ApiKeyModel
18+
19+
class ApiKeysClient:
20+
21+
def __init__(self, client: LockstepApi):
22+
self.client = client
23+
24+
# Retrieves the API Key with this identifier.
25+
#
26+
# An API Key is an authentication token that you may use with the Lockstep API. Because API Keys do not have an expiration date, they are well suited for unattended processes. Each API Key is associated with a user, and may be revoked to prevent it from accessing the Lockstep API. When you create an API Key, make sure to save the value in a secure location. Lockstep cannot retrieve an API Key once it is created. For more information, see [API Keys](https://developer.lockstep.io/docs/api-keys).
27+
#
28+
# @param id [uuid] The unique ID number of the API Key to retrieve
29+
# @param include [string] To fetch additional data on this object, specify the list of elements to retrieve. No collections are currently available but may be offered in the future.
30+
def retrieve_api_key(self, id: str, include: str) -> LockstepResponse:
31+
path = f"/api/v1/ApiKeys/{id}"
32+
return self.client.send_request("GET", path, None, {id: str, include: str})
33+
34+
# Immediately revokes the API Key with the specified id so it cannot be used to call the API. The Lockstep Platform guarantees that revocation will be received by all servers within five minutes of revocation. API calls made using this API key after the revocation will fail. A revoked API Key cannot be un-revoked and may be removed 60 days after revocation.
35+
#
36+
# An API Key is an authentication token that you may use with the Lockstep API. Because API Keys do not have an expiration date, they are well suited for unattended processes. Each API Key is associated with a user, and may be revoked to prevent it from accessing the Lockstep API. When you create an API Key, make sure to save the value in a secure location. Lockstep cannot retrieve an API Key once it is created. For more information, see [API Keys](https://developer.lockstep.io/docs/api-keys).
37+
#
38+
# @param id [uuid] The unique Lockstep Platform ID number of this API Key
39+
def revoke_api_key(self, id: str) -> LockstepResponse:
40+
path = f"/api/v1/ApiKeys/{id}"
41+
return self.client.send_request("DELETE", path, None, {id: str})
42+
43+
# Creates an API key with the specified name.
44+
#
45+
# An API Key is an authentication token that you may use with the Lockstep API. Because API Keys do not have an expiration date, they are well suited for unattended processes. Each API Key is associated with a user, and may be revoked to prevent it from accessing the Lockstep API. When you create an API Key, make sure to save the value in a secure location. Lockstep cannot retrieve an API Key once it is created. For more information, see [API Keys](https://developer.lockstep.io/docs/api-keys).
46+
#
47+
# @param body [ApiKeyModel] Metadata about the API Key to create.
48+
def create_api_key(self, body: ApiKeyModel) -> LockstepResponse:
49+
path = f"/api/v1/ApiKeys"
50+
return self.client.send_request("POST", path, body, {body: ApiKeyModel})
51+
52+
# Queries API Keys for this user using the specified filtering, sorting, nested fetch, and pagination rules requested. An API Key is an authentication token that you may use with the Lockstep API. Because API Keys do not have an expiration date, they are well suited for unattended processes. Each API Key is associated with a user, and may be revoked to prevent it from accessing the Lockstep API. When you create an API Key, make sure to save the value in a secure location. Lockstep cannot retrieve an API Key once it is created. For more information, see [API Keys](https://developer.lockstep.io/docs/api-keys).
53+
#
54+
# @param filter [string] The filter for this query. See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
55+
# @param include [string] To fetch additional data on this object, specify the list of elements to retrieve. No collections are currently available but may be offered in the future.
56+
# @param order [string] The sort order for this query. See See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
57+
# @param pageSize [int32] The page size for results (default 200). See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
58+
# @param pageNumber [int32] The page number for results (default 0). See [Searchlight Query Language](https://developer.lockstep.io/docs/querying-with-searchlight)
59+
def query_api_keys(self, filter: str, include: str, order: str, pageSize: int, pageNumber: int) -> LockstepResponse:
60+
path = f"/api/v1/ApiKeys/query"
61+
return self.client.send_request("GET", path, None, {filter: str, include: str, order: str, pageSize: int, pageNumber: int})

0 commit comments

Comments
 (0)