in src/main/java/com/microsoft/store/partnercenter/servicerequests/CustomerServiceRequestCollectionOperations.java [81:143]
public SeekBasedResourceCollection<ServiceRequest> query(IQuery serviceRequestsQuery)
{
if (serviceRequestsQuery == null)
{
throw new IllegalArgumentException("serviceRequestsQuery can't be null");
}
if (serviceRequestsQuery.getType() != QueryType.INDEXED && serviceRequestsQuery.getType() != QueryType.SIMPLE)
{
throw new IllegalArgumentException("Specified query type is not supported.");
}
Collection<KeyValuePair<String, String>> parameters = new ArrayList<KeyValuePair<String, String>>();
if (serviceRequestsQuery.getType() == QueryType.INDEXED)
{
// if the query specifies a page size, validate it and add it to the request
ParameterValidator.isIntInclusive(MIN_PAGE_SIZE, MAX_PAGE_SIZE, serviceRequestsQuery.getPageSize(),
MessageFormat.format("Allowed page size values are from {0}-{1}",
MIN_PAGE_SIZE, MAX_PAGE_SIZE));
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("SearchCustomerServiceRequests").getParameters().get("Size"),
String.valueOf(serviceRequestsQuery.getPageSize())));
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("SearchCustomerServiceRequests").getParameters().get("Offset"),
String.valueOf(serviceRequestsQuery.getIndex())));
}
if (serviceRequestsQuery.getFilter() != null)
{
// add the filter to the request if specified
ObjectMapper mapper = new ObjectMapper();
try
{
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("SearchCustomerServiceRequests").getParameters().get("Filter"),
URLEncoder.encode(mapper.writeValueAsString(serviceRequestsQuery.getFilter()),
"UTF-8")));
}
catch (JsonProcessingException e)
{
throw new PartnerException("", null, PartnerErrorCategory.REQUEST_PARSING, e);
}
catch (UnsupportedEncodingException e)
{
throw new PartnerException("", null, PartnerErrorCategory.REQUEST_PARSING, e);
}
}
return this.getPartner().getServiceClient().get(
this.getPartner(),
new TypeReference<SeekBasedResourceCollection<ServiceRequest>>(){},
MessageFormat.format(
PartnerService.getInstance().getConfiguration().getApis().get("SearchCustomerServiceRequests").getPath(),
this.getContext()),
parameters);
}