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 .jsv suffix or ?format=jsv

HTTP + JSV

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: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	Id: String,
	Workspace: String,
	Contact: 
	{
		ExternalId: String,
		ContactName: String,
		Company: String,
		MobilePhone: String,
		WorkPhone: String,
		HomePhone: String,
		Email: String,
		Lat: 0,
		Lon: 0,
		StreetAddress: String,
		Unit: String,
		City: String,
		State: String,
		Zip: String,
		Country: String,
		Team: String,
		Tasks: 
		[
			String
		],
		Enabled: False,
		LastUpdated: String,
		Created: String,
		Data: 
		{
			String: {}
		}
	},
	Contacts: 
	[
		{
			ExternalId: String,
			ContactName: String,
			Company: String,
			MobilePhone: String,
			WorkPhone: String,
			HomePhone: String,
			Email: String,
			Lat: 0,
			Lon: 0,
			StreetAddress: String,
			Unit: String,
			City: String,
			State: String,
			Zip: String,
			Country: String,
			Team: String,
			Tasks: 
			[
				String
			],
			Enabled: False,
			LastUpdated: String,
			Created: String,
			Data: 
			{
				String: {}
			}
		}
	]
}