Trendsic Platform Service

<back to all web services

ScheduleOptimizeRequest

Requires Authentication
The following routes are available for this service:
POST/v1/schedule/optimize
import 'package:servicestack/servicestack.dart';

class WorkerScheduleItem implements IConvertible
{
    int? WorkerScheduleItemID;
    int? JobID;
    int? ProjectID;
    int? ContactID;
    DateTime? ScheduledDate;
    int? SortOrder;
    int? SourceCrewID;
    String? Status;
    DateTime? StartedAt;
    DateTime? CompletedAt;
    String? WorkerNotes;
    String? JobName;
    String? ProjectName;
    String? FirstName;
    String? LastName;
    String? WorkerName;
    String? SourceCrewName;
    int? ProjectLocationID;
    String? ProjectLocationName;
    String? LocationZip;
    String? LocationCity;
    double? LocationLatitude;
    double? LocationLongitude;
    String? JobStatusName;
    String? BranchId;
    String? BranchName;
    String? WorkerHomeBranchId;
    String? WorkerHomeBranchName;

    WorkerScheduleItem({this.WorkerScheduleItemID,this.JobID,this.ProjectID,this.ContactID,this.ScheduledDate,this.SortOrder,this.SourceCrewID,this.Status,this.StartedAt,this.CompletedAt,this.WorkerNotes,this.JobName,this.ProjectName,this.FirstName,this.LastName,this.WorkerName,this.SourceCrewName,this.ProjectLocationID,this.ProjectLocationName,this.LocationZip,this.LocationCity,this.LocationLatitude,this.LocationLongitude,this.JobStatusName,this.BranchId,this.BranchName,this.WorkerHomeBranchId,this.WorkerHomeBranchName});
    WorkerScheduleItem.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        WorkerScheduleItemID = json['WorkerScheduleItemID'];
        JobID = json['JobID'];
        ProjectID = json['ProjectID'];
        ContactID = json['ContactID'];
        ScheduledDate = JsonConverters.fromJson(json['ScheduledDate'],'DateTime',context!);
        SortOrder = json['SortOrder'];
        SourceCrewID = json['SourceCrewID'];
        Status = json['Status'];
        StartedAt = JsonConverters.fromJson(json['StartedAt'],'DateTime',context!);
        CompletedAt = JsonConverters.fromJson(json['CompletedAt'],'DateTime',context!);
        WorkerNotes = json['WorkerNotes'];
        JobName = json['JobName'];
        ProjectName = json['ProjectName'];
        FirstName = json['FirstName'];
        LastName = json['LastName'];
        WorkerName = json['WorkerName'];
        SourceCrewName = json['SourceCrewName'];
        ProjectLocationID = json['ProjectLocationID'];
        ProjectLocationName = json['ProjectLocationName'];
        LocationZip = json['LocationZip'];
        LocationCity = json['LocationCity'];
        LocationLatitude = JsonConverters.toDouble(json['LocationLatitude']);
        LocationLongitude = JsonConverters.toDouble(json['LocationLongitude']);
        JobStatusName = json['JobStatusName'];
        BranchId = json['BranchId'];
        BranchName = json['BranchName'];
        WorkerHomeBranchId = json['WorkerHomeBranchId'];
        WorkerHomeBranchName = json['WorkerHomeBranchName'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'WorkerScheduleItemID': WorkerScheduleItemID,
        'JobID': JobID,
        'ProjectID': ProjectID,
        'ContactID': ContactID,
        'ScheduledDate': JsonConverters.toJson(ScheduledDate,'DateTime',context!),
        'SortOrder': SortOrder,
        'SourceCrewID': SourceCrewID,
        'Status': Status,
        'StartedAt': JsonConverters.toJson(StartedAt,'DateTime',context!),
        'CompletedAt': JsonConverters.toJson(CompletedAt,'DateTime',context!),
        'WorkerNotes': WorkerNotes,
        'JobName': JobName,
        'ProjectName': ProjectName,
        'FirstName': FirstName,
        'LastName': LastName,
        'WorkerName': WorkerName,
        'SourceCrewName': SourceCrewName,
        'ProjectLocationID': ProjectLocationID,
        'ProjectLocationName': ProjectLocationName,
        'LocationZip': LocationZip,
        'LocationCity': LocationCity,
        'LocationLatitude': LocationLatitude,
        'LocationLongitude': LocationLongitude,
        'JobStatusName': JobStatusName,
        'BranchId': BranchId,
        'BranchName': BranchName,
        'WorkerHomeBranchId': WorkerHomeBranchId,
        'WorkerHomeBranchName': WorkerHomeBranchName
    };

