1Fetch Client API

<back to all web services

PlaceOrder

The following routes are available for this service:
POST/orderProvide waypoints for a route and place an order. This will bill the order to your account.
import 'package:servicestack/servicestack.dart';

class ApiServiceRequest implements IServiceRequest, IHasApiKey, IConvertible
{
    /**
    * The API Key required for authentication
    */
    // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
    String? ApiKey;

    ApiServiceRequest({this.ApiKey});
    ApiServiceRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }

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

    Map<String, dynamic> toJson() => {
        'ApiKey': ApiKey
    };

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

class ApiServiceResponse implements IServiceResponse, IConvertible
{
    /**
    * Information about the response.
    */
    // @ApiMember(Description="Information about the response.", IsRequired=true)
    String? Description;

    /**
    * Heading or summary of the response.
    */
    // @ApiMember(Description="Heading or summary of the response.", IsRequired=true)
    String? Heading;

    /**
    * Did the intended operation for this response complete successfully?
    */
    // @ApiMember(DataType="boolean", Description="Did the intended operation for this response complete successfully?", IsRequired=true)
    bool? WasSuccessful;

    ApiServiceResponse({this.Description,this.Heading,this.WasSuccessful});
    ApiServiceResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        Description = json['Description'];
        Heading = json['Heading'];
        WasSuccessful = json['WasSuccessful'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'Description': Description,
        'Heading': Heading,
        'WasSuccessful': WasSuccessful
    };

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

class LinkedWaypoint implements IConvertible
{
    int? FromWaypointNumber;
    int? ToWaypointNumber;
    double? FromLatitude;
    double? FromLongitude;
    double? ToLatitude;
    double? ToLongitude;

    LinkedWaypoint({this.FromWaypointNumber,this.ToWaypointNumber,this.FromLatitude,this.FromLongitude,this.ToLatitude,this.ToLongitude});
    LinkedWaypoint.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        FromWaypointNumber = json['FromWaypointNumber'];
        ToWaypointNumber = json['ToWaypointNumber'];
        FromLatitude = JsonConverters.toDouble(json['FromLatitude']);
        FromLongitude = JsonConverters.toDouble(json['FromLongitude']);
        ToLatitude = JsonConverters.toDouble(json['ToLatitude']);
        ToLongitude = JsonConverters.toDouble(json['ToLongitude']);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'FromWaypointNumber': FromWaypointNumber,
        'ToWaypointNumber': ToWaypointNumber,
        'FromLatitude': FromLatitude,
        'FromLongitude': FromLongitude,
        'ToLatitude': ToLatitude,
        'ToLongitude': ToLongitude
    };

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

class WaypointQuoteInformation extends LinkedWaypoint implements IConvertible
{
    /**
    * Distance between waypoints as a number
    */
    // @ApiMember(Description="Distance between waypoints as a number")
    double? Distance;

    /**
    * String formatted distance
    */
    // @ApiMember(Description="String formatted distance")
    String? DistanceValue;

    bool? WaypointValid;
    String? Message;
    List<String>? ErrorDetails;
    /**
    * Caculated price between waypoints excluding vat
    */
    // @ApiMember(Description="Caculated price between waypoints excluding vat")
    double? Price;

    /**
    * Price excluding vat formatted as a string rand value
    */
    // @ApiMember(Description="Price excluding vat formatted as a string rand value")
    String? PriceValue;

    /**
    * The price between waypoints including vat
    */
    // @ApiMember(Description="The price between waypoints including vat")
    double? PriceWithVAT;

    /**
    * The price including vat formatted as a rand value string
    */
    // @ApiMember(Description="The price including vat formatted as a rand value string")
    String? PriceValueWithVAT;

    WaypointQuoteInformation({this.Distance,this.DistanceValue,this.WaypointValid,this.Message,this.ErrorDetails,this.Price,this.PriceValue,this.PriceWithVAT,this.PriceValueWithVAT});
    WaypointQuoteInformation.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        Distance = JsonConverters.toDouble(json['Distance']);
        DistanceValue = json['DistanceValue'];
        WaypointValid = json['WaypointValid'];
        Message = json['Message'];
        ErrorDetails = JsonConverters.fromJson(json['ErrorDetails'],'List<String>',context!);
        Price = JsonConverters.toDouble(json['Price']);
        PriceValue = json['PriceValue'];
        PriceWithVAT = JsonConverters.toDouble(json['PriceWithVAT']);
        PriceValueWithVAT = json['PriceValueWithVAT'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'Distance': Distance,
        'DistanceValue': DistanceValue,
        'WaypointValid': WaypointValid,
        'Message': Message,
        'ErrorDetails': JsonConverters.toJson(ErrorDetails,'List<String>',context!),
        'Price': Price,
        'PriceValue': PriceValue,
        'PriceWithVAT': PriceWithVAT,
        'PriceValueWithVAT': PriceValueWithVAT
    });

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

class WaypointValidationInformation implements IConvertible
{
    int? WaypointNumber;
    bool? IsValid;
    List<String>? ErrorMessages;

