Showing
1 changed file
with
15 additions
and
4 deletions
... | ... | @@ -77,6 +77,21 @@ public class RestClient implements ClientHttpRequestInterceptor { |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | + public Optional<Customer> findCustomer(String title) { | |
81 | + Map<String, String> params = new HashMap<String, String>(); | |
82 | + params.put("customerTitle", title); | |
83 | + try { | |
84 | + ResponseEntity<Customer> customerEntity = restTemplate.getForEntity(baseURL + "/api/tenant/customers?customerTitle={customerTitle}", Customer.class, params); | |
85 | + return Optional.of(customerEntity.getBody()); | |
86 | + } catch (HttpClientErrorException exception) { | |
87 | + if (exception.getStatusCode() == HttpStatus.NOT_FOUND) { | |
88 | + return Optional.empty(); | |
89 | + } else { | |
90 | + throw exception; | |
91 | + } | |
92 | + } | |
93 | + } | |
94 | + | |
80 | 95 | public Optional<Asset> findAsset(String name) { |
81 | 96 | Map<String, String> params = new HashMap<String, String>(); |
82 | 97 | params.put("assetName", name); |
... | ... | @@ -138,10 +153,6 @@ public class RestClient implements ClientHttpRequestInterceptor { |
138 | 153 | return restTemplate.getForEntity(baseURL + "/api/device/" + id.getId().toString() + "/credentials", DeviceCredentials.class).getBody(); |
139 | 154 | } |
140 | 155 | |
141 | - public Customer getCustomerByTitle(String title) { | |
142 | - return restTemplate.getForEntity(baseURL + "/api/tenant/customers?customerTitle=" + title, Customer.class).getBody(); | |
143 | - } | |
144 | - | |
145 | 156 | public RestTemplate getRestTemplate() { |
146 | 157 | return restTemplate; |
147 | 158 | } | ... | ... |