    getTypeName() => "WorkerScheduleItem";
    TypeContext? context = _ctx;
}

class SchedulableJob implements IConvertible
{
    int? JobID;
    String? JobName;
    int? ProjectID;
    String? ProjectName;
    int? StatusID;
    String? StatusName;
    int? ProjectLocationID;
    String? ProjectLocationName;
    String? LocationZip;
    String? LocationCity;
    double? LocationLatitude;
    double? LocationLongitude;
    DateTime? ExpectedStartDate;
    DateTime? ExpectedCompletionDate;
    bool? IsRecurring;
    List<String>? OccurrenceDates = [];

    SchedulableJob({this.JobID,this.JobName,this.ProjectID,this.ProjectName,this.StatusID,this.StatusName,this.ProjectLocationID,this.ProjectLocationName,this.LocationZip,this.LocationCity,this.LocationLatitude,this.LocationLongitude,this.ExpectedStartDate,this.ExpectedCompletionDate,this.IsRecurring,this.OccurrenceDates});
    SchedulableJob.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        JobID = json['JobID'];
        JobName = json['JobName'];
        ProjectID = json['ProjectID'];
        ProjectName = json['ProjectName'];
        StatusID = json['StatusID'];
        StatusName = json['StatusName'];
        ProjectLocationID = json['ProjectLocationID'];
        ProjectLocationName = json['ProjectLocationName'];
        LocationZip = json['LocationZip'];
        LocationCity = json['LocationCity'];
        LocationLatitude = JsonConverters.toDouble(json['LocationLatitude']);
        LocationLongitude = JsonConverters.toDouble(json['LocationLongitude']);
        ExpectedStartDate = JsonConverters.fromJson(json['ExpectedStartDate'],'DateTime',context!);
        ExpectedCompletionDate = JsonConverters.fromJson(json['ExpectedCompletionDate'],'DateTime',context!);
        IsRecurring = json['IsRecurring'];
        OccurrenceDates = JsonConverters.fromJson(json['OccurrenceDates'],'List<String>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'JobID': JobID,
        'JobName': JobName,
        'ProjectID': ProjectID,
        'ProjectName': ProjectName,
        'StatusID': StatusID,
        'StatusName': StatusName,
        'ProjectLocationID': ProjectLocationID,
        'ProjectLocationName': ProjectLocationName,
        'LocationZip': LocationZip,
        'LocationCity': LocationCity,
        'LocationLatitude': LocationLatitude,
        'LocationLongitude': LocationLongitude,
        'ExpectedStartDate': JsonConverters.toJson(ExpectedStartDate,'DateTime',context!),
        'ExpectedCompletionDate': JsonConverters.toJson(ExpectedCompletionDate,'DateTime',context!),
        'IsRecurring': IsRecurring,
        'OccurrenceDates': JsonConverters.toJson(OccurrenceDates,'List<String>',context!)
    };

    getTypeName() => "SchedulableJob";
    TypeContext? context = _ctx;
}

class ScheduleWorker implements IConvertible
{
    int? ContactId;
    String? FirstName;
    String? LastName;
    String? Name;
    String? Initials;
    double? Rate;
    String? ImageUrl;
    String? BranchId;
    String? BranchName;

    ScheduleWorker({this.ContactId,this.FirstName,this.LastName,this.Name,this.Initials,this.Rate,this.ImageUrl,this.BranchId,this.BranchName});
    ScheduleWorker.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        ContactId = json['ContactId'];
        FirstName = json['FirstName'];
        LastName = json['LastName'];
        Name = json['Name'];
        Initials = json['Initials'];
        Rate = JsonConverters.toDouble(json['Rate']);
        ImageUrl = json['ImageUrl'];
        BranchId = json['BranchId'];
        BranchName = json['BranchName'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'ContactId': ContactId,
        'FirstName': FirstName,
        'LastName': LastName,
        'Name': Name,
        'Initials': Initials,
        'Rate': Rate,
        'ImageUrl': ImageUrl,
        'BranchId': BranchId,
        'BranchName': BranchName
    };