    WaypointValidationInformation({this.WaypointNumber,this.IsValid,this.ErrorMessages});
    WaypointValidationInformation.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        WaypointNumber = json['WaypointNumber'];
        IsValid = json['IsValid'];
        ErrorMessages = JsonConverters.fromJson(json['ErrorMessages'],'List<String>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => {
        'WaypointNumber': WaypointNumber,
        'IsValid': IsValid,
        'ErrorMessages': JsonConverters.toJson(ErrorMessages,'List<String>',context!)
    };

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

class PlaceOrderResponse extends ApiServiceResponse implements IConvertible
{
    /**
    * The ID of the order.
    */
    // @ApiMember(Description="The ID of the order.")
    String? OrderId;

    /**
    * Were there any validation issues for any waypoints
    */
    // @ApiMember(Description="Were there any validation issues for any waypoints")
    bool? WaypointIssue;

    /**
    * The total distance for the order
    */
    // @ApiMember(Description="The total distance for the order")
    double? TotalDistance;

    /**
    * The total distance for the order, formatted as a string
    */
    // @ApiMember(Description="The total distance for the order, formatted as a string")
    String? TotalDistanceValue;

    /**
    * The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true
    */
    // @ApiMember(Description="The date and time the order is scheduled for in ISO 8601 string format, will be set if IsScheduled is true")
    String? ScheduledDate;

    /**
    * The subtotal of the order before VAT
    */
    // @ApiMember(Description="The subtotal of the order before VAT")
    String? SubTotal;

    /**
    * The total of the order after VAT
    */
    // @ApiMember(Description="The total of the order after VAT")
    String? FinalPrice;

    /**
    * The amount of VAT 
    */
    // @ApiMember(Description="The amount of VAT ")
    String? VATValue;

    /**
    * Will contain a message if there a problem with a scheduled order
    */
    // @ApiMember(Description="Will contain a message if there a problem with a scheduled order")
    String? SchedulingNotice;

    /**
    * Will contain a message if there is a problem with a scheduled quote, if the order is scheduled to soon to opening times
    */
    // @ApiMember(Description="Will contain a message if there is a problem with a scheduled quote, if the order is scheduled to soon to opening times")
    String? SchedulingError;

    /**
    * User friendly waybill number
    */
    // @ApiMember(Description="User friendly waybill number")
    String? WayBill;

    /**
    * List of order information for pricing etc between each waypoint
    */
    // @ApiMember(Description="List of order information for pricing etc between each waypoint")
    List<WaypointQuoteInformation>? Waypoints;

    /**
    * List with validation information for each waypoint
    */
    // @ApiMember(Description="List with validation information for each waypoint")
    List<WaypointValidationInformation>? WaypointValidations;

    PlaceOrderResponse({this.OrderId,this.WaypointIssue,this.TotalDistance,this.TotalDistanceValue,this.ScheduledDate,this.SubTotal,this.FinalPrice,this.VATValue,this.SchedulingNotice,this.SchedulingError,this.WayBill,this.Waypoints,this.WaypointValidations});
    PlaceOrderResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        OrderId = json['OrderId'];
        WaypointIssue = json['WaypointIssue'];
        TotalDistance = JsonConverters.toDouble(json['TotalDistance']);
        TotalDistanceValue = json['TotalDistanceValue'];
        ScheduledDate = json['ScheduledDate'];
        SubTotal = json['SubTotal'];
        FinalPrice = json['FinalPrice'];
        VATValue = json['VATValue'];
        SchedulingNotice = json['SchedulingNotice'];
        SchedulingError = json['SchedulingError'];
        WayBill = json['WayBill'];
        Waypoints = JsonConverters.fromJson(json['Waypoints'],'List<WaypointQuoteInformation>',context!);
        WaypointValidations = JsonConverters.fromJson(json['WaypointValidations'],'List<WaypointValidationInformation>',context!);
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'OrderId': OrderId,
        'WaypointIssue': WaypointIssue,
        'TotalDistance': TotalDistance,
        'TotalDistanceValue': TotalDistanceValue,
        'ScheduledDate': ScheduledDate,
        'SubTotal': SubTotal,
        'FinalPrice': FinalPrice,
        'VATValue': VATValue,
        'SchedulingNotice': SchedulingNotice,
        'SchedulingError': SchedulingError,
        'WayBill': WayBill,
        'Waypoints': JsonConverters.toJson(Waypoints,'List<WaypointQuoteInformation>',context!),
        'WaypointValidations': JsonConverters.toJson(WaypointValidations,'List<WaypointValidationInformation>',context!)
    });

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

class RequestQuoteWaypoint implements IRequestWaypoint, IConvertible
{
    /**
    * Number of waypoint for ordering
    */
    // @ApiMember(Description="Number of waypoint for ordering", IsRequired=true)
    int? WaypointNumber;

