View Javadoc
1   package com.srv4pos.server.api.buildinfo;
2   
3   import com.srv4pos.server.api.infrastructure.EmptyConnectionWriter;
4   import com.srv4pos.server.api.infrastructure.HttpMethod;
5   import com.srv4pos.server.api.infrastructure.credentials.Credentials;
6   import com.srv4pos.server.api.infrastructure.http.HttpHelper;
7   import com.srv4pos.server.api.infrastructure.http.Transport;
8   import com.srv4pos.server.api.infrastructure.exceptions.enums.ForbiddenErrorType;
9   
10  import java.net.URL;
11  import java.util.Collection;
12  
13  import static com.srv4pos.server.api.infrastructure.request.RequestHelper.requestString;
14  import static java.lang.String.format;
15  
16  public class BuildInfoService {
17      private URL url;
18      private Credentials credentials;
19      private Transport transport;
20  
21      public BuildInfoService(URL url, Credentials credentials, Transport transport) {
22          this.url = url;
23          this.credentials = credentials;
24          this.transport = transport;
25      }
26  
27      /**
28       * Returns list of entities.
29       *
30       * @param productionNumber unique installation identifier.
31       * @return list of entities
32       * @throws com.srv4pos.server.api.exceptions.NotFoundJsonException  if installation wasn't found.
33       * @throws com.srv4pos.server.api.exceptions.ForbiddenJsonException see:
34       *                                                                  {@link ForbiddenErrorType#INSUFFICIENT_ACCESS_RIGHTS}
35       */
36      public Collection<BuildInfoInfo> list(String productionNumber) {
37  
38          return BuildInfoInfo.fromJsonArrayToBuildInfoInfoes(requestString(
39                  format("installations/%s/build-infoes", productionNumber),
40                  HttpMethod.GET,
41                  url,
42                  credentials.toAuthentication(),
43                  null,
44                  null,
45                  EmptyConnectionWriter.EMPTY_CONNECTION_WRITER,
46                  HttpHelper.CONTENT_TYPE_APPLICATION_JSON,
47                  transport).getContent());
48      }
49  }