diff --git a/pom.xml b/pom.xml
index 01e0494..900c64d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
BookingBug-SDK
BookingBug-SDK
- 1.4
+ 1.5
@@ -74,6 +74,12 @@
1.1
+
+ io.reactivex
+ rxjava
+ 1.1.0
+
+
diff --git a/src/main/bookingbugAPI/api/AdminURLS.java b/src/main/bookingbugAPI/api/AdminURLS.java
index e4ba96e..5ddfc9b 100644
--- a/src/main/bookingbugAPI/api/AdminURLS.java
+++ b/src/main/bookingbugAPI/api/AdminURLS.java
@@ -11,6 +11,7 @@ public static class Company {
public static UriTemplate company() {
return UriTemplate.buildFromTemplate(new Config().serverUrl)
.literal("/admin")
+ .path(UriTemplateBuilder.var("companyId"))
.literal("/company")
.build();
}
@@ -625,6 +626,16 @@ public static UriTemplate eventChainReadUsingRefId() {
.path(UriTemplateBuilder.var("refId"))
.build();
}
+
+ public static UriTemplate eventChainEventsList() {
+ return UriTemplate.buildFromTemplate(new Config().serverUrl)
+ .literal("/admin")
+ .path(UriTemplateBuilder.var("companyId"))
+ .literal("/event_chains")
+ .path(UriTemplateBuilder.var("eventChainId"))
+ .literal("/events")
+ .build();
+ }
}
diff --git a/src/main/bookingbugAPI/api/PublicURLS.java b/src/main/bookingbugAPI/api/PublicURLS.java
index acfae19..4aac65f 100644
--- a/src/main/bookingbugAPI/api/PublicURLS.java
+++ b/src/main/bookingbugAPI/api/PublicURLS.java
@@ -179,8 +179,13 @@ public static class Event {
* @return UriTemplate
*/
public static UriTemplate eventList(){
- return UriTemplate.buildFromTemplate(new Config().serverUrl).path(UriTemplateBuilder.var("companyId"))
- .literal("/" + eventsLink).build();
+ return UriTemplate.buildFromTemplate(new Config().serverUrl)
+ .path(UriTemplateBuilder.var("companyId"))
+ .literal("/" + eventsLink)
+ .query("page", "per_page", "event_chain_id",
+ "start_date", "end_date", "resource_id", "person_id",
+ "event_group_id", "summary", "member_level_id")
+ .build();
}
/**
@@ -244,7 +249,9 @@ public static UriTemplate availabilityDaysForBookableItem() {
*/
public static UriTemplate availabilityTimesForBookableItem() {
return UriTemplate.buildFromTemplate(new Config().serverUrl).path(UriTemplateBuilder.var("companyId"))
- .literal("/time_data").build();
+ .literal("/time_data")
+ .query("event_id", "service_id", "resource_id","resource_ids", "person_id", "group_id", "location",
+ "date", "end_date", "duration", "num_resources").build();
}
/**
@@ -314,7 +321,9 @@ public static class EventChain {
*/
public static UriTemplate eventChainList(){
return UriTemplate.buildFromTemplate(new Config().serverUrl).path(UriTemplateBuilder.var("companyId"))
- .literal("/" + eventChainsLink).build();
+ .literal("/" + eventChainsLink)
+ .query(UriTemplateBuilder.var("page"), UriTemplateBuilder.var("per_page"))
+ .build();
}
/**
diff --git a/src/main/bookingbugAPI/models/BBRoot.java b/src/main/bookingbugAPI/models/BBRoot.java
index ac369ea..ccbaa6e 100644
--- a/src/main/bookingbugAPI/models/BBRoot.java
+++ b/src/main/bookingbugAPI/models/BBRoot.java
@@ -107,6 +107,18 @@ public String get(String key){
return val;
}
+ public boolean getBoolean(String key, boolean defaultValue) {
+ String val = this.get(key);
+ if(val != null) return Boolean.parseBoolean(val);
+ return defaultValue;
+ }
+
+ public int getInteger(String key, int defaultValue) {
+ String val = this.get(key);
+ if(val != null) return Integer.parseInt(val);
+ return defaultValue;
+ }
+
public String getAuth_token() {
return auth_token;
diff --git a/src/main/bookingbugAPI/models/BookableAvailability.java b/src/main/bookingbugAPI/models/BookableAvailability.java
index 0a42f4a..7879c42 100644
--- a/src/main/bookingbugAPI/models/BookableAvailability.java
+++ b/src/main/bookingbugAPI/models/BookableAvailability.java
@@ -50,20 +50,36 @@ public Date getDateTimeObj(){
return datetime;
}
- public boolean isAvailable(Date datetime){
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(datetime);
- int hour_to_check = calendar.get(Calendar.HOUR_OF_DAY);
-
- ArrayList times = new ArrayList<>(getRep().getResourcesByRel("times"));
- for (ReadableRepresentation rep : times) {
- int time_min = Integer.parseInt((String) rep.getValue("time"));
- int avail = Integer.parseInt((String) rep.getValue("avail"));
-
- int hour = time_min / 60;
- if(hour_to_check >= hour && hour_to_check < hour + 1 && avail == 1)
- return true;
+ public ArrayList getAvailTimes(){
+
+ ArrayList times_reps = new ArrayList<>(getRep().getResourcesByRel("times"));
+ ArrayList times = new ArrayList<>();
+
+ for (ReadableRepresentation rep : times_reps) {
+ AvailTime timeObj = new AvailTime();
+ timeObj.time_minutes = Integer.parseInt((String) rep.getValue("time"));
+ timeObj.avail = Integer.parseInt((String) rep.getValue("avail")) == 1 ? true : false;
+ timeObj.price = Integer.parseInt((String) rep.getValue("price"));
+ times.add(timeObj);
+ }
+ return times;
+ }
+
+ public static class AvailTime {
+ int time_minutes;
+ boolean avail;
+ int price;
+
+ public int getTime_minutes() {
+ return time_minutes;
+ }
+
+ public boolean isAvail() {
+ return avail;
+ }
+
+ public int getPrice() {
+ return price;
}
- return false;
}
}
diff --git a/src/main/bookingbugAPI/models/Company.java b/src/main/bookingbugAPI/models/Company.java
index 8c36265..dc786c2 100644
--- a/src/main/bookingbugAPI/models/Company.java
+++ b/src/main/bookingbugAPI/models/Company.java
@@ -12,6 +12,7 @@
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import com.theoryinpractise.halbuilder.api.ContentRepresentation;
import bookingbugAPI.services.HttpService;
+import com.theoryinpractise.halbuilder.api.ReadableRepresentation;
import com.theoryinpractise.halbuilder.json.JsonRepresentationFactory;
import helpers.HttpServiceResponse;
import helpers.Utils;
@@ -19,6 +20,7 @@
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.List;
import java.util.Map;
import static com.theoryinpractise.halbuilder.api.RepresentationFactory.HAL_JSON;
@@ -322,9 +324,21 @@ public Resource companyDetails(String companyId) throws IOException {
* @throws IOException
*/
public BBCollection eventList() throws IOException {
- URL url = new URL(PublicURLS.Event.eventList().set("companyId", this.id).expand());
- BBCollection events = new BBCollection(HttpService.api_GET(url, auth_token), auth_token, "events", Event.class);
- return events;
+ return eventList(new Params());
+ }
+
+ /**
+ * Get a List of Bookable Events.
+ * @param params Parameters for pagination
+ * @return BBCollection
+ * @throws IOException
+ */
+ public BBCollection eventList(Params params) throws IOException {
+ UriTemplate template = Utils.TemplateWithPagination(
+ PublicURLS.Event.eventList().set("companyId", this.id),
+ params);
+ URL url = new URL(template.expand());
+ return new BBCollection(HttpService.api_GET(url, auth_token), auth_token, "events", Event.class);
}
@@ -369,9 +383,13 @@ public BBCollection bookableItemsByDate(String date) throws IOExce
* @return Resource
* @throws IOException
*/
- public BBCollection availabilityDaysForBookableItem() throws IOException {
- URL url = new URL(PublicURLS.Bookable.availabilityDaysForBookableItem().set("companyId", this.id).expand());
- return new BBCollection(HttpService.api_GET(url, auth_token), auth_token, "events", BookableAvailability.class);
+ public BBRoot availabilityDaysForBookableItem(TimeDataParams params) throws IOException {
+ URL url = new URL(
+ PublicURLS.Bookable.availabilityDaysForBookableItem()
+ .set("companyId", this.id)
+ .set((Map)params.getParams())
+ .expand());
+ return new BBRoot(HttpService.api_GET(url, auth_token), auth_token);
}
@@ -380,9 +398,13 @@ public BBCollection availabilityDaysForBookableItem() thro
* @return Resource
* @throws IOException
*/
- public Resource availabilityTimesForBookableItem() throws IOException {
- URL url = new URL(PublicURLS.Bookable.availabilityTimesForBookableItem().set("companyId", this.id).expand());
- return new Resource(HttpService.api_GET(url, auth_token), auth_token);
+ public BBCollection availabilityTimesForBookableItem(TimeDataParams params) throws IOException {
+ URL url = new URL(
+ PublicURLS.Bookable.availabilityTimesForBookableItem()
+ .set("companyId", this.id)
+ .set((Map)params.getParams())
+ .expand());
+ return new BBCollection(HttpService.api_GET(url, auth_token), auth_token, "events", BookableAvailability.class);
}
@@ -439,7 +461,20 @@ public EventGroup eventGroupRead(String eventGroupId) throws IOException {
* @throws IOException
*/
public BBCollection eventChainList() throws IOException {
- URL url = new URL (PublicURLS.EventChain.eventChainList().set("companyId", this.id).expand());
+ return eventChainList(new Params());
+ }
+
+ /**
+ * Get a List of Courses or Repeating Events for a Company.
+ * @param params Parameters for pagination
+ * @return BBCollection
+ * @throws IOException
+ */
+ public BBCollection eventChainList(Params params) throws IOException {
+ UriTemplate template = Utils.TemplateWithPagination(
+ PublicURLS.EventChain.eventChainList().set("companyId", this.id),
+ params);
+ URL url = new URL(template.expand());
BBCollection eventChains = new BBCollection(HttpService.api_GET(url, auth_token), auth_token, "event_chains", EventChain.class);
return eventChains;
}
@@ -605,18 +640,24 @@ public Resource spaceStatusList() throws IOException {
}
+
/**
* Loads all of the public settings for a company, this allows you to configure a booking widget,
* and shows all of the details need to book and show an appropriate widget.
- * @return Resource
+ * @return CompanySettings
* @throws IOException
*/
- public Resource settingsDetails() throws IOException {
- URL url = new URL(PublicURLS.Company.settingsDetails().set("companyId", this.id).expand());
- return new Resource(HttpService.api_GET(url));
+ public CompanySettings getSettings() throws IOException {
+ if(getRep().getResourcesByRel("settings").size() > 0) {
+ //Return settings from embedded
+ return new CompanySettings(new HttpServiceResponse((ContentRepresentation) getRep().getResourcesByRel("settings").get(0)));
+ } else {
+ //Call API
+ URL url = new URL(PublicURLS.Company.settingsDetails().set("companyId", this.id).expand());
+ return new CompanySettings(HttpService.api_GET(url));
+ }
}
-
/**
* You can either get all the company questions or pass a param to specifiy that you only want company questions
* that apply to either a service, resource, person, company:
diff --git a/src/main/bookingbugAPI/models/CompanySettings.java b/src/main/bookingbugAPI/models/CompanySettings.java
new file mode 100644
index 0000000..a1fd5e1
--- /dev/null
+++ b/src/main/bookingbugAPI/models/CompanySettings.java
@@ -0,0 +1,55 @@
+package bookingbugAPI.models;
+
+import helpers.HttpServiceResponse;
+
+/**
+ * Created by sebi on 31.03.2016.
+ */
+public class CompanySettings extends BBRoot {
+
+ public CompanySettings(HttpServiceResponse httpServiceResponse, String auth_token) {
+ super(httpServiceResponse, auth_token);
+ }
+
+ public CompanySettings(HttpServiceResponse response) {
+ super(response);
+ }
+
+ public boolean has_coupons() {
+ return getBoolean("has_coupons", false);
+ }
+
+ public boolean has_deals() {
+ return getBoolean("has_deals", false);
+ }
+
+ public boolean has_products() {
+ return getBoolean("has_products", false);
+ }
+
+ public boolean has_events() {
+ return getBoolean("has_events", false);
+ }
+
+ public boolean has_classes() {
+ return getBoolean("has_classes", false);
+ }
+
+ public boolean requires_login() {
+ return getBoolean("requires_login", false);
+ }
+
+ public boolean has_wallets() {
+ return getBoolean("has_wallets", false);
+ }
+
+ public int getPaymentTax() {
+ return getInteger("payment_tax", 0);
+ }
+
+
+
+ public Currency getCurrency() {
+ return Currency.fromString(get("currency"));
+ }
+}
diff --git a/src/main/bookingbugAPI/models/Currency.java b/src/main/bookingbugAPI/models/Currency.java
new file mode 100644
index 0000000..1cf3c6b
--- /dev/null
+++ b/src/main/bookingbugAPI/models/Currency.java
@@ -0,0 +1,33 @@
+package bookingbugAPI.models;
+
+/**
+ * Created by sebi on 31.03.2016.
+ */
+public enum Currency {
+ GBP("GBP"),
+ EUR("EUR");
+
+ private final String apiValue;
+
+ private Currency(String apiValue) {
+ this.apiValue = apiValue;
+ }
+
+ public String symbol() {
+ switch (this) {
+ case GBP: return "\u00a3";
+ case EUR: return "\u20ac";
+ default: return "";
+ }
+ }
+
+ public static Currency fromString(String str) {
+ if(str != null) {
+ for(Currency currency : Currency.values()) {
+ if(str.equalsIgnoreCase(currency.apiValue))
+ return currency;
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/bookingbugAPI/models/EventChain.java b/src/main/bookingbugAPI/models/EventChain.java
index dc32cbe..2d88b8f 100644
--- a/src/main/bookingbugAPI/models/EventChain.java
+++ b/src/main/bookingbugAPI/models/EventChain.java
@@ -1,6 +1,16 @@
package bookingbugAPI.models;
+import bookingbugAPI.api.PublicURLS;
+import bookingbugAPI.models.params.EventListParams;
+import bookingbugAPI.services.HttpService;
+import com.damnhandy.uri.template.UriTemplate;
import helpers.HttpServiceResponse;
+import helpers.Utils;
+import rx.Observable;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.concurrent.Callable;
public class EventChain extends BBRoot{
@@ -18,4 +28,33 @@ public EventChain(HttpServiceResponse httpServiceResponse, String auth_token){
public EventChain() {}
+ /**
+ * Get a List of Bookable Events for an EventChain.
+ * @param params Parameters for pagination
+ * @return BBCollection
+ * @throws IOException
+ */
+ public BBCollection eventList(EventListParams params) throws IOException {
+ UriTemplate template;
+ if(getLink("events") != null) {
+ template = Utils.TemplateWithPagination(
+ Utils.paginatedUriTemplate(getLink("events")),
+ params);
+ } else {
+ params.setEvent_chain_id(this.id);
+ template = PublicURLS.Event.eventList().set("companyId", get("company_id"));
+ }
+
+ URL url = new URL(template.expand(params.getParamsMapObj()));
+ return new BBCollection(HttpService.api_GET(url, auth_token), auth_token, "events", Event.class);
+ }
+
+ public Observable> eventListObs(final EventListParams params){
+ return Observable.fromCallable(new Callable>() {
+ @Override
+ public BBCollection call() throws Exception {
+ return eventList(params);
+ }
+ });
+ }
}
diff --git a/src/main/bookingbugAPI/models/Login.java b/src/main/bookingbugAPI/models/Login.java
index 303f445..050d5b6 100644
--- a/src/main/bookingbugAPI/models/Login.java
+++ b/src/main/bookingbugAPI/models/Login.java
@@ -5,7 +5,10 @@
import com.damnhandy.uri.template.UriTemplate;
import com.theoryinpractise.halbuilder.api.ContentRepresentation;
import com.theoryinpractise.halbuilder.api.Link;
+import helpers.Config;
import helpers.HttpServiceResponse;
+import helpers.TokenGenerator;
+import org.json.simple.JSONObject;
import java.io.IOException;
import java.net.MalformedURLException;
diff --git a/src/main/bookingbugAPI/models/params/EventListParams.java b/src/main/bookingbugAPI/models/params/EventListParams.java
new file mode 100644
index 0000000..48ed147
--- /dev/null
+++ b/src/main/bookingbugAPI/models/params/EventListParams.java
@@ -0,0 +1,85 @@
+package bookingbugAPI.models.params;
+
+/**
+ * Created by sebi on 31.03.2016.
+ */
+public class EventListParams extends Params {
+ String resource_id;
+ String event_chain_id;
+ String person_id;
+ String event_group_id;
+ String summary;
+ String member_level_id;
+ String start_date;
+ String end_date;
+
+ public EventListParams() {}
+
+ public EventListParams(int page){
+ super(page);
+ }
+
+ public String getResource_id() {
+ return resource_id;
+ }
+
+ public void setResource_id(String resource_id) {
+ this.resource_id = resource_id;
+ }
+
+ public String getPerson_id() {
+ return person_id;
+ }
+
+ public void setPerson_id(String person_id) {
+ this.person_id = person_id;
+ }
+
+ public String getEvent_group_id() {
+ return event_group_id;
+ }
+
+ public void setEvent_group_id(String event_group_id) {
+ this.event_group_id = event_group_id;
+ }
+
+ public String getSummary() {
+ return summary;
+ }
+
+ public void setSummary(String summary) {
+ this.summary = summary;
+ }
+
+ public String getMember_level_id() {
+ return member_level_id;
+ }
+
+ public void setMember_level_id(String member_level_id) {
+ this.member_level_id = member_level_id;
+ }
+
+ public String getStart_date() {
+ return start_date;
+ }
+
+ public void setStart_date(String start_date) {
+ this.start_date = start_date;
+ }
+
+ public String getEnd_date() {
+ return end_date;
+ }
+
+ public void setEnd_date(String end_date) {
+ this.end_date = end_date;
+ }
+
+ public String getEvent_chain_id() {
+ return event_chain_id;
+ }
+
+ public void setEvent_chain_id(String event_chain_id) {
+ this.event_chain_id = event_chain_id;
+ }
+}
diff --git a/src/main/bookingbugAPI/models/params/Params.java b/src/main/bookingbugAPI/models/params/Params.java
index d2a8f09..a1b468f 100644
--- a/src/main/bookingbugAPI/models/params/Params.java
+++ b/src/main/bookingbugAPI/models/params/Params.java
@@ -1,17 +1,40 @@
package bookingbugAPI.models.params;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
-public abstract class Params {
+public class Params {
+
+ private int page = 1;
+ private int per_page = 100;
public Params() {}
+ public Params(int page) {
+ this.page = page;
+ }
+
public Params(Map args){
setNotNullStringMap(args);
}
+ public static Params withPagination(int page, int per_page){
+ Params params = new Params();
+ params.page = page;
+ params.per_page = per_page;
+ return params;
+ }
+
+ public static Params withPagination(int page){
+ Params params = new Params();
+ params.page = page;
+ return params;
+ }
+
public Map getNotNullStringMap() {
Map result = new HashMap();
Field[] declaredFields = this.getClass().getDeclaredFields();
@@ -44,4 +67,30 @@ public void setNotNullStringMap(Map map) {
public Map getParams(){
return getNotNullStringMap();
}
+
+ public Map getParamsMapObj() {
+ Map objectMap = new HashMap<>();
+ objectMap.putAll(getParams());
+ return objectMap;
+ }
+
+ public int getPage() {
+ return page;
+ }
+
+ public int getPer_page() {
+ return per_page;
+ }
+
+ @Override
+ public String toString(){
+ String json = "";
+ try {
+ json = new ObjectMapper().writeValueAsString(this);
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ }
+ return json;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/bookingbugAPI/models/params/TimeDataParams.java b/src/main/bookingbugAPI/models/params/TimeDataParams.java
new file mode 100644
index 0000000..bbfab58
--- /dev/null
+++ b/src/main/bookingbugAPI/models/params/TimeDataParams.java
@@ -0,0 +1,126 @@
+package bookingbugAPI.models.params;
+
+import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
+
+import javax.print.DocFlavor;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.StringTokenizer;
+
+/**
+ * Created by sebi on 27.02.2016.
+ */
+public class TimeDataParams extends Params {
+
+ String event_id;
+ String service_id;
+ String resource_id;
+ String resource_ids;
+ String person_id;
+ String group_id;
+ String location;
+ String date;
+ String end_date;
+ String duration;
+ String num_resources;
+
+ public String getEvent_id() {
+ return event_id;
+ }
+
+ public void setEvent_id(String event_id) {
+ this.event_id = event_id;
+ }
+
+ public String getNum_resources() {
+ return num_resources;
+ }
+
+ public void setNum_resources(String num_resources) {
+ this.num_resources = num_resources;
+ }
+
+ public int getDuration() {
+ return Integer.parseInt(duration);
+ }
+
+ public void setDuration(int duration) {
+ this.duration = String.valueOf(duration);
+ }
+
+ public String getEnd_date() {
+ return end_date;
+ }
+
+ public void setEnd_date(Date end_date) {
+ this.end_date = new ISO8601DateFormat().format(end_date);
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public String getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = new ISO8601DateFormat().format(date);
+ }
+
+
+
+ public String getPerson_id() {
+ return person_id;
+ }
+
+ public void setPerson_id(String person_id) {
+ this.person_id = person_id;
+ }
+
+ public String getGroup_id() {
+ return group_id;
+ }
+
+ public void setGroup_id(String group_id) {
+ this.group_id = group_id;
+ }
+
+ public String getService_id() {
+ return service_id;
+ }
+
+ public void setService_id(String service_id) {
+ this.service_id = service_id;
+ }
+
+ public String getResource_id() {
+ return resource_id;
+ }
+
+ public void setResource_id(String resource_id) {
+ this.resource_id = resource_id;
+ }
+
+ public ArrayList getResource_ids() {
+ ArrayList res = new ArrayList<>();
+ StringTokenizer tokenizer = new StringTokenizer(resource_ids, ",");
+ while (tokenizer.hasMoreTokens())
+ res.add(tokenizer.nextToken());
+ return res;
+ }
+
+ public void setResource_ids(ArrayList resource_ids) {
+ this.resource_ids = "";
+ for(int i = 0; i < resource_ids.size(); i++) {
+ this.resource_ids += resource_ids.get(i);
+ if(i + 1 < resource_ids.size())
+ this.resource_ids += ",";
+ }
+ }
+}
diff --git a/src/main/helpers/Utils.java b/src/main/helpers/Utils.java
index 1129a96..8788cd5 100644
--- a/src/main/helpers/Utils.java
+++ b/src/main/helpers/Utils.java
@@ -1,6 +1,8 @@
package helpers;
+import bookingbugAPI.models.params.Params;
import com.damnhandy.uri.template.UriTemplate;
+import com.damnhandy.uri.template.UriTemplateBuilder;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -45,6 +47,24 @@ public static String absoluteURL(String url){
return absoluteURL(url, null);
}
+ /**
+ * Given a string url returns a templated url with pagination
+ * @param fromTemplate String to convert to UriTemplate
+ * @return
+ */
+ public static UriTemplate paginatedUriTemplate(String fromTemplate){
+ return UriTemplate.buildFromTemplate(fromTemplate)
+ .query(UriTemplateBuilder.var("page"), UriTemplateBuilder.var("per_page"))
+ .build();
+ }
+
+ public static UriTemplate TemplateWithPagination(UriTemplate template, Params params){
+ if(params != null){
+ template.set("page", params.getPage());
+ template.set("per_page", params.getPer_page());
+ }
+ return template;
+ }
/**
* @param content
diff --git a/src/test/bookingbugAPI/api/CompanyTest.java b/src/test/bookingbugAPI/api/CompanyTest.java
new file mode 100644
index 0000000..09d50eb
--- /dev/null
+++ b/src/test/bookingbugAPI/api/CompanyTest.java
@@ -0,0 +1,43 @@
+package bookingbugAPI.api;
+
+import bookingbugAPI.models.Company;
+import bookingbugAPI.models.Currency;
+import bookingbugAPI.models.HttpException;
+import bookingbugAPI.models.Login;
+import bookingbugAPI.services.HttpService;
+import helpers.TokenGenerator;
+import org.json.simple.JSONObject;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Created by sebi on 31.03.2016.
+ */
+
+@Ignore
+public class CompanyTest {
+
+ private static final String companyId = "37028";
+ private static final String token = "7gcmPMDS-G2gpNiPSUQA4A";
+
+ @Test
+ public void companySettings(){
+ Company company = null;
+ try {
+ URL url = new URL(AdminURLS.Company.company().set("companyId", companyId).expand());
+ company = new Company(HttpService.api_GET(url, token), token);
+ assertNotNull(company);
+ assertNotNull(company.getSettings());
+ assertEquals(company.getSettings().getCurrency(), Currency.GBP);
+ }catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}