PerformLine Python Client Library¶
Contents:
Quick Start¶
This page will offer a quick overview for how to get started with using this library, from installation to basic usage.
Installation¶
This library is made available for installation via the PyPi public Python package repository (https://pypi.python.org/pypi/performline/). To install it on your machine, run:
1 | pip install performline
|
This will retrieve the latest version of the Python module and install it. This will also install
a useful command line utility called performline
. You can read more about using this command by
running performline --help
.
Basic Usage: Printing all Brands and Campaigns¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from performline.client import Client
import json
client = Client("YOUR_API_KEY")
# list all brands
for brand in client.brands():
print("Brand: {} (id: {})".format(brand.name, brand.id))
# list all campaigns in the current brand
for campaign in brand.campaigns():
print(" Campaign: {}".format(campaign.name))
# output the full content of each item in the current campaign
for item in campaign.items():
print(json.dumps(item._data, indent=4))
|
Developer Guide¶
This guide is designed to provide an overview of the features and functionality that the PerformLine Python Client Library offers. You can find additional details by choosing from the topics below:
Using the Client and Retrieving Compliance Data¶
Overview¶
Using the PerformMatch Compliance API is fairly straightforward. The API is accessed by way of a
Client()
instance created with your API token (provided by PerformLine
Support). The client instance exposes methods that allow you to access the various data associated
with your account. To explore these methods, see the second below detailing what can be accessed for
each product that we offer.
Products & Data¶
The methods in the following classes are the primary means of accessing product-specific data and,
in general, using the API. These classes are _mixins_, so each of the methods are available on an
instance of Client()
.
Mix-in Classes¶
Common Account Data¶
Client
Methods¶-
class
performline.products.common.api.
CommonClientMethods
[source]¶ Methods for retrieving data common to all products.
-
brands
(id=None, limit=None, offset=None, create_date=None)[source]¶ Retrieve one or more brands associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single brand by the given ID. Otherwise, return all brands. Returns: An instance of Brand
ifid
is not None representing the brand with that ID. Otherwise, retrieve a list ofBrand
instances of all brands associated with the account.Raises: See request()
-
campaigns
(id=None, limit=None, offset=None, brand=None)[source]¶ Retrieve one or more campaigns associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single campaign by the given ID. Otherwise, return all campaigns. Returns: An instance of Campaign
ifid
is not None representing the campaign with that ID. Otherwise, retrieve a list ofCampaign
instances of all campaigns associated with the account.Raises: See request()
-
items
(id=None, limit=None, offset=None, brand=None, campaign=None)[source]¶ Retrieve one or more scorable items associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single item by the given ID. Otherwise, return all items. Returns: An instance of Item
ifid
is not None representing the item with that ID. Otherwise, retrieve a list ofItem
instances of all items associated with the account.Raises: See request()
-
remediation_statuses
()[source]¶ Retrieve all available remediation statuses available in the Performline platform. :returns: An instance of
RemediationStatuses
,which has a property returning a list of strings representing the availareturn RemediationStatus.get()
-
rules
(id=None, limit=None, offset=None)[source]¶ Retrieve one or more rules associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single rule by the given ID. Otherwise, return all rules. Returns: An instance of Rule
ifid
is not None representing the rule with that ID. Otherwise, retrieve a list ofRule
instances of all rules associated with the account.Raises: See request()
-
trafficsources
(id=None, limit=None, offset=None)[source]¶ Retrieve one or more traffic sources associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single traffic source by the given ID. Otherwise, return all traffic sources. Returns: An instance of TrafficSource
ifid
is not None representing the traffic source with that ID. Otherwise, retrieve a list ofTrafficSource
instances of all traffic sources associated with the account.Raises: See request()
-
Models representing common API objects
-
class
performline.products.common.models.
Brand
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving data from and working with an individual brand.
-
class
performline.products.common.models.
BrandRules
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving data rules for a specific brand.
-
class
performline.products.common.models.
Campaign
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving data from and working with an individual campaign.
-
class
performline.products.common.models.
CampaignRules
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving data rules for a specific campaign.
-
class
performline.products.common.models.
Item
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving data from and working with scorable content, regardless of product.
-
class
performline.products.common.models.
RemediationStatus
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving all available remediation statuses in the platform.
-
class
performline.products.common.models.
Rule
(client, data=None, metadata={}, rest_root=None, primary_key=None, secondary_key=None)[source]¶ An object for retrieving data from and working with an individual rule.
Web Pages¶
Client
Methods¶-
class
performline.products.web.api.
WebClientMethods
[source]¶ Methods for retrieving data from the Web product
-
webpages
(id=None, limit=None, offset=None, brand=None, campaign=None)[source]¶ Retrieve one or more web pages registered for processing on an account.
Parameters: id (int, optional) – If specified, retrieve a single page by the given ID. Otherwise, return all pages. Returns: An instance of WebPage
ifid
is not None representing the page with that ID. Otherwise, retrieve a list ofWebPage
instances of all pages associated with the account.Raises: See request()
-
Call Center Processing¶
Client
Methods¶-
class
performline.products.callcenter.api.
CallCenterClientMethods
[source]¶ Methods for retrieving data from the Call Center product
-
calls
(id=None, limit=None, offset=None, brand=None, campaign=None)[source]¶ Retrieve one or more calls associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single call by the given ID. Otherwise, return all calls. Returns: An instance of Call
ifid
is not None representing the call with that ID. Otherwise, retrieve a list ofCall
instances of all calls associated with the account.Raises: See request()
-
Chat Processing¶
Client
Methods¶-
class
performline.products.chatscout.api.
ChatScoutClientMethods
[source]¶ Methods for retrieving data from the ChatScout product
-
chats
(id=None, limit=None, offset=None, brand=None, campaign=None)[source]¶ Retrieve one or more chats associated with an account.
Parameters: id (int, optional) – If specified, retrieve a single chat by the given ID. Otherwise, return all chats. Returns: An instance of Chat
ifid
is not None representing the chat with that ID. Otherwise, retrieve a list ofChat
instances of all chats associated with the account.Raises: See request()
-
Client Class Reference¶
-
class
performline.client.
Client
(token, *args, **kwargs)[source]¶ PerformLine API Client
-
wrap_response
(response, model, flat=False)[source]¶ Takes a SuccessResponse and returns the results as instances of the given model.
Parameters: - response (SuccessResponse) – A SuccessResponse object containing the data to be wrapped.
- model (RestModel) – A subclass of RestModel that should be used
- creating instances for each result in the response. (when) –
- flat (bool, optional) – Whether single-element lists should return just that element instead of the list itself.
Returns: If
response
contains zero results, returns None.If
response
has one element andflat
equals True, return the first element as an instance of typemodel
.In all other cases, return a list of instances of type
model
.
-