The Profit package is a Python package designed to retrieve specific GetConnectors defined by the user in their AFAS environment. It utilizes the SalureConnect package to securely retrieve the necessary credential information.
The Profit package can be installed by simply importing it into your Python project:
pythonCopy codefrom profit import GetConnector
To use the Profit package, you'll first need to create an instance of the GetConnector
class. Then, you can use the various methods provided by the class to interact with your AFAS environment.
- pythonCopy code
from profit import GetConnector
# Initialize the GetConnector class
connector = GetConnector(label='your_label', test_environment=False, debug=False)
# Retrieve metadata for a specific connector
metadata = connector.get_metadata(connector='your_connector')
# Retrieve data for a specific connector
data = connector.get_data(connector='your_connector', fields='field1,field2', values='value1,value2', operators='1,1', orderbyfields='orderby_field')
Initializes a new instance of the GetConnector
class, which inherits from the SalureConnect
class.
label
: The label of the credential to be used.test_environment
: Optional. Set to True
if you're working with a test environment. Defaults to False
.debug
: Optional. Set to True
to enable debugging output. Defaults to False
.Retrieves the metadata for a specific GetConnector or all GetConnectors if no connector is specified.
connector
: Optional. The name of the GetConnector for which to retrieve metadata. Defaults to None
.Retrieves data for a specific connector using filters and optional orderbyfields.
connector
: The name of the connector to retrieve data from.fields
: Optional. A comma-separated string of field IDs for the filter.values
: Optional. A comma-separated string of filter values.operators
: Optional. A comma-separated string of filter operator types. See method documentation for a full list of available operators.orderbyfields
: Optional. A string of fields to order the result by. If you're using skip and take, it's highly recommended to specify orderbyfields to speed up the request.Retrieves data for a specific connector using complex combined filters and optional orderbyfields.
connector
: The name of the connector to retrieve data from.fields
: A list of filter blocks, where each list item is one filter block.values
: A list of filter values, where each list item corresponds to one filter block.operators
: A list of filter operator types, where each list item corresponds to one filter block. See method documentation for a full list of available operatorsorderbyfields
: Optional. A string of fields to order the result by. If you're using skip and take, it's highly recommended to specify orderbyfields to speed up the request.Retrieves the base64-encoded binary data of a dossier attachment as part of the response object's filedata
key.
dossieritem_id
: The ID of the dossier item.dossieritem_guid
: The GUID of the dossier item.You can process the base64-encoded binary data by decoding it and writing it to a file like this:
- pythonCopy code
import base64
# Retrieve the attachment data
response = connector.get_dossier_attachments(dossieritem_id='your_dossieritem_id', dossieritem_guid='your_dossieritem_guid')
# Decode the base64-encoded binary data
blob = base64.b64decode(response.json()['filedata'])
# Write the decoded data to a file
with open('your_file_directory/filename.ext', 'wb') as f:
f.write(blob)
f.write(blob)