Quick Start Guide

Wednesday, 25 of February 2015

Introduction

This guide walks through the steps of installing and configuring RepCamp Java SDK together with a brief explanation on how to upload and retrieve data from your account at RepCamp.com.

For your convenience a sample Java project using the SDK can be found in GitHub.


What does the SDK includes?

  • A set of Classes that you will be using such as: Customers, Products, Categories, PriceLists, etc. Lear more here.

  • A Rest Services interface so you forget about http calls and focus on transffering back and forth the data.

  • A Main Controller: The RepCampApi is the main controller wich you will be using for authentication and centarlization of the API calls.

Installation

Reference our maven repository or download the jar file from here.

<repository>
    <id>kriter-code</id>
    <name>kriter-code-releases</name>
    <url>http://code.kriter.net:8081/artifactory</url>
</repository>
<dependency>
    <groupId>net.kriter.rcsdk</groupId>
    <artifactId>repcamp-sdk</artifactId>
    <version>LATEST</version>
</dependency>
 

Dependencies

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-client</artifactId>
    <version>1.18.3</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-core</artifactId>
    <version>1.18.3</version>
</dependency>
<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-json</artifactId>
    <version>1.18.3</version>
</dependency>
<dependency>
    <groupId>org.codehaus.jackson</groupId>
    <artifactId>jackson-mapper-asl</artifactId>
    <version>1.9.13</version>
</dependency>

 


Lets Code!

  • Instantiate the main RepCamp SDK controller.
RepCampAPI repcampAPI = new RepCampAPI();

 

  • Specify API data to start up the authentication.
APIData apidata = new APIData(
      config.getProperty("url"),
      config.getProperty("username"),
      config.getProperty("password"), //Sha1
      config.getProperty("apikey"),
      config.getProperty("secretkey"),
      config.getProperty("apiversion") //Just hardcode the version, for now is "v1"
);

 

  • Set API data to the controller.
repcampAPI.setAPIData(apidata);

 

  • Authenticate your self, just to test the API key out. 
if(repcampAPI.authenticateMe()) System.out.println("Authentication ----------- OK");
else System.out.println("Authentication ----------- FAILED");

 

Upload

  • Create a Customer
Customer customer = new Customer();
//Set all necessary atributes
customer.setCode("CT0001");
customer.setFiscal_name("Kriter Software, S.L.");
customer.setComercial_name("Kriter Software");
customer.setVat_number("D58709832");
customer.setTelephone("+34 937575997");
customer.setTelephone_2("");
customer.setEmail("support@repcamp.com");
customer.setAddress("Pablo Iglesias 63");
customer.setAddress_2("PB L1");
customer.setCity("Mataró");
customer.setZip("08302");
customer.setState("Barcelona (BCN)");
customer.setCountry("SPAIN");
customer.setLatitude(new BigDecimal("41.531395"));
customer.setLongitude(new BigDecimal("2.43232"));
customer.setPayment_method("Bank Transfer 30 days");
customer.setDiscount(new BigDecimal("10"));
customer.setDescription("This is just a comment area");
customer.setStatus((short) 1);
customer.setPricelist("01");
customer.setLanguage("en");
//etc.

 

  • Upload it and handle the response
GenericResponse resp =  GenerepcampAPI.addCustomer(customer);
if(resp.getSingleResponse() != null)
{
    if(resp.getSingleResponse().getError() != null)
    {
      System.out.println("Failed to delete customer: (CODE) " + code + " Error: " + resp.getSingleResponse().getError());
    }
}

 

Query RepCamp to obtain its data

List<String> criteria = new ArrayList<String>();
criteria.add("code=CT0001");

List<Customer> customerslist = repcampAPI.getCustomers(criteria, 0, 1);

for(Customer customer : customerslist) System.out.println(customer.toString());