Prerequisites
To use the Tradenity SDK, you must have:
- Working Java development environment (currently JDK 1.7 is the only tested version, but Java 6 and 8 should work).
- Active account in Tradenity, sign up now, It is free.
API Reference documentation (Javadoc)
You can browse the SDK JavaDocs here
Spring framework extension JavaDocs here
Installation
The SDK is available through our maven repository, You can install it using any compatible tool.
Add this repository definition to your maven pom.xml
file.
<repository>
<id>tradenity-public</id>
<name>tradenity-public-releases</name>
<url>http://artifacts.tradenity.com/artifactory/tradenity-release-public</url>
</repository>
Maven
<dependency>
<groupId>com.tradenity</groupId>
<artifactId>java-sdk</artifactId>
<version>0.8.1</version>
</dependency>
Gradle
com.tradenity:java-sdk:0.8.1
Ivy
<dependency org="com.tradenity" name="java-sdk" rev="0.8.1"/>
Setup your credentials
First of all, you have to get API keys for your store, you can find it in your store Edit
page.
To get there navigate to the stores list page, click on the Edit
button next to your store name, scroll down till you find the API Keys
section.
Initialize the library
With the API key in hand, you can initialize the Tradenity client.
Tradenity client needs the API key and an instance of SessionTokenStore
which is an object that makes Tradenity session integrates with the web framework’s session mechanism.
The Java SDK provide the interface and a default implementation suitable for single user application (such as android app).
The Spring SDK extension provide implementation suitable for Spring and Grails. It’s easy to implement your own for other frameworks, It is a simple 3 method interface.
TradenityClient client = new TradenityClient('sk_1234567')
Make sure to replace the api keys with the ones for your store, otherwise you will get authentication error
Make your First call
The Tradenity SDK is organized into a group of model entitiy classes that corresponds to the REST API’s resources, each encapsulate the operation for a specific entity model,
for example to perform operations related to the Brand
resource you can use the corresponding tradenity.sdk.entities.Brand
class.
Now, just call any method in your code.
Brand brand = brandService.findById("1243-9786786-jhgjtu-789s6i");
Tutorials and sample applications
We provide 2 sample applications, actually it is the same application implemented using 2 frameworks: Spring MVC
, and Grails
.
Camera store sample application live demo
You can find the code at github:
Camera store for spring mvc code.
We also provide a detailed explanation of the code of these sample applications in the form of a step by step tutorials: