in src/main/java/com/microsoft/store/partnercenter/customerusers/CustomerUsersCollectionOperations.java [106:198]
public SeekBasedResourceCollection<CustomerUser> query(IQuery customerUsersQuery)
{
if (customerUsersQuery == null)
{
throw new IllegalArgumentException("customerUsersQuery can't be null");
}
if (customerUsersQuery.getType() == QueryType.COUNT)
{
throw new IllegalArgumentException("customerUsersQuery can't be a count query.");
}
Collection<KeyValuePair<String, String>> parameters = new ArrayList<KeyValuePair<String, String>>();
Map<String, String> headers = new HashMap<>();
if (customerUsersQuery.getType() == QueryType.SEEK)
{
// if this is a seek query, add the seek operation and the continuation token to the request
if (customerUsersQuery.getToken() == null)
{
throw new IllegalArgumentException("customerUsersQuery.Token is required.");
}
headers.put(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getAdditionalHeaders().get("ContinuationToken"),
customerUsersQuery.getToken().toString());
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getParameters().get("SeekOperation"),
customerUsersQuery.getSeekOperation().toString()));
}
else
{
if (customerUsersQuery.getType() == QueryType.INDEXED)
{
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getParameters().get("Size"),
String.valueOf(customerUsersQuery.getPageSize())));
}
else
{
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getParameters().get("Size"),
"0"));
}
if (customerUsersQuery.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("GetCustomerUsers").getParameters().get("Filter"),
URLEncoder.encode(mapper.writeValueAsString(customerUsersQuery.getFilter()),
"UTF-8")));
}
catch (UnsupportedEncodingException e)
{
throw new PartnerException("", null, PartnerErrorCategory.REQUEST_PARSING, e);
}
catch (JsonProcessingException e)
{
throw new PartnerException("", null, PartnerErrorCategory.REQUEST_PARSING, e);
}
}
if (customerUsersQuery.getSort() != null)
{
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getParameters().get("SortField"),
customerUsersQuery.getSort().getSortField()));
parameters.add(
new KeyValuePair<String, String>(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getParameters().get("SortDirection"),
customerUsersQuery.getSort().getSortDirection().toString()));
}
}
return this.getPartner().getServiceClient().get(
this.getPartner(),
new TypeReference<SeekBasedResourceCollection<CustomerUser>>(){},
MessageFormat.format(
PartnerService.getInstance().getConfiguration().getApis().get("GetCustomerUsers").getPath(),
this.getContext()),
headers,
parameters);
}