    getTypeName() => "ScheduleWorker";
    TypeContext? context = _ctx;
}

class Crew implements IConvertible
{
    int? CrewID;
    String? CrewName;
    String? CrewNumber;
    int? CrewManagerContactID;
    String? CrewManagerContactName;
    String? CrewColor;
    DateTime? RecordCreatedDate;
    bool? Active;
    String? CreatedByUID;
    int? ProjectID;
    int? CrewMemberCount;
    int? ProjectCrewID;
    String? ProjectName;
    String? BranchId;
    String? BranchName;

    Crew({this.CrewID,this.CrewName,this.CrewNumber,this.CrewManagerContactID,this.CrewManagerContactName,this.CrewColor,this.RecordCreatedDate,this.Active,this.CreatedByUID,this.ProjectID,this.CrewMemberCount,this.ProjectCrewID,this.ProjectName,this.BranchId,this.BranchName});
    Crew.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        CrewID = json['CrewID'];
        CrewName = json['CrewName'];
        CrewNumber = json['CrewNumber'];
        CrewManagerContactID = json['CrewManagerContactID'];
        CrewManagerContactName = json['CrewManagerContactName'];
        CrewColor = json['CrewColor'];
        RecordCreatedDate = JsonConverters.fromJson(json['RecordCreatedDate'],'DateTime',context!);
        Active = json['Active'];
        CreatedByUID = json['CreatedByUID'];
        ProjectID = json['ProjectID'];
        CrewMemberCount = json['CrewMemberCount'];
        ProjectCrewID = json['ProjectCrewID'];
        ProjectName = json['ProjectName'];
        BranchId = json['BranchId'];
        BranchName = json['BranchName'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'CrewID': CrewID,
        'CrewName': CrewName,
        'CrewNumber': CrewNumber,
        'CrewManagerContactID': CrewManagerContactID,
        'CrewManagerContactName': CrewManagerContactName,
        'CrewColor': CrewColor,
        'RecordCreatedDate': JsonConverters.toJson(RecordCreatedDate,'DateTime',context!),
        'Active': Active,
        'CreatedByUID': CreatedByUID,
        'ProjectID': ProjectID,
        'CrewMemberCount': CrewMemberCount,
        'ProjectCrewID': ProjectCrewID,
        'ProjectName': ProjectName,
        'BranchId': BranchId,
        'BranchName': BranchName
    };

    getTypeName() => "Crew";
    TypeContext? context = _ctx;
}

class ScheduleLastAssignment implements IConvertible
{
    int? JobID;
    List<int>? ContactIds = [];
    int? SourceCrewID;

    ScheduleLastAssignment({this.JobID,this.ContactIds,this.SourceCrewID});
    ScheduleLastAssignment.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        JobID = json['JobID'];
        ContactIds = JsonConverters.fromJson(json['ContactIds'],'List<int>',context!);
        SourceCrewID = json['SourceCrewID'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'JobID': JobID,
        'ContactIds': JsonConverters.toJson(ContactIds,'List<int>',context!),
        'SourceCrewID': SourceCrewID
    };

    getTypeName() => "ScheduleLastAssignment";
    TypeContext? context = _ctx;
}

class ScheduleAutoFillResult implements IConvertible
{
    int? JobsFilled;
    int? JobsSkipped;
    int? VisitsScheduled;

    ScheduleAutoFillResult({this.JobsFilled,this.JobsSkipped,this.VisitsScheduled});
    ScheduleAutoFillResult.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        JobsFilled = json['JobsFilled'];
        JobsSkipped = json['JobsSkipped'];
        VisitsScheduled = json['VisitsScheduled'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'JobsFilled': JobsFilled,
        'JobsSkipped': JobsSkipped,
        'VisitsScheduled': VisitsScheduled
    };

    getTypeName() => "ScheduleAutoFillResult";
    TypeContext? context = _ctx;
}

