Introduction
The purpose of this section is to enumerate the methods of the main SDK controller, RepCampApi. Once instantiated, it will allow you to add, update, remove and retrieve data from your account at RepCamp.com.
NOTE
Please notice that the code described below is written in JAVA. If you are a C# fanboy just translated the types and method names. Sorry about that ;)
The normal usage of this controller would be:
- Instantiate it.
-
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.
-
if(repcampAPI.authenticateMe()) System.out.println("Authentication ----------- OK"); else System.out.println("Authentication ----------- FAILED");
Once authenticated you are ready to use any of the methods described bellow. Each item (Customer, Product, PriceList, etc.) has five standard methods that act exactly the same way for all of them. There are only two items that are threated differently, Stock (just update and retrieve) and Orders (data can only be retrieved).
As you will notice most of the methods return an object called GenericResponse that contains the following:
public class GenericResponse {
private int status;
private String url;
private String message;
private BulkResponse bulkResponse;
private SingleResponse singleResponse;
}
There allways be a status (http status), an url (the full path url called) and a message (http status message), the rest will be fullfilled or just null depending on the nature of the call.
The methods add, update and remove are treated equaly and they all recieve a SingleResponse when there is an error. In the other hand the BulkResponse is only recieved when attempting a bulk action, or in other words, whenever the upload method is called.
public class SingleResponse {
private String id;
private String error;
}
public class BulkResponse {
private String item_type;
private int total;
private int inserts;
private int updates;
private int errors;
private String[] items_error;
}
To know more about this two objects go here.
The Stock item is treated diferently as the only available method (a part from retrieveing the data) is the update.
To retrieve data from RepCamp it is as easy as calling the get methods of each item and your are done. The standard return object is a List Object containing your Items. Ex: List<Customer>.
You can define a criteria by using the param queryParam which consists of List<String> as follows:
List<String> criteria = new ArrayList<String>();
criteria.add("code=CT0001");
criteria.add("vat_number=D58709832");
The criterias will be treated as "AND" and will only return and object if it fully complains it.
Tips & Triks
- Althoug all the calls can be treated separatly it is mandataory to upload each item dependencies before the actual item. So for example the Categories and the Manufacturers have to be uploaded before uploading any product, otherwise there will exist no connection in betewn them.
- That being said, it is clear and recommended that master items such as Countries and its States are uploaded at first place.
General Methods
Throws ExceptionConstructorRepCampAPI()
Throws ExceptionConstructorRepCampAPI(APIData apidata)
Throws ExceptionsetAPIData(APIData apidata)
Throws ExceptionAPIDatagetAPIData()
Throws ExceptionAuthtokengetAuthtoken()
Throws ExceptionbooleanauthenticateMe()
Customer
- Throws ExceptionGenericResponseaddCustomer(Customer customer)
- Throws ExceptionGenericResponseupdateCustomer(Customer customer)
- Throws ExceptionGenericResponseremoveCustomer(String code)
- Throws ExceptionGenericResponseuploadCustomers(List<Customer> customers)
- Throws ExceptionList<Customer>getCustomers(List
queryParam, int skip, int take)
Product
- Throws ExceptionGenericResponseaddProduct(Product product)
- Throws ExceptionGenericResponseupdateProduct(Product product)
- Throws ExceptionGenericResponseremoveProduct(String code)
- Throws ExceptionGenericResponseuploadProducts(List<Product> products)
- Throws ExceptionList<Product>getProducts(List
queryParam, int skip, int take)
Category
- Throws ExceptionGenericResponseaddCategory(Category category)
- Throws ExceptionGenericResponseupdateCategory(Category category)
- Throws ExceptionGenericResponseremoveCategory(String code)
- Throws ExceptionGenericResponseuploadCategories(List<Category> categories)
- Throws ExceptionList<Category>getCategories(List
queryParam, int skip, int take)
Manufacturer
- Throws ExceptionGenericResponseaddManufacturer(Manufacturer manufacturer)
- Throws ExceptionGenericResponseupdateManufacturer(Manufacturer manufacturer)
- Throws ExceptionGenericResponseremoveManufacturer(String code)
- Throws ExceptionGenericResponseuploadManufacturers(List<Manufacturer> manufacturers)
- Throws ExceptionList<Manufacturer>getManufacturers(List
queryParam, int skip, int take)
Price List
- Throws ExceptionGenericResponseaddPriceList(PriceList pricelist)
- Throws ExceptionGenericResponseupdatePriceList(PriceList pricelist)
- Throws ExceptionGenericResponseremovePriceList(String unique_code)
- Throws ExceptionGenericResponseuploadPriceLists(List<PriceList> pricelists)
- Throws ExceptionList<PriceList>getPriceList(List
queryParam, int skip, int take)
Price List Line
- Throws ExceptionGenericResponseaddPriceListLine(PriceListLine pricelistline)
- Throws ExceptionGenericResponseupdatePriceListLine(PriceListLine pricelistline)
- Throws ExceptionGenericResponseremovePriceListLine(String unique_code)
- Throws ExceptionGenericResponseuploadPriceListLine(List<PriceListLine> pricelistlines)
- Throws ExceptionList<PriceListLine>getPriceListLines(List
queryParam, int skip, int take)
Last Sales
- Throws ExceptionGenericResponseremoveLastSale(String unique_code)
- Throws ExceptionGenericResponseuploadLastSales(List<LastSale> lastSales)
- Throws ExceptionList<LastSale>getLastSales(List
queryParam, int skip, int take)
Stock
- Throws ExceptionGenericResponseuploadStock(List<Stock> stocks)
- Throws ExceptionList<Stock>getStock(List
queryParam, int skip, int take)
Country
- Throws ExceptionGenericResponseaddCountry(Country country)
- Throws ExceptionGenericResponseupdateCountry(Country country)
- Throws ExceptionGenericResponseremoveCountry(String unique_code)
- Throws ExceptionGenericResponseuploadCountries(List<Country> countries)
- Throws ExceptionList<Country>getCountries(List
queryParam, int skip, int take)
Order
- Throws ExceptionGenericResponseupdateOrdersStatus(List<OrderStatus> ordersStatueses)
- Throws ExceptionList<Order>getOrders(List
queryParam, int skip, int take)