The API has documentation that's available on our website, so if you're not familiar with the OnTime API, I encourage you to go to our website and get the documentation. It's available as a PDF file. Once you have that document, there's lots of good information in here that details all of the differen end points, as well as methods that can be called. You'll see all the different things that you can do with this API and all the details that you'll need to know to use one of the calls.
In this particular example, I thought we could use a very common method, CreateOrder. This is a call that you can make to the API that very simply creates an order in an OnTime account. This table below details all of the information that needs to be fed into the API in order to successfully create an order. As a result, the description tells us that once we submit an order, it should return back to us a tracking number, which will allow us to manipulate or get the status of that order in the future. Let's give this a try in a programming environment and see how easily this can be done.
To do that, I'm going to make use of Microsoft Visual Studio 2013. In fact, I'm going to be using a free version from Microsoft's site. We're going to illustrate how easy it is to integrate the API by using a Windows Form Application. We're going to do this in Visual Basic, keeping it very simple.
What I want to do with my little application here is, I want to have a button on it and, whenever that button is pressed, I want it to submit an order to an OnTime account. So, I'll go into my Toolbox and drag a button onto the form. I'm going to rename it to Submit Order. Again, when somebody clicks on this button, I want it to attach up to the OnTime API. How do I do that? I need to first establish a connection from my project to the OnTime API. Notice how easy this is: in the Solution Explorer, I am going to right-click, and choose Add, Service Reference. From here, I will select the end point that attaches to the corresponding OnTime account. If you have questions on how to get that end point, even though information is mentioned in the API documention, please don't hesitate to contact OnTime Customer Support and we'll be able to direct you on that. Once I have my end point specified, I'm going to give a name to reference it by. We'll call it "OnTimeAPI" and click OK.
Now, in my Solution Explorer, I see a reference to the API. In my code, again the button-click, when somebody clicks that button, I first need to initialize and instance of the API and then I can make calls on it. Let me write that code:
Dim myAPIConnection As New OnTimeAPI.OnTimeOrderSoapClient
So, there is one line of code that initializes an instance of the API and now I can make the call to myAPIConnection.CreateOrder. Notice that we are able to filter down all the parameters, so IntelliSense is working to help us write code. To save a little time here because there's a lot of parameters that would normally need to be entered for an order, I'm just going to copy-and-paste some that I have previously created. I have, for readability, put one parameter on each line. Notice that there's a customer account number. This tells the APi which customer this order should be placed under. Also, who is requesting it, pickup and delivery times, descriptions, address information for collection and for delivery.
We have everything here that needs to be in order to succesfully make this call. Remember from the API documentation earlier that this CreateOrder method, if successful, will return the tracking number of the order as it's placed in the system. We want to be able to capture that and display that to our end user, so that they know that the order was submitted successfully. I'm going to declare a variable here and call it tracking number as a string. Whenever this CreateOrder method finishes, we want it to put that tracking number into our variable. Then, at the bottom, we'll start a message box that will display a little message with the tracking number inside. So it will say, "Order submitted. Your tracking number is:" and then whatever the number happens to be.
Let's go ahead and run our application to see how this works. With our application running, we'll click on Submit Order, and there is our result. Within just a second or so, the API has processedour order, accepted it, and returned a tracking number, 105400.
I happen to have OnTime Management Suite running and we want to see if this all happened in real-time. That's what we're expecting to happen. Let me open up, go to the Tracking View, and there is our order. It came in instantaneously, as soon as the API accepted it.
There is a taste of how easy it is to integrate third-party applications with the OnTime API. It only takes a couple lines of code. It doesn't take days or weeks or months, just a few minutes. And again, the open standards that this works with allows it to work with virtually any programming language that's out there today. I hope this video has been helpful to you. If you have any questions about the OnTime API, please contact the OnTime Customer Support team and we'll be happy to help. Thank you.