class WorkerScheduleResponse implements IConvertible
{
    List<WorkerScheduleItem>? Items = [];
    List<SchedulableJob>? SchedulableJobs = [];
    List<ScheduleWorker>? Workers = [];
    List<Crew>? Crews = [];
    List<ScheduleWorker>? BudgetedCrew = [];
    ScheduleLastAssignment? LastAssignment;
    ScheduleAutoFillResult? AutoFill;
    int? DatesScheduled;
    int? WorkersScheduled;
    int? ItemsRemoved;
    ResponseStatus? ResponseStatus;

    WorkerScheduleResponse({this.Items,this.SchedulableJobs,this.Workers,this.Crews,this.BudgetedCrew,this.LastAssignment,this.AutoFill,this.DatesScheduled,this.WorkersScheduled,this.ItemsRemoved,this.ResponseStatus});
    WorkerScheduleResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Items = JsonConverters.fromJson(json['Items'],'List<WorkerScheduleItem>',context!);
        SchedulableJobs = JsonConverters.fromJson(json['SchedulableJobs'],'List<SchedulableJob>',context!);
        Workers = JsonConverters.fromJson(json['Workers'],'List<ScheduleWorker>',context!);
        Crews = JsonConverters.fromJson(json['Crews'],'List<Crew>',context!);
        BudgetedCrew = JsonConverters.fromJson(json['BudgetedCrew'],'List<ScheduleWorker>',context!);
        LastAssignment = JsonConverters.fromJson(json['LastAssignment'],'ScheduleLastAssignment',context!);
        AutoFill = JsonConverters.fromJson(json['AutoFill'],'ScheduleAutoFillResult',context!);
        DatesScheduled = json['DatesScheduled'];
        WorkersScheduled = json['WorkersScheduled'];
        ItemsRemoved = json['ItemsRemoved'];
        ResponseStatus = JsonConverters.fromJson(json['ResponseStatus'],'ResponseStatus',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Items': JsonConverters.toJson(Items,'List<WorkerScheduleItem>',context!),
        'SchedulableJobs': JsonConverters.toJson(SchedulableJobs,'List<SchedulableJob>',context!),
        'Workers': JsonConverters.toJson(Workers,'List<ScheduleWorker>',context!),
        'Crews': JsonConverters.toJson(Crews,'List<Crew>',context!),
        'BudgetedCrew': JsonConverters.toJson(BudgetedCrew,'List<ScheduleWorker>',context!),
        'LastAssignment': JsonConverters.toJson(LastAssignment,'ScheduleLastAssignment',context!),
        'AutoFill': JsonConverters.toJson(AutoFill,'ScheduleAutoFillResult',context!),
        'DatesScheduled': DatesScheduled,
        'WorkersScheduled': WorkersScheduled,
        'ItemsRemoved': ItemsRemoved,
        'ResponseStatus': JsonConverters.toJson(ResponseStatus,'ResponseStatus',context!)
    };

    getTypeName() => "WorkerScheduleResponse";
    TypeContext? context = _ctx;
}

class ScheduleOptimizeRequest implements IConvertible
{
    int? ContactID;
    DateTime? ScheduledDate;
    double? StartLatitude;
    double? StartLongitude;

    ScheduleOptimizeRequest({this.ContactID,this.ScheduledDate,this.StartLatitude,this.StartLongitude});
    ScheduleOptimizeRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        ContactID = json['ContactID'];
        ScheduledDate = JsonConverters.fromJson(json['ScheduledDate'],'DateTime',context!);
        StartLatitude = JsonConverters.toDouble(json['StartLatitude']);
        StartLongitude = JsonConverters.toDouble(json['StartLongitude']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'ContactID': ContactID,
        'ScheduledDate': JsonConverters.toJson(ScheduledDate,'DateTime',context!),
        'StartLatitude': StartLatitude,
        'StartLongitude': StartLongitude
    };

    getTypeName() => "ScheduleOptimizeRequest";
    TypeContext? context = _ctx;
}

