helpscout package¶
Subpackages¶
- helpscout.apis package
- helpscout.domain package
- helpscout.models package
- Submodules
- helpscout.models.address module
- helpscout.models.attachment module
- helpscout.models.attachment_data module
- helpscout.models.base_conversation module
- helpscout.models.chat module
- helpscout.models.conversation module
- helpscout.models.custom_field module
- helpscout.models.customer module
- helpscout.models.email module
- helpscout.models.field module
- helpscout.models.folder module
- helpscout.models.mailbox module
- helpscout.models.mailbox_ref module
- helpscout.models.option module
- helpscout.models.person module
- helpscout.models.phone module
- helpscout.models.rating module
- helpscout.models.search_conversation module
- helpscout.models.search_customer module
- helpscout.models.social_profile module
- helpscout.models.source module
- helpscout.models.tag module
- helpscout.models.thread module
- helpscout.models.user module
- helpscout.models.web_hook module
- helpscout.models.web_hook_event module
- helpscout.models.website module
- helpscout.models.workflow module
- Module contents
- helpscout.request_paginator package
- helpscout.tests package
- Submodules
- helpscout.tests.api_common module
- helpscout.tests.test_apis_conversations module
- helpscout.tests.test_apis_customers module
- helpscout.tests.test_apis_mailboxes module
- helpscout.tests.test_apis_tags module
- helpscout.tests.test_apis_teams module
- helpscout.tests.test_apis_users module
- helpscout.tests.test_auth_proxy module
- helpscout.tests.test_base_api module
- helpscout.tests.test_base_model module
- helpscout.tests.test_domain module
- helpscout.tests.test_exceptions module
- helpscout.tests.test_helpscout module
- helpscout.tests.test_helpscout_web_hook module
- helpscout.tests.test_helpscout_web_hook_event module
- helpscout.tests.test_model_person module
- helpscout.tests.test_request_paginator module
- Module contents
- helpscout.web_hook package
Submodules¶
helpscout.auth_proxy module¶
-
class
helpscout.auth_proxy.
AuthProxy
(session, proxy_class)[source]¶ Bases:
object
This object acts as a transparent authentication proxy for the API.
This is required because the API objects are naive of the authentication that is setup in
HelpScout
, and all of the API interface methods areclassmethods
because they are instantiating.-
METHOD_NO_PROXY
= ['auth_proxy']¶
-
auth_proxy
(method)[source]¶ Authentication proxy for API requests.
This is required because the API objects are naive of
HelpScout
, so they would otherwise be unauthenticated.Parameters: method (callable) – A method call that should be authenticated. It should accept a requests.Session
as its first parameter, which should be used for the actual API call.Returns: The results of the authenticated callable. Return type: mixed
-
helpscout.base_api module¶
-
class
helpscout.base_api.
BaseApi
[source]¶ Bases:
object
This is the API interface object to be implemented by API adapters.
It acts as a collection for the API object that it represents, passing through iteration to the API’s request paginator.
-
BASE_URI
¶ str – HelpScout API URI base.
-
paginator
¶ RequestPaginator – Object to use for producing an iterator representing multiple requests (API response pages). Created on init.
-
__object__
¶ helpscout.models.BaseModel – Model object that API represents.
-
BASE_URI
= 'https://api.helpscout.net/v1'
-
classmethod
create
(session, record, endpoint_override=None, out_type=None, **add_params)[source]¶ Create an object on HelpScout.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- record (helpscout.BaseModel) – The record to be created.
- endpoint_override (str, optional) – Override the default endpoint using this.
- out_type (helpscout.BaseModel, optional) – The type of record to output. This should be provided by child classes, by calling super.
- **add_params (mixed) – Add these to the request parameters.
Returns: Newly created record. Will be of the
Return type: helpscout.models.BaseModel
-
classmethod
delete
(session, record, endpoint_override=None, out_type=None)[source]¶ Delete a record.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- record (helpscout.BaseModel) – The record to be deleted.
- endpoint_override (str, optional) – Override the default endpoint using this.
- out_type (helpscout.BaseModel, optional) – The type of record to output. This should be provided by child classes, by calling super.
Returns: Nothing.
Return type: NoneType
-
classmethod
get
(session, record_id, endpoint_override=None)[source]¶ Return a specific record.
Parameters: Returns: - A record singleton, if existing. Otherwise
None
.
Return type:
-
static
get_search_domain
(queries)[source]¶ Helper method to create search domains if needed.
Parameters: queries (Domain or iter) – The queries for the domain. If a Domain
object is provided, it will simply be returned. Otherwise, aDomain
object will be generated from the complex queries. In this case, the queries should conform to the interface inhelpscout.domain.Domain.from_tuple()
.Returns: - Either the provided domain, or one created from
queries
.
Return type: Domain
-
classmethod
list
(session, endpoint_override=None, data=None)[source]¶ Return records in a mailbox.
Parameters: Returns: - Results
iterator.
Return type: RequestPaginator(output_type=helpscout.BaseModel)
-
classmethod
new_object
(data)[source]¶ Return a new object of the correct type from the data.
Parameters: data (dict) – Data dictionary that should be converted to an object. It can use either camelCase keys or snake_case. Returns: A model of the type declared in cls.__object__
.Return type: BaseModel
-
paginator
= None
-
classmethod
search
(session, queries, out_type)[source]¶ Search for a record given a domain.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- queries (helpscout.models.Domain or iter) – The queries for the
domain. If a
Domain
object is provided, it will simply be returned. Otherwise, aDomain
object will be generated from the complex queries. In this case, the queries should conform to the interface inhelpscout.domain.Domain.from_tuple()
. - out_type (helpscout.BaseModel) – The type of record to output. This should be provided by child classes, by calling super.
Returns: - Results
iterator of the
out_type
that is defined.
Return type: RequestPaginator(output_type=helpscout.BaseModel)
-
classmethod
update
(session, record)[source]¶ Update a record.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- record (helpscout.BaseModel) – The record to be updated.
Returns: Freshly updated record.
Return type:
-
helpscout.base_model module¶
-
class
helpscout.base_model.
BaseModel
(**kwargs)[source]¶ Bases:
properties.base.base.HasProperties
This is the model that all other models inherit from.
It provides some convenience functions, and the standardid
property.Required Properties:
- id (
Integer
): Unique identifier, an integer
-
classmethod
from_api
(**kwargs)[source]¶ Create a new instance from API arguments.
This will switch camelCase keys into snake_case for instantiation.
It will also identify any
Instance
orList
properties, and instantiate the proper objects using the values. The end result being a fully Objectified and Pythonified API response.Returns: Instantiated model using the API values. Return type: BaseModel
-
id
¶ Unique identifier
- id (
helpscout.exceptions module¶
-
exception
helpscout.exceptions.
HelpScoutException
(message)[source]¶ Bases:
exceptions.Exception
Base exception for HelpScout library errors.
-
exception
helpscout.exceptions.
HelpScoutRemoteException
(status_code, message)[source]¶ Bases:
helpscout.exceptions.HelpScoutException
Indicates that an error occurred when communicating with the remote.
-
exception
helpscout.exceptions.
HelpScoutSecurityException
(message)[source]¶ Bases:
helpscout.exceptions.HelpScoutException
Indicates a security error; probably by an invalid web hook signature.
-
exception
helpscout.exceptions.
HelpScoutValidationException
(message)[source]¶ Bases:
helpscout.exceptions.HelpScoutException
Indicates an error while validating user-supplied data.
Module contents¶
-
class
helpscout.
AuthProxy
(session, proxy_class)[source]¶ Bases:
object
This object acts as a transparent authentication proxy for the API.
This is required because the API objects are naive of the authentication that is setup in
HelpScout
, and all of the API interface methods areclassmethods
because they are instantiating.-
METHOD_NO_PROXY
= ['auth_proxy']¶
-
auth_proxy
(method)[source]¶ Authentication proxy for API requests.
This is required because the API objects are naive of
HelpScout
, so they would otherwise be unauthenticated.Parameters: method (callable) – A method call that should be authenticated. It should accept a requests.Session
as its first parameter, which should be used for the actual API call.Returns: The results of the authenticated callable. Return type: mixed
-
-
class
helpscout.
BaseApi
[source]¶ Bases:
object
This is the API interface object to be implemented by API adapters.
It acts as a collection for the API object that it represents, passing through iteration to the API’s request paginator.
-
BASE_URI
¶ str – HelpScout API URI base.
-
paginator
¶ RequestPaginator – Object to use for producing an iterator representing multiple requests (API response pages). Created on init.
-
__object__
¶ helpscout.models.BaseModel – Model object that API represents.
-
BASE_URI
= 'https://api.helpscout.net/v1'
-
classmethod
create
(session, record, endpoint_override=None, out_type=None, **add_params)[source]¶ Create an object on HelpScout.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- record (helpscout.BaseModel) – The record to be created.
- endpoint_override (str, optional) – Override the default endpoint using this.
- out_type (helpscout.BaseModel, optional) – The type of record to output. This should be provided by child classes, by calling super.
- **add_params (mixed) – Add these to the request parameters.
Returns: Newly created record. Will be of the
Return type: helpscout.models.BaseModel
-
classmethod
delete
(session, record, endpoint_override=None, out_type=None)[source]¶ Delete a record.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- record (helpscout.BaseModel) – The record to be deleted.
- endpoint_override (str, optional) – Override the default endpoint using this.
- out_type (helpscout.BaseModel, optional) – The type of record to output. This should be provided by child classes, by calling super.
Returns: Nothing.
Return type: NoneType
-
classmethod
get
(session, record_id, endpoint_override=None)[source]¶ Return a specific record.
Parameters: Returns: - A record singleton, if existing. Otherwise
None
.
Return type:
-
static
get_search_domain
(queries)[source]¶ Helper method to create search domains if needed.
Parameters: queries (Domain or iter) – The queries for the domain. If a Domain
object is provided, it will simply be returned. Otherwise, aDomain
object will be generated from the complex queries. In this case, the queries should conform to the interface inhelpscout.domain.Domain.from_tuple()
.Returns: - Either the provided domain, or one created from
queries
.
Return type: Domain
-
classmethod
list
(session, endpoint_override=None, data=None)[source]¶ Return records in a mailbox.
Parameters: Returns: - Results
iterator.
Return type: RequestPaginator(output_type=helpscout.BaseModel)
-
classmethod
new_object
(data)[source]¶ Return a new object of the correct type from the data.
Parameters: data (dict) – Data dictionary that should be converted to an object. It can use either camelCase keys or snake_case. Returns: A model of the type declared in cls.__object__
.Return type: BaseModel
-
paginator
= None
-
classmethod
search
(session, queries, out_type)[source]¶ Search for a record given a domain.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- queries (helpscout.models.Domain or iter) – The queries for the
domain. If a
Domain
object is provided, it will simply be returned. Otherwise, aDomain
object will be generated from the complex queries. In this case, the queries should conform to the interface inhelpscout.domain.Domain.from_tuple()
. - out_type (helpscout.BaseModel) – The type of record to output. This should be provided by child classes, by calling super.
Returns: - Results
iterator of the
out_type
that is defined.
Return type: RequestPaginator(output_type=helpscout.BaseModel)
-
classmethod
update
(session, record)[source]¶ Update a record.
Parameters: - session (requests.sessions.Session) – Authenticated session.
- record (helpscout.BaseModel) – The record to be updated.
Returns: Freshly updated record.
Return type:
-
-
class
helpscout.
BaseModel
(**kwargs)[source]¶ Bases:
properties.base.base.HasProperties
This is the model that all other models inherit from.
It provides some convenience functions, and the standardid
property.Required Properties:
- id (
Integer
): Unique identifier, an integer
-
classmethod
from_api
(**kwargs)[source]¶ Create a new instance from API arguments.
This will switch camelCase keys into snake_case for instantiation.
It will also identify any
Instance
orList
properties, and instantiate the proper objects using the values. The end result being a fully Objectified and Pythonified API response.Returns: Instantiated model using the API values. Return type: BaseModel
-
id
¶ Unique identifier
- id (
-
class
helpscout.
Domain
(queries=None, join_with='AND')[source]¶ Bases:
properties.base.base.HasProperties
This represents a full search query.
-
AND
= 'AND'¶
-
OR
= 'OR'¶
-
add_query
(query, join_with='AND')[source]¶ Join a new query to existing queries on the stack.
Parameters: - query (tuple or list or DomainCondition) – The condition for the
query. If a
DomainCondition
object is not provided, the input should conform to the interface defined infrom_tuple()
. - join_with (str) – The join string to apply, if other queries are already on the stack.
- query (tuple or list or DomainCondition) – The condition for the
query. If a
-
classmethod
from_tuple
(queries)[source]¶ Create a
Domain
given a set of complex query tuples.Parameters: queries (iter) – An iterator of complex queries. Each iteration should contain either:
- A data-set compatible with
add_query()
- A string to switch the join type
Example:
[('subject', 'Test1'), 'OR', ('subject', 'Test2')', ('subject', 'Test3')', ] # The above is equivalent to: # subject:'Test1' OR subject:'Test2' OR subject:'Test3' [('modified_at', datetime(2017, 01, 01)), ('status', 'active'), ] # The above is equivalent to: # modified_at:[2017-01-01T00:00:00Z TO *] # AND status:"active"
Returns: A domain representing the input queries. Return type: Domain - A data-set compatible with
-
-
class
helpscout.
HelpScout
(api_key)[source]¶ Bases:
object
This object is the primary point of interaction with HelpScout.
Properties will be set on this
HelpScout
instance that will mirror the class names of APIs in thehelpscout.api
module.These API classes are naive of authentication, so the actual properties set will be using the
AuthProxy
class, which will transparently inject authentication into the API requests while still allowing for a naive API object.This allows for the
HelpScout
instance to act as a container for all of the authenticated API objects.Examples:
from helpscout import HelpScout hs = HelpScout('api_key') for customer in hs.Customers.list(): print(customer)
-
Conversations
¶ helpscout.api.conversations.Conversations – Conversations API endpoint.
-
Customers
¶ helpscout.api.customers.Customers – Customers API endpoint.
-
Mailboxes
¶ helpscout.api.mailboxes.Mailboxes – Mailboxes API endpoint.
-
Tags
¶ helpscout.api.tags.Tags – Tags API endpoint.
-
Teams
¶ helpscout.api.teams.Teams – Teams API endpoint.
-
Users
¶ helpscout.api.users.Users – Users API endpoint.
-
WebHook
¶ helpscout.api.web_hook.WebHook – Web Hook API endpoint.
-
__apis__
¶ dict – References to all available APIs, keyed by class name.
-
-
class
helpscout.
HelpScoutWebHook
(**kwargs)[source]¶ Bases:
helpscout.models.web_hook.WebHook
This provides the ability to easily create & process web hook events.
Required Properties:
- events (
a list of StringChoice
): The events to subscribe to., a list (each item is any of “convo.agent.reply.created” (An agent replied to the conversation.), “convo.assigned” (Conversation was assigned.), “convo.created” (Conversation was created.), “convo.customer.reply.created” (The customer replied to the conversation.), “convo.deleted” (Conversation was deleted.), “convo.merged” (Conversation was merged.), “convo.moved” (Conversation was moved.), “convo.note.created” (A note was added to the conversation.), “convo.status” (Conversation status was updated.), “convo.tags” (Conversation tags were updated.), “customer.created” (A customer was created.), “satisfaction.ratings” (A rating was received.)) - helpscout (
object
): The authenticated HelpScout object. Used for create., an instance of object - id (
Integer
): Unique identifier, an integer - secret_key (
String
): A randomly-generated (by you) string of 40 characters or less used to create signatures for each webhook method. Help Scout uses this secret key to generate a signature for each webhook message. When the message is received at your callback URL, you can calculate a signature and compare to the one Help Scout sends. If the signatures match, you know it’s from Help Scout., a unicode string - url (
String
): The callback URL where Help Scout will post your webhook events. This is the script or location where you’ll handle the data received from Help Scout., a unicode string
-
helpscout
¶ The authenticated HelpScout object. Used for create.
-
receive
(event_type, signature, data_str)[source]¶ Receive a web hook for the event and signature.
Parameters: - event_type (str) – Name of the event that was received (from the
request
X-HelpScout-Event
header). - signature (str) – The signature that was received, which serves as
authentication (from the request
X-HelpScout-Signature
header). - data_str (str) – The raw data that was posted by HelpScout to the web hook. This must be the raw string, because if it is parsed with JSON it will lose its ordering and not pass signature validation.
Raises: helpscout.exceptions.HelpScoutSecurityException
– If an invalid signature is provided, andraise_if_invalid
isTrue
.Returns: - The authenticated web hook
request.
Return type: - event_type (str) – Name of the event that was received (from the
request
- events (