helpscout.domain package

Module contents

class helpscout.domain.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 in from_tuple().
  • join_with (str) – The join string to apply, if other queries are already on the stack.
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
class helpscout.domain.DomainCondition(field, value, **kwargs)[source]

Bases: properties.base.base.HasProperties

This represents one condition of a domain query.

Required Properties:

  • field (String): Field to search on, a unicode string
  • value (String): String Value, a unicode string
field

Field to search on

field_name

Return the name of the API field.

classmethod from_tuple(query)[source]

Create a condition from a query tuple.

Parameters:query (tuple or list) – Tuple or list that contains a query domain in the format of (field_name, field_value, field_value_to). field_value_to is only applicable in the case of a date search.
Returns:
An instance of a domain condition. The specific
type will depend on the data type of the first value provided in query.
Return type:DomainCondition
value

String Value

class helpscout.domain.DomainConditionBoolean(field, value, **kwargs)[source]

Bases: helpscout.domain.DomainCondition

This represents an integer query.

Required Properties:

  • field (String): Field to search on, a unicode string
  • value (Bool): Boolean Value, a boolean
value

Boolean Value

class helpscout.domain.DomainConditionDateTime(field, value_from, value_to=None)[source]

Bases: helpscout.domain.DomainCondition

This represents a date time query.

Required Properties:

  • field (String): Field to search on, a unicode string
  • value (DateTime): Date From, a datetime object
  • value_to (DateTime): Date To, a datetime object
value

Date From

value_to

Date To

class helpscout.domain.DomainConditionInteger(field, value, **kwargs)[source]

Bases: helpscout.domain.DomainCondition

This represents an integer query.

Required Properties:

  • field (String): Field to search on, a unicode string
  • value (Integer): Integer Value, an integer
value

Integer Value