TypeContext _ctx = TypeContext(library: 'api.dev.dynamics.trendsic.com', types: <String, TypeInfo> {
    'WorkerScheduleItem': TypeInfo(TypeOf.Class, create:() => WorkerScheduleItem()),
    'SchedulableJob': TypeInfo(TypeOf.Class, create:() => SchedulableJob()),
    'ScheduleWorker': TypeInfo(TypeOf.Class, create:() => ScheduleWorker()),
    'Crew': TypeInfo(TypeOf.Class, create:() => Crew()),
    'ScheduleLastAssignment': TypeInfo(TypeOf.Class, create:() => ScheduleLastAssignment()),
    'ScheduleAutoFillResult': TypeInfo(TypeOf.Class, create:() => ScheduleAutoFillResult()),
    'WorkerScheduleResponse': TypeInfo(TypeOf.Class, create:() => WorkerScheduleResponse()),
    'List<WorkerScheduleItem>': TypeInfo(TypeOf.Class, create:() => <WorkerScheduleItem>[]),
    'List<SchedulableJob>': TypeInfo(TypeOf.Class, create:() => <SchedulableJob>[]),
    'List<ScheduleWorker>': TypeInfo(TypeOf.Class, create:() => <ScheduleWorker>[]),
    'List<Crew>': TypeInfo(TypeOf.Class, create:() => <Crew>[]),
    'ScheduleOptimizeRequest': TypeInfo(TypeOf.Class, create:() => ScheduleOptimizeRequest()),
});

Dart ScheduleOptimizeRequest 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 /v1/schedule/optimize HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	ContactID: 0,
	ScheduledDate: 0001-01-01,
	StartLatitude: 0,
	StartLongitude: 0
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Items: 
	[
		{
			WorkerScheduleItemID: 0,
			JobID: 0,
			ProjectID: 0,
			ContactID: 0,
			ScheduledDate: 0001-01-01,
			SortOrder: 0,
			SourceCrewID: 0,
			Status: String,
			StartedAt: 0001-01-01,
			CompletedAt: 0001-01-01,
			WorkerNotes: String,
			JobName: String,
			ProjectName: String,
			FirstName: String,
			LastName: String,
			WorkerName: String,
			SourceCrewName: String,
			ProjectLocationID: 0,
			ProjectLocationName: String,
			LocationZip: String,
			LocationCity: String,
			LocationLatitude: 0,
			LocationLongitude: 0,
			JobStatusName: String,
			BranchId: 00000000000000000000000000000000,
			BranchName: String,
			WorkerHomeBranchId: 00000000000000000000000000000000,
			WorkerHomeBranchName: String
		}
	],
	SchedulableJobs: 
	[
		{
			JobID: 0,
			JobName: String,
			ProjectID: 0,
			ProjectName: String,
			StatusID: 0,
			StatusName: String,
			ProjectLocationID: 0,
			ProjectLocationName: String,
			LocationZip: String,
			LocationCity: String,
			LocationLatitude: 0,
			LocationLongitude: 0,
			ExpectedStartDate: 0001-01-01,
			ExpectedCompletionDate: 0001-01-01,
			IsRecurring: False,
			OccurrenceDates: 
			[
				String
			]
		}
	],
	Workers: 
	[
		{
			ContactId: 0,
			FirstName: String,
			LastName: String,
			Name: String,
			Initials: String,
			Rate: 0,
			ImageUrl: String,
			BranchId: 00000000000000000000000000000000,
			BranchName: String
		}
	],
	Crews: 
	[
		{
			CrewID: 0,
			CrewName: String,
			CrewNumber: String,
			CrewManagerContactID: 0,
			CrewManagerContactName: String,
			CrewColor: String,
			RecordCreatedDate: 0001-01-01,
			Active: False,
			CreatedByUID: 00000000000000000000000000000000,
			ProjectID: 0,
			CrewMemberCount: 0,
			ProjectCrewID: 0,
			ProjectName: String,
			BranchId: 00000000000000000000000000000000,
			BranchName: String
		}
	],
	BudgetedCrew: 
	[
		{
			ContactId: 0,
			FirstName: String,
			LastName: String,
			Name: String,
			Initials: String,
			Rate: 0,
			ImageUrl: String,
			BranchId: 00000000000000000000000000000000,
			BranchName: String
		}
	],
	LastAssignment: 
	{
		JobID: 0,
		ContactIds: 
		[
			0
		],
		SourceCrewID: 0
	},
	AutoFill: 
	{
		JobsFilled: 0,
		JobsSkipped: 0,
		VisitsScheduled: 0
	},
	DatesScheduled: 0,
	WorkersScheduled: 0,
	ItemsRemoved: 0,
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	}
}