Search in sources :

Example 1 with OrganizationList

use of org.bf2.srs.fleetmanager.spi.ams.impl.model.response.OrganizationList in project srs-fleet-manager by bf2fc6cc711aee1a0c2a.

the class AccountManagementSystemRestClient method getOrganizationByExternalId.

public Organization getOrganizationByExternalId(String externalOrgId) {
    String search = "external_id='ORG_ID'".replace("ORG_ID", externalOrgId);
    Map<String, List<String>> queryParams = new HashMap<>();
    queryParams.put("search", Collections.singletonList(search));
    OrganizationList rval = this.client.sendRequest(new Request.RequestBuilder<OrganizationList>().operation(Operation.GET).path(Paths.ORGANIZATIONS_PATH).queryParams(queryParams).responseType(new TypeReference<OrganizationList>() {
    }).build());
    if (rval.getTotal() < 1) {
        throw new AccountManagementSystemClientException("Organization not found with external id: " + externalOrgId);
    }
    return rval.getItems().get(0);
}
Also used : HashMap(java.util.HashMap) QuotaCostList(org.bf2.srs.fleetmanager.spi.ams.impl.model.response.QuotaCostList) List(java.util.List) OrganizationList(org.bf2.srs.fleetmanager.spi.ams.impl.model.response.OrganizationList) OrganizationList(org.bf2.srs.fleetmanager.spi.ams.impl.model.response.OrganizationList) AccountManagementSystemClientException(org.bf2.srs.fleetmanager.spi.ams.impl.exception.AccountManagementSystemClientException)

Aggregations

HashMap (java.util.HashMap)1 List (java.util.List)1 AccountManagementSystemClientException (org.bf2.srs.fleetmanager.spi.ams.impl.exception.AccountManagementSystemClientException)1 OrganizationList (org.bf2.srs.fleetmanager.spi.ams.impl.model.response.OrganizationList)1 QuotaCostList (org.bf2.srs.fleetmanager.spi.ams.impl.model.response.QuotaCostList)1