    /**
    * Waypoint Latitude
    */
    // @ApiMember(Description="Waypoint Latitude", IsRequired=true)
    double? Latitude;

    /**
    * Waypoint Longitude
    */
    // @ApiMember(Description="Waypoint Longitude", IsRequired=true)
    double? Longitude;

    /**
    * Name of contact person at waypoint
    */
    // @ApiMember(Description="Name of contact person at waypoint", IsRequired=true)
    String? ContactName;

    /**
    * Telephone number of contact person at waypoint
    */
    // @ApiMember(Description="Telephone number of contact person at waypoint", IsRequired=true)
    String? ContactNumber;

    /**
    * Instructions for driver to follow at waypoint
    */
    // @ApiMember(Description="Instructions for driver to follow at waypoint", IsRequired=true)
    String? DeliveryInstructions;

    /**
    * Waypoint address
    */
    // @ApiMember(Description="Waypoint address", IsRequired=true)
    String? Address;

    RequestQuoteWaypoint({this.WaypointNumber,this.Latitude,this.Longitude,this.ContactName,this.ContactNumber,this.DeliveryInstructions,this.Address});
    RequestQuoteWaypoint.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        WaypointNumber = json['WaypointNumber'];
        Latitude = JsonConverters.toDouble(json['Latitude']);
        Longitude = JsonConverters.toDouble(json['Longitude']);
        ContactName = json['ContactName'];
        ContactNumber = json['ContactNumber'];
        DeliveryInstructions = json['DeliveryInstructions'];
        Address = json['Address'];
        return this;
    }

    Map<String, dynamic> toJson() => {
        'WaypointNumber': WaypointNumber,
        'Latitude': Latitude,
        'Longitude': Longitude,
        'ContactName': ContactName,
        'ContactNumber': ContactNumber,
        'DeliveryInstructions': DeliveryInstructions,
        'Address': Address
    };

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

class ScheduleType
{
    static const ScheduleType NextAvailable = const ScheduleType._(0);
    static const ScheduleType SpecificTime = const ScheduleType._(1);

    final int _value;
    const ScheduleType._(this._value);
    int get value => _value;
    static List<ScheduleType> get values => const [NextAvailable,SpecificTime];
}

class PlaceOrder extends ApiServiceRequest implements ILogRequest, IConvertible
{
    /**
    * Optionally provide your own reference identifier
    */
    // @ApiMember(Description="Optionally provide your own reference identifier")
    String? ClientReference;

    /**
    * Optionally provide a reference for the customer/business
    */
    // @ApiMember(Description="Optionally provide a reference for the customer/business")
    String? CustomerReference;

    /**
    * Array of waypoints
    */
    // @ApiMember(Description="Array of waypoints", IsRequired=true)
    List<RequestQuoteWaypoint>? Waypoints;

    /**
    * Is this a scheduled order?
    */
    // @ApiMember(Description="Is this a scheduled order?", IsRequired=true)
    bool? IsScheduled;

    /**
    * Specify the scheduling type, required if IsScheduled is true
    */
    // @ApiMember(Description="Specify the scheduling type, required if IsScheduled is true")
    ScheduleType? ScheduleType;

    /**
    * Specify the scheduled date for this delivery in ISO 8601 string format, required if IsScheduled is true and ScheduleType is SpecificTime
    */
    // @ApiMember(Description="Specify the scheduled date for this delivery in ISO 8601 string format, required if IsScheduled is true and ScheduleType is SpecificTime")
    String? ScheduledDate;

