Requires any of the roles: | SystemAdministrator, Manager, Customer |
GET | /customers |
---|
import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
class SortOrders(str, Enum):
ASCEND = 'Ascend'
DESCEND = 'Descend'
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ListRequest(Generic[T], IReturn[ListResponse[T]], IGet):
# @ApiMember(Description="The page of data to retrieve")
page: int = 0
"""
The page of data to retrieve
"""
# @ApiMember(Description="If you want all objects to be returned. This should be used with care")
all: bool = False
"""
If you want all objects to be returned. This should be used with care
"""
# @ApiMember(Description="The number per page to retrieve")
count_per_page: int = 0
"""
The number per page to retrieve
"""
# @ApiMember(Description="Specific IDs")
specific_ids: Optional[List[str]] = None
"""
Specific IDs
"""
# @ApiMember(Description="Specify a sort field")
sort_field: Optional[str] = None
"""
Specify a sort field
"""
# @ApiMember(Description="Specify a sort order")
sort_order: Optional[SortOrders] = None
"""
Specify a sort order
"""
# @ApiMember(Description="Disables total / page counts - improves performance. Returns only data. If there is no more data, Items will be empty array")
simplified_paging: bool = False
"""
Disables total / page counts - improves performance. Returns only data. If there is no more data, Items will be empty array
"""
@staticmethod
def response_type(): return ListResponse[T]
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class EntityInfo:
# @ApiMember(Description="The ID of the object")
id: Optional[str] = None
"""
The ID of the object
"""
# @ApiMember(Description="The date the object was created")
date_created: Optional[str] = None
"""
The date the object was created
"""
# @ApiMember(Description="The date the object was last modified")
date_last_modified: Optional[str] = None
"""
The date the object was last modified
"""
# @ApiMember(Description="The user that created this object")
created_by: Optional[str] = None
"""
The user that created this object
"""
# @ApiMember(Description="The user that last modified this object")
last_modified_by: Optional[str] = None
"""
The user that last modified this object
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerBreadcrumb:
id: Optional[str] = None
name: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Value:
bool_value: Optional[bool] = None
string_value: Optional[str] = None
number_value: Optional[float] = None
list_value: Optional[List[Struct]] = None
struct_value: Optional[Struct] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Struct(Dict[str,Value]):
pass
class TagColors(str, Enum):
MAGENTA = 'Magenta'
RED = 'Red'
VOLCANO = 'Volcano'
ORANGE = 'Orange'
GOLD = 'Gold'
LIME = 'Lime'
GREEN = 'Green'
CYAN = 'Cyan'
BLUE = 'Blue'
GEEK_BLUE = 'GeekBlue'
PURPLE = 'Purple'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Tag:
id: Optional[str] = None
name: Optional[str] = None
color: Optional[TagColors] = None
class SimpleSchedulingRuleTypes(str, Enum):
ALWAYS = 'Always'
CUSTOMER_STATE = 'CustomerState'
TIME = 'Time'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ScheduleDay:
offset: int = 0
day_of_week: Optional[DayOfWeek] = None
class SchedulingRuleFrequency(str, Enum):
NONE = 'None'
SECONDLY = 'Secondly'
MINUTELY = 'Minutely'
HOURLY = 'Hourly'
DAILY = 'Daily'
WEEKLY = 'Weekly'
MONTHLY = 'Monthly'
YEARLY = 'Yearly'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SchedulingRule:
id: Optional[str] = None
name: Optional[str] = None
priority: int = 0
state: Optional[str] = None
source: Optional[str] = None
condition: Optional[str] = None
simple_rule_type: Optional[SimpleSchedulingRuleTypes] = None
customer_state: Optional[str] = None
flow_id: Optional[str] = None
flow_params: Optional[Struct] = None
is_all_day: bool = False
start_date: Optional[str] = None
start_time: Optional[str] = None
end_time: Optional[str] = None
by_set_position: Optional[List[int]] = None
by_month: Optional[List[int]] = None
by_week_no: Optional[List[int]] = None
by_year_day: Optional[List[int]] = None
by_month_day: Optional[List[int]] = None
by_day: Optional[List[ScheduleDay]] = None
by_hour: Optional[List[int]] = None
by_minute: Optional[List[int]] = None
interval: int = 0
count: int = 0
until_date: Optional[str] = None
frequency: Optional[SchedulingRuleFrequency] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Schedule:
time_zone_id: Optional[str] = None
inherit: bool = False
force_closed: bool = False
rules: Optional[List[SchedulingRule]] = None
default_state: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class IntegrationData:
third_party_id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class EntityIntegrationData(Dict[str,IntegrationData]):
pass
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BillingItem:
base_cost: float = 0.0
raw_unit_multiplier: float = 0.0
unit_cost: float = 0.0
allowance: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class BillingSettings:
base: Optional[BillingItem] = None
local_numbers: Optional[BillingItem] = None
toll_free_numbers: Optional[BillingItem] = None
inbound_voice_calls: Optional[BillingItem] = None
outbound_voice_calls: Optional[BillingItem] = None
inbound_faxes: Optional[BillingItem] = None
outbound_faxes: Optional[BillingItem] = None
inbound_sms_messages: Optional[BillingItem] = None
outbound_sms_messages: Optional[BillingItem] = None
ai_insights: Optional[BillingItem] = None
ai_live_minutes: Optional[BillingItem] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AppSettings:
enable_phone_number_management: bool = False
enable_device_management: bool = False
enable_dialer: bool = False
enable_call_history: bool = False
enable_assistants: bool = False
show_file_name_in_message_center: bool = False
chakra_theme: Optional[str] = None
custom_css: Optional[str] = None
page_title: Optional[str] = None
string_mappings: Optional[str] = None
logout_url: Optional[str] = None
port_my_number_url: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class CustomerInfo(EntityInfo):
# @ApiMember(Description="The ID of the account associated with this customer")
account_id: Optional[str] = None
"""
The ID of the account associated with this customer
"""
# @ApiMember(Description="The parent customer ID for this customer")
parent_customer_id: Optional[str] = None
"""
The parent customer ID for this customer
"""
# @ApiMember(Description="The breadcrumb to this customer")
breadcrumb: Optional[List[CustomerBreadcrumb]] = None
"""
The breadcrumb to this customer
"""
# @ApiMember(Description="The name of the account associated with this customer")
account_name: Optional[str] = None
"""
The name of the account associated with this customer
"""
# @ApiMember(Description="Is this customer staging or production?")
is_staging: bool = False
"""
Is this customer staging or production?
"""
# @ApiMember(Description="The name of the company")
name: Optional[str] = None
"""
The name of the company
"""
# @ApiMember(Description="The reference ID for this company")
reference_id: Optional[str] = None
"""
The reference ID for this company
"""
# @ApiMember(Description="This customer's data values")
data: Optional[Struct] = None
"""
This customer's data values
"""
# @ApiMember(Description="The list of tags for this customer")
tags: Optional[List[Tag]] = None
"""
The list of tags for this customer
"""
# @ApiMember(Description="This customer's schedule")
schedule: Optional[Schedule] = None
"""
This customer's schedule
"""
# @ApiMember(Description="Integration data for this customer")
integration_data: Optional[EntityIntegrationData] = None
"""
Integration data for this customer
"""
# @ApiMember(Description="Override this customer's billing settings? Otherwise inherits from parent")
override_billing_settings: bool = False
"""
Override this customer's billing settings? Otherwise inherits from parent
"""
# @ApiMember(Description="Billing settings for this customer")
billing_settings: Optional[BillingSettings] = None
"""
Billing settings for this customer
"""
# @ApiMember(Description="Should this customer override the parent customer's app settings")
override_app_settings: bool = False
"""
Should this customer override the parent customer's app settings
"""
# @ApiMember(Description="App / Portal settings for this customer")
app_settings: Optional[AppSettings] = None
"""
App / Portal settings for this customer
"""
# @Api(Description="Retrieve customers")
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ListCustomers(ListRequest[CustomerInfo]):
"""
Retrieve customers
"""
# @ApiMember(Description="Filter by accounts")
account_ids: Optional[List[str]] = None
"""
Filter by accounts
"""
# @ApiMember(Description="Filter by name")
name_filter: Optional[str] = None
"""
Filter by name
"""
# @ApiMember(Description="The IDs of the parent customers you want to filter by")
parent_customer_ids: Optional[List[str]] = None
"""
The IDs of the parent customers you want to filter by
"""
# @ApiMember(Description="If you want a shall parent customer filter (e.g. no deep children)")
shallow_parent: bool = False
"""
If you want a shall parent customer filter (e.g. no deep children)
"""
# @ApiMember(Description="The list of tag IDs to filter by (must contain all)")
tag_ids: Optional[List[str]] = None
"""
The list of tag IDs to filter by (must contain all)
"""
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AccountInfo(EntityInfo):
# @ApiMember(Description="The name of this account")
name: Optional[str] = None
"""
The name of this account
"""
# @ApiMember(Description="The ID of this account's parent")
parent_account_id: Optional[str] = None
"""
The ID of this account's parent
"""
# @ApiMember(Description="The twilio account SID")
twilio_account_sid: Optional[str] = None
"""
The twilio account SID
"""
# @ApiMember(Description="The ancestors of this account. Useful for breadcrumbs")
ancestor_ids: Optional[List[str]] = None
"""
The ancestors of this account. Useful for breadcrumbs
"""
# @ApiMember(Description="The max number of phone numbers this account can have")
max_phone_numbers: int = 0
"""
The max number of phone numbers this account can have
"""
# @ApiMember(Description="This account is BYOA")
is_b_y_o_a: bool = False
"""
This account is BYOA
"""
# @ApiMember(Description="TrustHub Profile Sid")
trust_hub_profile_sid: Optional[str] = None
"""
TrustHub Profile Sid
"""
# @ApiMember(Description="The ID of the logo file")
logo_id: Optional[str] = None
"""
The ID of the logo file
"""
# @ApiMember(Description="The URI of the logo file")
logo_uri: Optional[str] = None
"""
The URI of the logo file
"""
# @ApiMember(Description="The billing settings for this account")
billing_settings: Optional[BillingSettings] = None
"""
The billing settings for this account
"""
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ListResponse(Generic[T]):
# @ApiMember(Description="The items")
items: Optional[List[AccountInfo]] = None
"""
The items
"""
# @ApiMember(Description="The total number of items")
total_count: int = 0
"""
The total number of items
"""
# @ApiMember(Description="The total number of pages")
total_pages: int = 0
"""
The total number of pages
"""
# @ApiMember(Description="Are there more pages of items? Used with simplified paging")
has_more_pages: bool = False
"""
Are there more pages of items? Used with simplified paging
"""
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /customers HTTP/1.1 Host: team.evovoice.io Accept: application/xml
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <ListResponseOfCustomerInfoznfKbIMc xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Voice.Api"> <HasMorePages>false</HasMorePages> <Items xmlns:d2p1="http://schemas.datacontract.org/2004/07/Voice.Api.Customers"> <d2p1:CustomerInfo> <CreatedBy>String</CreatedBy> <DateCreated>String</DateCreated> <DateLastModified>String</DateLastModified> <Id>String</Id> <LastModifiedBy>String</LastModifiedBy> <d2p1:AccountId>String</d2p1:AccountId> <d2p1:AccountName>String</d2p1:AccountName> <d2p1:AppSettings> <d2p1:ChakraTheme>String</d2p1:ChakraTheme> <d2p1:CustomCss>String</d2p1:CustomCss> <d2p1:EnableAssistants>false</d2p1:EnableAssistants> <d2p1:EnableCallHistory>false</d2p1:EnableCallHistory> <d2p1:EnableDeviceManagement>false</d2p1:EnableDeviceManagement> <d2p1:EnableDialer>false</d2p1:EnableDialer> <d2p1:EnablePhoneNumberManagement>false</d2p1:EnablePhoneNumberManagement> <d2p1:LogoutUrl>String</d2p1:LogoutUrl> <d2p1:PageTitle>String</d2p1:PageTitle> <d2p1:PortMyNumberUrl>String</d2p1:PortMyNumberUrl> <d2p1:ShowFileNameInMessageCenter>false</d2p1:ShowFileNameInMessageCenter> <d2p1:StringMappings>String</d2p1:StringMappings> </d2p1:AppSettings> <d2p1:BillingSettings xmlns:d4p1="http://schemas.datacontract.org/2004/07/Voice.Api.Accounts"> <d4p1:AIInsights> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:AIInsights> <d4p1:AILiveMinutes> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:AILiveMinutes> <d4p1:Base> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:Base> <d4p1:InboundFaxes> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:InboundFaxes> <d4p1:InboundSmsMessages> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:InboundSmsMessages> <d4p1:InboundVoiceCalls> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:InboundVoiceCalls> <d4p1:LocalNumbers> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:LocalNumbers> <d4p1:OutboundFaxes> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:OutboundFaxes> <d4p1:OutboundSmsMessages> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:OutboundSmsMessages> <d4p1:OutboundVoiceCalls> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:OutboundVoiceCalls> <d4p1:TollFreeNumbers> <d4p1:Allowance>0</d4p1:Allowance> <d4p1:BaseCost>0</d4p1:BaseCost> <d4p1:RawUnitMultiplier>0</d4p1:RawUnitMultiplier> <d4p1:UnitCost>0</d4p1:UnitCost> </d4p1:TollFreeNumbers> </d2p1:BillingSettings> <d2p1:Breadcrumb> <d2p1:CustomerBreadcrumb> <d2p1:Id>String</d2p1:Id> <d2p1:Name>String</d2p1:Name> </d2p1:CustomerBreadcrumb> </d2p1:Breadcrumb> <d2p1:Data xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" /> <d2p1:IntegrationData xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d4p1:KeyValueOfstringIntegrationDataY_SkqLnhh> <d4p1:Key>String</d4p1:Key> <d4p1:Value xmlns:d6p1="http://schemas.datacontract.org/2004/07/Voice.Api.Integrations"> <d6p1:ThirdPartyId>String</d6p1:ThirdPartyId> </d4p1:Value> </d4p1:KeyValueOfstringIntegrationDataY_SkqLnhh> </d2p1:IntegrationData> <d2p1:IsStaging>false</d2p1:IsStaging> <d2p1:Name>String</d2p1:Name> <d2p1:OverrideAppSettings>false</d2p1:OverrideAppSettings> <d2p1:OverrideBillingSettings>false</d2p1:OverrideBillingSettings> <d2p1:ParentCustomerId>String</d2p1:ParentCustomerId> <d2p1:ReferenceId>String</d2p1:ReferenceId> <d2p1:Schedule xmlns:d4p1="http://schemas.datacontract.org/2004/07/Voice.Api.Scheduling"> <d4p1:DefaultState>String</d4p1:DefaultState> <d4p1:ForceClosed>false</d4p1:ForceClosed> <d4p1:Inherit>false</d4p1:Inherit> <d4p1:Rules> <d4p1:SchedulingRule> <d4p1:ByDay> <d4p1:ScheduleDay> <d4p1:DayOfWeek>Sunday</d4p1:DayOfWeek> <d4p1:Offset>0</d4p1:Offset> </d4p1:ScheduleDay> </d4p1:ByDay> <d4p1:ByHour xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:ByHour> <d4p1:ByMinute xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:ByMinute> <d4p1:ByMonth xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:ByMonth> <d4p1:ByMonthDay xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:ByMonthDay> <d4p1:BySetPosition xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:BySetPosition> <d4p1:ByWeekNo xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:ByWeekNo> <d4p1:ByYearDay xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d7p1:int>0</d7p1:int> </d4p1:ByYearDay> <d4p1:Condition>String</d4p1:Condition> <d4p1:Count>0</d4p1:Count> <d4p1:CustomerState>String</d4p1:CustomerState> <d4p1:EndTime>String</d4p1:EndTime> <d4p1:FlowId>String</d4p1:FlowId> <d4p1:FlowParams xmlns:d7p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true" /> <d4p1:Frequency>None</d4p1:Frequency> <d4p1:Id>String</d4p1:Id> <d4p1:Interval>0</d4p1:Interval> <d4p1:IsAllDay>false</d4p1:IsAllDay> <d4p1:Name>String</d4p1:Name> <d4p1:Priority>0</d4p1:Priority> <d4p1:SimpleRuleType>Always</d4p1:SimpleRuleType> <d4p1:Source>String</d4p1:Source> <d4p1:StartDate>String</d4p1:StartDate> <d4p1:StartTime>String</d4p1:StartTime> <d4p1:State>String</d4p1:State> <d4p1:UntilDate>String</d4p1:UntilDate> </d4p1:SchedulingRule> </d4p1:Rules> <d4p1:TimeZoneId>String</d4p1:TimeZoneId> </d2p1:Schedule> <d2p1:Tags xmlns:d4p1="http://schemas.datacontract.org/2004/07/Voice.Api.Settings"> <d4p1:Tag> <d4p1:Color>Magenta</d4p1:Color> <d4p1:Id>String</d4p1:Id> <d4p1:Name>String</d4p1:Name> </d4p1:Tag> </d2p1:Tags> </d2p1:CustomerInfo> </Items> <TotalCount>0</TotalCount> <TotalPages>0</TotalPages> </ListResponseOfCustomerInfoznfKbIMc>