Field Squared API Services

<back to all web services

ContactImport

Bulk import a set of contacts..

The following routes are available for this service:
POST/{Workspace}/ContactImport
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 ContactImport:
    """
    Bulk import a set of contacts..
    """

    workspace: Optional[str] = None
    contacts: Optional[List[Contact]] = None
    request_id: Optional[str] = None

Python ContactImport 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}/ContactImport HTTP/1.1 
Host: dev.fieldsquared.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	Workspace: String,
	Contacts: 
	[
		{
			Workspace: String,
			ObjectId: String,
			TimeZone: String,
			VersionId: String,
			BasedOn: String,
			ExternalId: String,
			ContactName: String,
			Company: String,
			MobilePhone: String,
			WorkPhone: String,
			HomePhone: String,
			Email: String,
			SMS: False,
			Address: 
			{
				Street: String,
				Unit: String,
				City: String,
				State: String,
				Zip: String,
				ContactTitle: String,
				ContactName: String,
				ContactPhone: String,
				ContactEmail: String,
				Location: 
				{
					y: 0,
					x: 0
				},
				SiteName: String,
				GeocodeFailed: False,
				Country: String
			},
			Enabled: False,
			POI: False,
			EmailSiteDriving: False,
			ServiceAddresses: 
			[
				{
					Street: String,
					Unit: String,
					City: String,
					State: String,
					Zip: String,
					ContactTitle: String,
					ContactName: String,
					ContactPhone: String,
					ContactEmail: String,
					Location: 
					{
						y: 0,
						x: 0
					},
					SiteName: String,
					GeocodeFailed: False,
					Country: String
				}
			],
			Documents: 
			[
				{
					Workspace: String,
					ObjectId: String,
					VersionId: String,
					LastUpdated: String
				}
			],
			Data: 
			{
				String: String
			},
			Owner: 
			{
				ObjectId: String,
				Class: String,
				VersionId: String,
				Ancestors: 
				[
					String
				],
				Type: String
			},
			Tasks: 
			[
				String
			],
			Assets: 
			[
				String
			],
			Contacts: 
			[
				String
			],
			Events: 
			[
				{
					ObjectId: String,
					Date: String,
					Location: 
					{
						y: 0,
						x: 0
					},
					Barcode: String,
					Details: String,
					Type: String,
					IsScan: False,
					User: String,
					SelectedBy: String,
					Status: String,
					StatusType: String,
					DateCreated: String,
					Automatic: False
				}
			],
			Teams: 
			[
				String
			],
			Created: String,
			LastUpdated: String,
			CreatedBy: String,
			ActiveLaborTypes: 
			{
				String: {}
			}
		}
	],
	RequestId: String
}