Field Squared API Services

<back to all web services

PublicContact

The following routes are available for this service:
GET/{Workspace}/API/Contact/Schema
GET, PUT, POST, DELETE/{Workspace}/API/Contact/{Id}
GET, PUT, POST, DELETE/{Workspace}/API/Contact
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


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Location:
    y: float = 0.0
    x: float = 0.0


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Address:
    street: Optional[str] = None
    unit: Optional[str] = None
    city: Optional[str] = None
    state: Optional[str] = None
    zip: Optional[str] = None
    contact_title: Optional[str] = None
    contact_name: Optional[str] = None
    contact_phone: Optional[str] = None
    contact_email: Optional[str] = None
    location: Optional[Location] = None
    site_name: Optional[str] = None
    geocode_failed: bool = False
    country: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class DomainItem:
    workspace: Optional[str] = None
    object_id: Optional[str] = None
    version_id: Optional[str] = None
    last_updated: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ClassedItem:
    object_id: Optional[str] = None
    class_: Optional[str] = field(metadata=config(field_name='class'), default=None)
    version_id: Optional[str] = None
    ancestors: Optional[List[str]] = None
    type: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class EventItem:
    object_id: Optional[str] = None
    date: Optional[str] = None
    location: Optional[Location] = None
    barcode: Optional[str] = None
    details: Optional[str] = None
    type: Optional[str] = None
    is_scan: bool = False
    user: Optional[str] = None
    selected_by: Optional[str] = None
    status: Optional[str] = None
    status_type: Optional[str] = None
    date_created: Optional[str] = None
    automatic: bool = False


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Contact:
    """
    Represents a DTO for a contact in a workspace.  Calls without an ObjectId will retrieve an array of all active contact objects for the workspace.A call to /{Workspace}/ContactTasks/{ObjectId} will return a List<DomainItem> for the list of tasks associated to the contact.A core or custom sort field can be specified by using sort=fieldname&sortorder=ascending/descending. To filter for contacts based on full text search, use fulltext Custom contact field 'contains' filters can also be specified by using the binding/key as the query parameter. i.e. Comments=Quick Brown Fox. To filter and return all contacts modified since a date and time, use the query parameter modifiedsince = X where X = YYYY-MM-DDTHH:MM:SSZ To filter and return all contacts deleted since a date and time, use the query parameter deletedsince = X where X = YYYY-MM-DDTHH:MM:SSZ.  Note only Object ID, Workspace and Version is populated. Spatial extents can be passed in using: bottomleft=Lat,Lon&topright=Lat,Lon.  To filter on tasks inside a boundary, use boundary=Lat,Lon,Lat,Lon etc. Pagination - /{0}/ContactList?recstart=0&reccount=1  /{Workspace}/ContactList/Count returns a count, not the actual object list
    """

    workspace: Optional[str] = None
    object_id: Optional[str] = None
    time_zone: Optional[str] = None
    version_id: Optional[str] = None
    based_on: Optional[str] = None
    external_id: Optional[str] = None
    contact_name: Optional[str] = None
    company: Optional[str] = None
    mobile_phone: Optional[str] = None
    work_phone: Optional[str] = None
    home_phone: Optional[str] = None
    email: Optional[str] = None
    sms: bool = False
    address: Optional[Address] = None
    enabled: bool = False
    poi: bool = False
    email_site_driving: bool = False
    service_addresses: Optional[List[Address]] = None
    documents: Optional[List[DomainItem]] = None
    data: Optional[Dict[str, str]] = None
    owner: Optional[ClassedItem] = None
    tasks: Optional[List[str]] = None
    assets: Optional[List[str]] = None
    contacts: Optional[List[str]] = None
    events: Optional[List[EventItem]] = None
    teams: Optional[List[str]] = None
    created: Optional[str] = None
    last_updated: Optional[str] = None
    created_by: Optional[str] = None
    active_labor_types: Optional[Dict[str, Object]] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class PublicContact:
    id: Optional[str] = None
    workspace: Optional[str] = None
    contact: Optional[Contact] = None
    contacts: Optional[List[Contact]] = None

Python PublicContact DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /{Workspace}/API/Contact/{Id} HTTP/1.1 
Host: dev.fieldsquared.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<PublicContact xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Field2Office.API.Model.PublicApi.Contacts">
  <Contact>
    <City>String</City>
    <Company>String</Company>
    <ContactName>String</ContactName>
    <Country>String</Country>
    <Created>String</Created>
    <Data xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringanyType>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value />
      </d3p1:KeyValueOfstringanyType>
    </Data>
    <Email>String</Email>
    <Enabled>false</Enabled>
    <ExternalId>String</ExternalId>
    <HomePhone>String</HomePhone>
    <LastUpdated>String</LastUpdated>
    <Lat>0</Lat>
    <Lon>0</Lon>
    <MobilePhone>String</MobilePhone>
    <State>String</State>
    <StreetAddress>String</StreetAddress>
    <Tasks xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:string>String</d3p1:string>
    </Tasks>
    <Team>String</Team>
    <Unit>String</Unit>
    <WorkPhone>String</WorkPhone>
    <Zip>String</Zip>
  </Contact>
  <Contacts>
    <Contact>
      <City>String</City>
      <Company>String</Company>
      <ContactName>String</ContactName>
      <Country>String</Country>
      <Created>String</Created>
      <Data xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringanyType>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value />
        </d4p1:KeyValueOfstringanyType>
      </Data>
      <Email>String</Email>
      <Enabled>false</Enabled>
      <ExternalId>String</ExternalId>
      <HomePhone>String</HomePhone>
      <LastUpdated>String</LastUpdated>
      <Lat>0</Lat>
      <Lon>0</Lon>
      <MobilePhone>String</MobilePhone>
      <State>String</State>
      <StreetAddress>String</StreetAddress>
      <Tasks xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:string>String</d4p1:string>
      </Tasks>
      <Team>String</Team>
      <Unit>String</Unit>
      <WorkPhone>String</WorkPhone>
      <Zip>String</Zip>
    </Contact>
  </Contacts>
  <Id>String</Id>
  <Workspace>String</Workspace>
</PublicContact>