Basic API Structure

Basic information on the base API Request and Response objects common to all API calls.

API Call

Once the typed Request is created, the API call can be made using the following format:

//Sending a request
ApsWebServiceResponseBase resp = client.Optimize(optimizeRequest);

    API Request Base Classes

    Depending on the API call, PlanetTogether API Request objects need to inherit from one of the base request classes listed below. 

    • APSWebServiceRequestBase contains information about user credentials and connection timeout. 
    [DataContract]
    public class ApsWebServiceRequestBase
    {
    [DataMember(IsRequired = true)]
    public string UserName { get; set; }

    [DataMember(IsRequired = false)]
    public string Password { get; set; } = string.Empty;

    [DataMember(IsRequired = false)]
    public TimeSpan TimeoutDuration { get; set; } = TimeSpan.FromSeconds(30);
    }
    • ApsWebServiceScenarioRequests inherits from ApsWebServiceRequestBase and adds the scenario Id parameter. It is used to make API calls that trigger a simulation specific to a particular scenario or all scenarios.
    [DataContract]
    public class ApsWebServiceScenarioRequest : ApsWebServiceRequestBase
    {
    [DataMember(IsRequired = false)]
    public long ScenarioId { get; set; }
    }
    • ApsWebServiceActionRequest inherits from ApsWebServiceScenarioRequest and adds the PtObjectId[] array parameter which is used to specify activity information. Each ObjectId contains ActivityId, OperationId, ManufacturingOrderId and JobId.
    [DataContract]
    public class ApsWebServiceActionRequest : ApsWebServiceScenarioRequest
    {
    [DataMember(IsRequired = true)]
    public PtObjectId[] PtObjects { get; set; }
    }

    API Response

    The API Response, in the form of API Response Base, will be received in response to sending the API Request and can be used to display messages to the user through the related web client.

    • Data Contract
    [DataContract]
    public class ApsWebServiceResponseBase
    {
    public ApsWebServiceResponseBase()
    {
    //Default constructor for serialization
    Exception = false;
    FullExceptionText = "";
    }

    public ApsWebServiceResponseBase(EApsWebServicesResponseCodes a_responseCode, string a_exceptionText)
    {
    ResponseCode = a_responseCode;
    if (!string.IsNullOrEmpty(a_exceptionText))
    {
    Exception = true;
    FullExceptionText = a_exceptionText;
    }
    }

    public ApsWebServiceResponseBase(EApsWebServicesResponseCodes a_responseCode)
    {
    ResponseCode = a_responseCode;
    Exception = false;
    FullExceptionText = "";
    }

    [DataMember(IsRequired = true)]
    public EApsWebServicesResponseCodes ResponseCode { get; set; }

    [DataMember(IsRequired = true)]
    public bool Exception { get; set; } = false;

    [DataMember(IsRequired = false)]
    public string FullExceptionText { get; set; }
    }
    • Response Example
    //Sending a request
    start = DateTime.Now;
    ApsWebServiceResponseBase resp = client.Optimize(optimizeRequest);
    Console.WriteLine($"Response received after '{DateTime.Now.Subtract(start)}'");

    //Display results
    if (!a_response.Exception)
    {
    Trace($"Completed with Zero Errors");
    }
    else
    {
    Trace($"Completed with Errors");
    Trace(a_response.FullExceptionText);
    }