| POST | /v1/schedule/reorder |
|---|
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 WorkerScheduleItem:
worker_schedule_item_i_d: int = 0
job_i_d: int = 0
project_i_d: Optional[int] = None
contact_i_d: int = 0
scheduled_date: Optional[datetime.datetime] = None
sort_order: int = 0
source_crew_i_d: Optional[int] = None
status: Optional[str] = None
started_at: Optional[datetime.datetime] = None
completed_at: Optional[datetime.datetime] = None
worker_notes: Optional[str] = None
job_name: Optional[str] = None
project_name: Optional[str] = None
first_name: Optional[str] = None
last_name: Optional[str] = None
worker_name: Optional[str] = None
source_crew_name: Optional[str] = None
project_location_i_d: Optional[int] = None
project_location_name: Optional[str] = None
location_zip: Optional[str] = None
location_city: Optional[str] = None
location_latitude: Optional[Decimal] = None
location_longitude: Optional[Decimal] = None
job_status_name: Optional[str] = None
branch_id: Optional[str] = None
branch_name: Optional[str] = None
worker_home_branch_id: Optional[str] = None
worker_home_branch_name: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class SchedulableJob:
job_i_d: int = 0
job_name: Optional[str] = None
project_i_d: int = 0
project_name: Optional[str] = None
status_i_d: Optional[int] = None
status_name: Optional[str] = None
project_location_i_d: Optional[int] = None
project_location_name: Optional[str] = None
location_zip: Optional[str] = None
location_city: Optional[str] = None
location_latitude: Optional[Decimal] = None
location_longitude: Optional[Decimal] = None
expected_start_date: Optional[datetime.datetime] = None
expected_completion_date: Optional[datetime.datetime] = None
is_recurring: bool = False
occurrence_dates: List[str] = field(default_factory=list)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ScheduleWorker:
contact_id: int = 0
first_name: Optional[str] = None
last_name: Optional[str] = None
name: Optional[str] = None
initials: Optional[str] = None
rate: Optional[Decimal] = None
image_url: Optional[str] = None
branch_id: Optional[str] = None
branch_name: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Crew:
crew_i_d: int = 0
crew_name: Optional[str] = None
crew_number: Optional[str] = None
crew_manager_contact_i_d: int = 0
crew_manager_contact_name: Optional[str] = None
crew_color: Optional[str] = None
record_created_date: datetime.datetime = datetime.datetime(1, 1, 1)
active: bool = False
created_by_u_i_d: Optional[str] = None
project_i_d: int = 0
crew_member_count: int = 0
project_crew_i_d: int = 0
project_name: Optional[str] = None
branch_id: Optional[str] = None
branch_name: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ScheduleLastAssignment:
job_i_d: int = 0
contact_ids: List[int] = field(default_factory=list)
source_crew_i_d: Optional[int] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ScheduleAutoFillResult:
jobs_filled: int = 0
jobs_skipped: int = 0
visits_scheduled: int = 0
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class WorkerScheduleResponse:
items: List[WorkerScheduleItem] = field(default_factory=list)
schedulable_jobs: List[SchedulableJob] = field(default_factory=list)
workers: List[ScheduleWorker] = field(default_factory=list)
crews: List[Crew] = field(default_factory=list)
budgeted_crew: List[ScheduleWorker] = field(default_factory=list)
last_assignment: Optional[ScheduleLastAssignment] = None
auto_fill: Optional[ScheduleAutoFillResult] = None
dates_scheduled: Optional[int] = None
workers_scheduled: Optional[int] = None
items_removed: Optional[int] = None
response_status: Optional[ResponseStatus] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ScheduleReorderRequest:
contact_i_d: int = 0
scheduled_date: datetime.datetime = datetime.datetime(1, 1, 1)
ordered_ids: List[int] = field(default_factory=list)
Python ScheduleReorderRequest DTOs
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.
POST /v1/schedule/reorder HTTP/1.1
Host: api.dev.dynamics.trendsic.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<ScheduleReorderRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<ContactID>0</ContactID>
<OrderedIds xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:int>0</d2p1:int>
</OrderedIds>
<ScheduledDate>0001-01-01T00:00:00</ScheduledDate>
</ScheduleReorderRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length
<WorkerScheduleResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/CRM.AgencyPlatform.API.Internal">
<AutoFill>
<JobsFilled>0</JobsFilled>
<JobsSkipped>0</JobsSkipped>
<VisitsScheduled>0</VisitsScheduled>
</AutoFill>
<BudgetedCrew>
<ScheduleWorker>
<BranchId>00000000-0000-0000-0000-000000000000</BranchId>
<BranchName>String</BranchName>
<ContactId>0</ContactId>
<FirstName>String</FirstName>
<ImageUrl>String</ImageUrl>
<Initials>String</Initials>
<LastName>String</LastName>
<Name>String</Name>
<Rate>0</Rate>
</ScheduleWorker>
</BudgetedCrew>
<Crews>
<Crew>
<Active>false</Active>
<BranchId>00000000-0000-0000-0000-000000000000</BranchId>
<BranchName>String</BranchName>
<CreatedByUID>00000000-0000-0000-0000-000000000000</CreatedByUID>
<CrewColor>String</CrewColor>
<CrewID>0</CrewID>
<CrewManagerContactID>0</CrewManagerContactID>
<CrewManagerContactName>String</CrewManagerContactName>
<CrewMemberCount>0</CrewMemberCount>
<CrewName>String</CrewName>
<CrewNumber>String</CrewNumber>
<ProjectCrewID>0</ProjectCrewID>
<ProjectID>0</ProjectID>
<ProjectName>String</ProjectName>
<RecordCreatedDate>0001-01-01T00:00:00</RecordCreatedDate>
</Crew>
</Crews>
<DatesScheduled>0</DatesScheduled>
<Items>
<WorkerScheduleItem>
<BranchId>00000000-0000-0000-0000-000000000000</BranchId>
<BranchName>String</BranchName>
<CompletedAt>0001-01-01T00:00:00</CompletedAt>
<ContactID>0</ContactID>
<FirstName>String</FirstName>
<JobID>0</JobID>
<JobName>String</JobName>
<JobStatusName>String</JobStatusName>
<LastName>String</LastName>
<LocationCity>String</LocationCity>
<LocationLatitude>0</LocationLatitude>
<LocationLongitude>0</LocationLongitude>
<LocationZip>String</LocationZip>
<ProjectID>0</ProjectID>
<ProjectLocationID>0</ProjectLocationID>
<ProjectLocationName>String</ProjectLocationName>
<ProjectName>String</ProjectName>
<ScheduledDate>0001-01-01T00:00:00</ScheduledDate>
<SortOrder>0</SortOrder>
<SourceCrewID>0</SourceCrewID>
<SourceCrewName>String</SourceCrewName>
<StartedAt>0001-01-01T00:00:00</StartedAt>
<Status>String</Status>
<WorkerHomeBranchId>00000000-0000-0000-0000-000000000000</WorkerHomeBranchId>
<WorkerHomeBranchName>String</WorkerHomeBranchName>
<WorkerName>String</WorkerName>
<WorkerNotes>String</WorkerNotes>
<WorkerScheduleItemID>0</WorkerScheduleItemID>
</WorkerScheduleItem>
</Items>
<ItemsRemoved>0</ItemsRemoved>
<LastAssignment>
<ContactIds xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d3p1:int>0</d3p1:int>
</ContactIds>
<JobID>0</JobID>
<SourceCrewID>0</SourceCrewID>
</LastAssignment>
<ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:Message>String</d2p1:Message>
<d2p1:StackTrace>String</d2p1:StackTrace>
<d2p1:Errors>
<d2p1:ResponseError>
<d2p1:ErrorCode>String</d2p1:ErrorCode>
<d2p1:FieldName>String</d2p1:FieldName>
<d2p1:Message>String</d2p1:Message>
<d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d5p1:KeyValueOfstringstring>
<d5p1:Key>String</d5p1:Key>
<d5p1:Value>String</d5p1:Value>
</d5p1:KeyValueOfstringstring>
</d2p1:Meta>
</d2p1:ResponseError>
</d2p1:Errors>
<d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d3p1:KeyValueOfstringstring>
<d3p1:Key>String</d3p1:Key>
<d3p1:Value>String</d3p1:Value>
</d3p1:KeyValueOfstringstring>
</d2p1:Meta>
</ResponseStatus>
<SchedulableJobs>
<SchedulableJob>
<ExpectedCompletionDate>0001-01-01T00:00:00</ExpectedCompletionDate>
<ExpectedStartDate>0001-01-01T00:00:00</ExpectedStartDate>
<IsRecurring>false</IsRecurring>
<JobID>0</JobID>
<JobName>String</JobName>
<LocationCity>String</LocationCity>
<LocationLatitude>0</LocationLatitude>
<LocationLongitude>0</LocationLongitude>
<LocationZip>String</LocationZip>
<OccurrenceDates xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string>String</d4p1:string>
</OccurrenceDates>
<ProjectID>0</ProjectID>
<ProjectLocationID>0</ProjectLocationID>
<ProjectLocationName>String</ProjectLocationName>
<ProjectName>String</ProjectName>
<StatusID>0</StatusID>
<StatusName>String</StatusName>
</SchedulableJob>
</SchedulableJobs>
<Workers>
<ScheduleWorker>
<BranchId>00000000-0000-0000-0000-000000000000</BranchId>
<BranchName>String</BranchName>
<ContactId>0</ContactId>
<FirstName>String</FirstName>
<ImageUrl>String</ImageUrl>
<Initials>String</Initials>
<LastName>String</LastName>
<Name>String</Name>
<Rate>0</Rate>
</ScheduleWorker>
</Workers>
<WorkersScheduled>0</WorkersScheduled>
</WorkerScheduleResponse>