Created and provided by OrderYOYO
For a complete documentation of all endpoints offered by the Stuart API, you can visit Stuart API documentation.
Via NuGet Package Manager:
$ PM> Install-Package stuart-client-csharp -Version 1.3.4- Initialize Client
- Create a Job
- Get a Job
- Cancel a Job
- Validate a Job
- Cancel a delivery
- Get a pricing
- Get a job eta to pickup
varclientId="<put_your_ID_here>";// can be found here: https://admin.sandbox.stuart.com/client/apivarclientSecret="<put_your_secret_here>";// can be found here: https://admin.sandbox.stuart.com/client/apivarenvironment=Environment.Sandbox;varstuartApi=StuartApi.Initialize(environment,clientId,clientSecret);Important: Even if you can create a Job with a minimal set of parameters, we highly recommend that you fill as many information as you can in order to ensure the delivery process goes well.
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);varjob=newJobRequest{Job=newJob{TransportType=TransportType.bike
PickUps =newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris"}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageType=PackageSizeType.small,PackageDescription="Pizza box",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);varjob=newJobRequest{Job=newJob{TransportType=TransportType.bike
PickUps =newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageDescription="Pizza box",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);For more information about job scheduling you should check our API documentation.
varjob=newJobRequest{Job=newJob{PickUpAt=DateTime.UtcNow.AddHours(2),PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);For more information about job scheduling you should check our API documentation.
Please note that this feature can only be used with only one dropoff.
varjob=newJobRequest{Job=newJob{DropOffAt=DateTime.UtcNow.AddHours(2),PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageType=PackageSizeType.small,PackageDescription="Red packet.",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}},newDropOff{PackageType=PackageSizeType.small,PackageDescription="Blue packet.",ClientReference="ABCDE213124",// Must be uniqueAddress="156 rue de Charonne, 75011 Paris",Comment="code: 92A42. 2e étage gauche",Contact=newContact{FirstName="Maximilien",LastName="Lebluc",Phone="+33632341209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);varjob=newJobRequest{Job=newJob{TransportType=TransportType.bike
PickUps =newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris",Comment="Wait outside for an employee to come.",Contact=newContact{FirstName="Martin",LastName="Pont",Phone="+33698348756",Company="KFC Paris Barbès"}}},DropOffs=newList<DropOff>{newDropOff{PackageDescription="Red packet.",ClientReference="12345678ABCDE",// Must be uniqueAddress="42 rue rivoli, 75001 Paris",Comment="code: 3492B. 3e étage droite. Sonner à Durand.",Contact=newContact{FirstName="Alex",LastName="Durand",Phone="+33634981209",}},newDropOff{PackageDescription="Blue packet.",ClientReference="ABCDE213124",// Must be uniqueAddress="156 rue de Charonne, 75011 Paris",Comment="code: 92A42. 2e étage gauche",Contact=newContact{FirstName="Maximilien",LastName="Lebluc",Phone="+33632341209",}}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);Once you successfully created a Job you can retrieve it this way:
varjobId=126532;varjob=awaitStuartApi.Job.GetJob(jobId);Or when you create a new Job:
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varcreatedJob=awaitStuartApi.Job.CreateJob(job);createdJob.DeliveriesThe Stuart API determine the optimal route on your behalf,
that's why the createdJob.Deliveries propery will be empty
List when the Job has not been created yet. The createdJob.Deliveries
propery will contain a List of Delivery as soon as the Job is created.
Once you successfully created a Job you can cancel it in this way:
varjobId=126532;awaitStuartApi.Job.CancelJob(jobId);The method CancelJob(); will return only Task if the job was cancelled. If
there was an error, it will throw an exception with information about reason.
For more details about how cancellation works, please refer to our dedicated documentation section.
Before creating a Job you can validate it (control delivery area & address format). Validating a Job is optional and does not prevent you from creating a Job.
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varresult=awaitStuartApi.Job.ValidateParameters(job);The result will hold the boolean value true if the job is valid. If
there was an error, it will throw an exception with information about reason.
Once you successfully created a Delivery you can cancel it in this way:
vardeliveryId=126532;awaitStuartApi.Job.CancelDelivery(deliveryId);Before creating a Job you can ask for a pricing. Asking for a pricing is optional and does not prevent you from creating a Job.
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};varresult=awaitStuartApi.Job.RequestJobPricing(job);result.Amount;// example: 11.5result.Currency;// example: "EUR"Before creating a Job you can ask for an estimated time of arrival at the pickup location (expressed in seconds). Asking for ETA is optional and does not prevent you from creating a job.
varjob=newJobRequest{Job=newJob{PickUps=newList<PickUp>{newPickUp{Address="12 rue rivoli, 75001 Paris"}},DropOffs=newList<DropOff>{newDropOff{Address="42 rue rivoli, 75001 Paris",PackageType=PackageSizeType.small}}}};vareta=awaitStuartApi.Job.RequestEta(job);eta;// example: 672