com.youcruit.billogram.objects.request.Search Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of billogram-v2-api-java-lib Show documentation
Show all versions of billogram-v2-api-java-lib Show documentation
Library for connecting to the Billogram v2 API
package com.youcruit.billogram.objects.request;
import java.util.HashMap;
import java.util.Map;
import com.google.gson.annotations.SerializedName;
public class Search {
private int page = 1;
@SerializedName("page_size")
private int pageSize = 10;
@SerializedName("filter_type")
private FilterType filterType;
@SerializedName("filter_field")
private String filterField;
@SerializedName("filter_value")
private String filterValue;
@SerializedName("order_field")
private String orderField;
@SerializedName("order_direction")
private SortDirection orderDirection;
public Map toQueryParameters() {
Map queryParameters = new HashMap<>();
queryParameters.put("page", String.valueOf(page));
queryParameters.put("page_size", String.valueOf(pageSize));
if (filterType != null) {
queryParameters.put("filter_type", filterType.fieldName);
queryParameters.put("filter_field", filterField);
queryParameters.put("filter_value", filterValue);
}
if (orderDirection != null) {
queryParameters.put("order_direction", orderDirection.directionName);
queryParameters.put("order_field", orderField);
}
return queryParameters;
}
public int getPage() {
return page;
}
public void setPage(int page) {
this.page = page;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public Search withPage(int page) {
this.page = page;
return this;
}
public Search withPageSize(int pageSize) {
this.pageSize = pageSize;
return this;
}
public Search withFilter(FilterType filterType, F filterField, String filterValue) {
this.filterType = filterType;
this.filterField = filterField.getFieldName();
this.filterValue = filterValue;
return this;
}
public Search withOrder(SortDirection orderDirection, O orderField) {
this.orderDirection = orderDirection;
this.orderField = orderField.getFieldName();
return this;
}
public FilterType getFilterType() {
return filterType;
}
public String getFilterField() {
return filterField;
}
public String getFilterValue() {
return filterValue;
}
public String getOrderField() {
return orderField;
}
public SortDirection getOrderDirection() {
return orderDirection;
}
}