Quick Start Guide
Introduction
This guide walks through the steps of installing and configuring RepCamp C# SDK together with a brief explanation on how to upload and retrieve data from your account at RepCamp.com.
Altough the C# sdk is fully functional it still in beta. A final version will be fully document and relased during the Q1 of 2015.
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
Download the dll from the downloads page. Our plan is to upload a NuGet package once the final version is out.
Dependencies
The SDK uses the well knwon RestSharp library to send and parse data back and forth. Visit the lib page or get it using NuGet.
Lets Code!
- Instantiate the main RepCamp SDK controller.
RepCampAPI repcampAPI = new RepCampAPI();
- Specify API data to start up the authentication.
APIData apidata = new APIData(
"url",
"username",
"password", //Sha1
"apikey",
"secretkey",
"apiversion" //Just hardcode the version, for now is "v1"
);
- Set API data to the controller.
repcampAPI.APIData = apidata;
- Authenticate your self, just to test the API key out.
if (repcampAPI.authenticateMe()) Console.WriteLine("Authentication ----------- OK");
else Console.WriteLine("Authentication ----------- FAILED");
Upload
- Create a Customer
Customer customer = new Customer();
//Set all necessary atributes
customer.code = "CT0001";
customer.fiscal_name = "Kriter Software, S.L.";
customer.comercial_name = "Kriter Software";
customer.vat_number = "D58709832";
customer.telephone = "+34 937575997";
customer.telephone_2 = "";
customer.email = "support@repcamp.com";
customer.address = "Pablo Iglesias 63";
customer.address_2 = "PB L1";
customer.city = "Mataró";
customer.zip = "08302";
customer.state = "Barcelona (BCN)";
customer.country = "SPAIN";
customer.latitude = new BigDecimal("41.531395");
customer.longitude = new BigDecimal("2.43232");
customer.payment_method = "Bank Transfer 30 days";
customer.discount = new BigDecimal("10");
customer.description = "This is just a comment area";
customer.status = (short) 1;
customer.pricelist = "01";
customer.language = "en";
//etc.
- Upload it and handle the response
GenericResponse resp = repcampAPI.addCustomer(customer);
if(resp.singleResponse != null)
{
if(resp.singleResponse.error != null)
{
Console.WriteLine("Failed to delete customer: (CODE) " + code + " Error: " + resp.singleResponse.error);
}
}
Query RepCamp to obtain its data
List<String> criteria = new List<String>();
criteria.Add("code=CT0001");
List<Customer> customerslist = repcampAPI.getCustomers(criteria, 0, 1);
foreach(Customer customer in customerslist) Console.WriteLine(customer.toString());