Detrack.DetrackCore 1.1.3

dotnet add package Detrack.DetrackCore --version 1.1.3
NuGet\Install-Package Detrack.DetrackCore -Version 1.1.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Detrack.DetrackCore" Version="1.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Detrack.DetrackCore --version 1.1.3
#r "nuget: Detrack.DetrackCore, 1.1.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Detrack.DetrackCore as a Cake Addin
#addin nuget:?package=Detrack.DetrackCore&version=1.1.3

// Install Detrack.DetrackCore as a Cake Tool
#tool nuget:?package=Detrack.DetrackCore&version=1.1.3

Detrack logo

detrack-core-dotnet

Official core library for .NET applications to interact with the Detrack API.

Installation

Install with dotnet-cli:

dotnet add package Detrack.DetrackCore

Add your default API KEY (this can be retrieved from the dashboard web application):

using Detrack.DetrackCore;
Job.DefaultApiKey = "keygoeshere";

Note: All methods below are Http request which is async, therefore it needs wrapped in an async Task method during call and then awaited. (More information on this in the examples)

For single job

Instantiate a new Job class:
Job job = new Job("doNumber", "date", "address");
Create a new job:
// instantiate a job class
Job job = new Job("doNumber", "date", "address");

// static method
await Job.CreateJob(job);
Update a job:

Note:

  • UpdateJob is a non-static method.
  • Both parameters are optional. If not given, it will take the instance's do number and date
// instantiate a job class
Job job = new Job("doNumber", "date", "address");

// instance method
await job.UpdateJob("doNumber", "date");
Retrieve a job:

Note: Returns a Job.

Job job = await Job.RetrieveJob("doNumber", "date");
Delete a job:

Note: Job can only be deleted if its status is "info received" or "out for delivery"

await Job.DeleteJob("doNumber", "date");
Reattempt a job:

Note: Only failed jobs can be reattempted

await Job.ReattemptJob("doNumber", "date");

For multiple jobs

Note: All batch jobs uses List<Job> as a parameter

Create a list of jobs:
List<Job> joblist = new List<Job>();

// instantiate several jobs
Job job1 = new Job("doNumber", "date", "address");
Job job2 = new Job("doNumber", "date", "address");
Job job3 = new Job("doNumber", "date", "address");

// add the instantiated job into the joblist
joblist.Add(job1);
joblist.Add(job2);
joblist.Add(job3);
Batch create jobs:
// create a list of jobs
List<Job> joblist = new List<Job>();

// instantiate several jobs
Job job1 = new Job("doNumber", "date", "address");
Job job2 = new Job("doNumber", "date", "address");
Job job3 = new Job("doNumber", "date", "address");

// (optional) you can change fields before adding them into the list
job1.assignTo = "driver";
job2.OpenToMarketplace = true;

// add the instantiated job into the joblist
joblist.Add(job1);
joblist.Add(job2);
joblist.Add(job3);

// batch create jobs
await Job.CreateJobs(joblist);
Batch update jobs:

Batch update jobs will update job with the specified doNumber and date.

// create a list of jobs
List<Job> joblist = new List<Job>();

// instantiate several jobs
Job job1 = new Job("doNumber", "date", "address");
Job job2 = new Job("doNumber", "date", "address");
Job job3 = new Job("doNumber", "date", "address");

// (optional) you can change fields before adding them into the list
job1.assignTo = "driver";
job2.OpenToMarketplace = true;

// add the instantiated job into the joblist
joblist.Add(job1);
joblist.Add(job2);
joblist.Add(job3);

// batch update jobs
await Job.UpdateJobs(joblist).Wait();
Batch delete jobs:

Batch delete jobs will update job with the specified doNumber and date.

// create a list of jobs
List<Job> joblist = new List<Job>();

// instantiate several jobs
Job job1 = new Job("doNumber", "date", "address");
Job job2 = new Job("doNumber", "date", "address");
Job job3 = new Job("doNumber", "date", "address");

// add the instantiated job into the joblist
joblist.Add(job1);
joblist.Add(job2);
joblist.Add(job3);

// batch delete jobs
await Job.DeleteJobs(joblist);

Extra Functions

List All Jobs:

Note:

  • Returns List<Job>
  • Parameters available is : page, limit, date, type, assignTo, status, DONumber. ALl parameters are optional parameters (giving an empty Dictionary<string, string> will still work.)
  • assignTo can be "name of driver", "unassigned" or empty.
// create a dictionary with type string as key and values
Dictionary<string,string> parameters = new Dictionary<string,string>();

// add your parameters
parameters.Add("page", 5);
parameters.Add("date", "2019-05-01");
parameters.Add("status", Status.completed_partial.ToString());
parameters.Add("assignTo", "unassigned") //or parameters.Add("assignTo", "your driver")

// list all jobs
List<Job> joblist = await Job.ListAllJobs(parameters);
Download Job POD or shipping label as pdf:

Note: pathToSaveFile will start in the folder that contains the dll. If you want to go out of the folder then do ..

await Job.DownloadJobExport("doNumber", "pathToSaveFile", "documentType(pod or shipping-label)", "date");

Adding Items on a Job

Note:

  • Updating an item requires you to create a new Item class and push the update
  • Pushing an item will delete all the existing items so if youwant to have multiple items make sure to update them in 1 request
Adding Items
// instantiate a job
Job job = new Job("doNumber", "date", "address");

// create a new item class
Item item = new Item();

// (optional) Change some fields here
item.Description = "Insert description here";
item.Quantity = 15;
item.RejectQuantity= 20;

// add the itemlist into the job
job.Items.Add(item);

// update the job
await Job.UpdateJob("doNumber", "date");

Examples

Note: As mentioned before, Http request is async so the methods must be wrapped in an async method. .Wait() and .Result() will cause instant deadlock when called from a UI thread. It will work fine on console but considered an unsafe practice. Below is one way to avoid the deadlock :

using System.Threading.Tasks;
using Detrack.DetrackCore;

public static async Task CreatingJob()
{
    Job.DefaultApiKey = "yourapikey";
    Job job = new Job("doNumber", "date", "address");
    await Job.CreateJob(job);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.3 732 7/12/2019
1.1.2 526 7/10/2019
1.1.1 516 7/8/2019

Added Vehicle Type