    /**
    * Set this to true to prevent creating an order and billing for it
    */
    // @ApiMember(Description="Set this to true to prevent creating an order and billing for it", IsRequired=true)
    bool? Test;

    /**
    * Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.
    */
    // @ApiMember(Description="Is your account allows Urgent Orders, you can use this flag to indicate when an Order is urgent.")
    bool? IsUrgent;

    PlaceOrder({this.ClientReference,this.CustomerReference,this.Waypoints,this.IsScheduled,this.ScheduleType,this.ScheduledDate,this.Test,this.IsUrgent});
    PlaceOrder.fromJson(Map<String, dynamic> json) { fromMap(json); }

    fromMap(Map<String, dynamic> json) {
        super.fromMap(json);
        ClientReference = json['ClientReference'];
        CustomerReference = json['CustomerReference'];
        Waypoints = JsonConverters.fromJson(json['Waypoints'],'List<RequestQuoteWaypoint>',context!);
        IsScheduled = json['IsScheduled'];
        ScheduleType = JsonConverters.fromJson(json['ScheduleType'],'ScheduleType',context!);
        ScheduledDate = json['ScheduledDate'];
        Test = json['Test'];
        IsUrgent = json['IsUrgent'];
        return this;
    }

    Map<String, dynamic> toJson() => super.toJson()..addAll({
        'ClientReference': ClientReference,
        'CustomerReference': CustomerReference,
        'Waypoints': JsonConverters.toJson(Waypoints,'List<RequestQuoteWaypoint>',context!),
        'IsScheduled': IsScheduled,
        'ScheduleType': JsonConverters.toJson(ScheduleType,'ScheduleType',context!),
        'ScheduledDate': ScheduledDate,
        'Test': Test,
        'IsUrgent': IsUrgent
    });

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

TypeContext _ctx = TypeContext(library: 'api.1fetch.co.za', types: <String, TypeInfo> {
    'ApiServiceRequest': TypeInfo(TypeOf.Class, create:() => ApiServiceRequest()),
    'ApiServiceResponse': TypeInfo(TypeOf.Class, create:() => ApiServiceResponse()),
    'LinkedWaypoint': TypeInfo(TypeOf.Class, create:() => LinkedWaypoint()),
    'WaypointQuoteInformation': TypeInfo(TypeOf.Class, create:() => WaypointQuoteInformation()),
    'WaypointValidationInformation': TypeInfo(TypeOf.Class, create:() => WaypointValidationInformation()),
    'PlaceOrderResponse': TypeInfo(TypeOf.Class, create:() => PlaceOrderResponse()),
    'List<WaypointQuoteInformation>': TypeInfo(TypeOf.Class, create:() => <WaypointQuoteInformation>[]),
    'List<WaypointValidationInformation>': TypeInfo(TypeOf.Class, create:() => <WaypointValidationInformation>[]),
    'RequestQuoteWaypoint': TypeInfo(TypeOf.Class, create:() => RequestQuoteWaypoint()),
    'ScheduleType': TypeInfo(TypeOf.Enum, enumValues:ScheduleType.values),
    'PlaceOrder': TypeInfo(TypeOf.Class, create:() => PlaceOrder()),
    'List<RequestQuoteWaypoint>': TypeInfo(TypeOf.Class, create:() => <RequestQuoteWaypoint>[]),
});

Dart PlaceOrder DTOs

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

HTTP + OTHER

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

POST /order HTTP/1.1 
Host: api.1fetch.co.za 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"ClientReference":"String","CustomerReference":"String","Waypoints":[{"WaypointNumber":0,"Latitude":0,"Longitude":0,"ContactName":"String","ContactNumber":"String","DeliveryInstructions":"String","Address":"String"}],"IsScheduled":false,"ScheduleType":0,"ScheduledDate":"String","Test":false,"IsUrgent":false,"ApiKey":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"OrderId":"00000000-0000-0000-0000-000000000000","WaypointIssue":false,"TotalDistance":0,"TotalDistanceValue":"0","ScheduledDate":"String","SubTotal":"String","FinalPrice":"String","VATValue":"String","SchedulingNotice":"String","SchedulingError":"String","WayBill":"String","Waypoints":[{}],"WaypointValidations":[{}],"Description":"String","Heading":"String","WasSuccessful":false}