Step 1: Getting Started with the Vetspace API

The API is based upon Swagger IO / Open API set of tools, and we have provided the Public YAML Document as well as Documentation.

The simplest way to think of this API is a way to call an interface with a "standard" URL.

This url defines the service requested and also passes parameters to the URL, for example :-

http://my-host-name.com/my-service-name/parameter1/parameter2/

Essentially this says :-

  • Call service my-service-name and give it parameters parameter1 and parameter2
The service would respond by checking that everything is as expected, and would respond with some JSON

The JSON might look like this :-


				
{ "ApiResponseList": { "responseType": "Response", "uuid": "1", "responseText": "Response was successful", "responseList": [ { "AvgWait": [ { "id": 1101, "avgWaitMins": 0, "numberWaiting": 0, "siteId": 1101, "siteName": "Esher" }, { "id": 1106, "avgWaitMins": 0, "numberWaiting": 0, "siteId": 1106, "siteName": "Walton" }, { "id": 1107, "avgWaitMins": 0, "numberWaiting": 0, "siteId": 1107, "siteName": "Guildford" } ] } ], "responseTimestamp": 1474024455750 } }

If you have any questions about the API or usage, please contact support@vetspace.com.

Step 2: Read the specifications

Head over to the V2 Api Documentation to read more about available methods and how things work.

This documentation allows you to generate code for the API clients in most recognised languages, such as Java, C# or PHP.

If you have any questions about the API or usage, please contact support@vetspace.com.

Step 3: Try it out

If you've been given a demo API key by our support team, you can try out the documentation yourself.

If you haven't got an API key yet, some of the calls will still work, so please head over to the documentation and give it a try.

If you have any questions about the API or usage, please contact support@vetspace.com.

Step 4: Begin Implementing

Once you're fully up to speed with the V2 API, it's possible to begin implementation immediately.

You are able to generate client code directly from https://editor.swagger.io that will generate your client code, by cutting and pasting our swagger.json file content in directly.

Your unit test code might look a lot like this (and as you can imagine, your client code isn't much different!) :-

/**
 * Vetspace Global Api GlobalApi is a 3rd party integration hub developed for
 * Vetspace Ltd.
 *
 * OpenAPI spec version: 2.0.0 Contact: support@vetspace.com
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git Do not edit the class
 * manually.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package test.java.io.swagger.api;

import static org.junit.Assert.assertNotNull;

import java.util.ArrayList;
import java.util.List;

import org.apache.cxf.jaxrs.client.ClientConfiguration;
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
import org.apache.cxf.jaxrs.client.WebClient;
import org.junit.Before;
import org.junit.Test;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;

import io.swagger.api.V2authApi;
import io.swagger.api.V2mobileApi;
import io.swagger.model.ApiResponseAccessToken;
import io.swagger.model.ApiResponseListBarcodeMO;
import io.swagger.model.ApiResponseListStockLevelsMO;
import io.swagger.model.ApiResponseUserVerified;

/**
 * API tests for V2mobileApi
 */
public class UnitTestExampleClass {
	private final String server = "https://dev-api.vetspace.cloud";
	private final String apiAccount = "21DF1383-2FD3-4B53-B65E-1551AB56919E";
	private final String apiKey = "1F2F3B62-DE86-400D-8369-923C040CFBB6";
	private final String uName = "vetspaceclient@gmail.com";
	private final String pass = "password";
	private final Long groupId = new Long(4);
	private final Integer siteId = 1101;
	private V2mobileApi api;
	private V2authApi authApi;

	@Before
	public void setup() {
		JacksonJsonProvider provider = new JacksonJsonProvider();
		List providers = new ArrayList();
		providers.add(provider);

		api = JAXRSClientFactory.create(server, V2mobileApi.class, providers);
		org.apache.cxf.jaxrs.client.Client client = WebClient.client(api);

		ClientConfiguration config = WebClient.getConfig(client);

		JacksonJsonProvider providerAuth = new JacksonJsonProvider();
		providers.add(providerAuth);

		authApi = JAXRSClientFactory.create(server, V2authApi.class, providers);
		org.apache.cxf.jaxrs.client.Client clientAuth = WebClient.client(authApi);

		ClientConfiguration configAuth = WebClient.getConfig(clientAuth);
	}

	/**
	 * Get barcodes
	 *
	 * Bar codes retrieval - /retrieveBarCodes/{groupId}/{siteId}/
	 *
	 * @throws ApiException
	 *             if the Api call fails
	 */
	@Test
	public void barCodesTest() {
		String apiToken = getToken();
		String apiUserToken = getUserToken(apiToken);
		ApiResponseListBarcodeMO response = api.barCodes(apiAccount, apiKey, groupId, siteId, apiToken, apiUserToken);
		assertNotNull(response);

	}

	/**
	 * /retrieveStockLevels/{groupId}/{siteId}/{stockCentreId}/{codeTypeId}
	 *
	 * Retrieve a list of stock centres for a stock centreid
	 *
	 * @throws ApiException
	 *             if the Api call fails
	 */
	@Test
	public void retrieveStockLevelsTest() {
		Integer stockCentreId = 1;
		Integer codeTypeId = 1;
		String apiToken = getToken();
		String apiUserToken = getUserToken(apiToken);
		ApiResponseListStockLevelsMO response = api.retrieveStockLevels(groupId, siteId, stockCentreId, codeTypeId, apiToken, apiUserToken, apiAccount, apiKey);
		assertNotNull(response);

	}

	/**
	 * getToken: gets the authorisation to use the API
	 *
	 * Retrieve a list of stock centres for a stock centreid
	 *
	 * @throws ApiException
	 *             if the Api call fails
	 */
	private String getToken() {
		String apiToken = null;

		ApiResponseAccessToken response = authApi.login1(apiAccount, apiKey);
		apiToken = response.getResponseObject().getAccessToken();
		return apiToken;
	}

	/**
	 * getToken: gets the authorisation to use the API
	 *
	 * Retrieve a list of stock centres for a stock centreid
	 *
	 * @throws ApiException
	 *             if the Api call fails
	 */
	private String getUserToken(String apiToken) {
		String apiUserToken = null;

		ApiResponseUserVerified response = authApi.verifyUserNew1(apiAccount, apiKey, apiToken, uName, pass);
		String apiNewToken = response.getResponseObject().getUserToken();
		return apiNewToken;

	}

}

		    
		    

If you have any questions about the API or usage, please contact support@vetspace.com.

Useful Links

You may wish to look at these resources :-

NOTE: Please note that none of these guides are officially supported, and use of these is clearly at your own risk.

If you have any questions about the API or usage, please contact support@vetspace.com.