|
2 | 2 |
|
3 | 3 | import com.postfinancecheckout.sdk.ApiClient;
|
4 | 4 |
|
| 5 | +import com.postfinancecheckout.sdk.model.Charge; |
5 | 6 | import com.postfinancecheckout.sdk.model.ClientError;
|
6 | 7 | import com.postfinancecheckout.sdk.model.EntityQuery;
|
7 | 8 | import com.postfinancecheckout.sdk.model.EntityQueryFilter;
|
@@ -879,6 +880,140 @@ public HttpResponse deleteForHttpResponse(Long spaceId, Long id, Map<String, Obj
|
879 | 880 | HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content);
|
880 | 881 |
|
881 | 882 |
|
| 883 | + httpRequest.setReadTimeout(ApiClient.READ_TIMEOUT); |
| 884 | + return httpRequest.execute(); |
| 885 | + } |
| 886 | + |
| 887 | + /** |
| 888 | + * Process Transaction |
| 889 | + * This operation processes the given transaction by using the token associated with the transaction. |
| 890 | + * <p><b>200</b> - This status code indicates that a client request was successfully received, understood, and accepted. |
| 891 | + * <p><b>442</b> - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. |
| 892 | + * <p><b>542</b> - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. |
| 893 | + * @param spaceId |
| 894 | + * @param transactionId The id of the transaction for which we want to check if the token can be created or not. |
| 895 | + * @return Charge |
| 896 | + * @throws IOException if an error occurs while attempting to invoke the API |
| 897 | + * For more information visit this link. |
| 898 | + * @see <a href="https://checkout.postfinance.ch/doc/api/web-service#token-service--process-transaction">Process Transaction Documentation</a> |
| 899 | +
|
| 900 | + **/ |
| 901 | + public Charge processTransaction(Long spaceId, Long transactionId) throws IOException { |
| 902 | + HttpResponse response = processTransactionForHttpResponse(spaceId, transactionId); |
| 903 | + String returnType = "Charge"; |
| 904 | + if(returnType.equals("String")){ |
| 905 | + return (Charge) (Object) response.parseAsString(); |
| 906 | + } |
| 907 | + TypeReference typeRef = new TypeReference<Charge>() {}; |
| 908 | + return (Charge)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); |
| 909 | + } |
| 910 | + |
| 911 | + /** |
| 912 | + * Process Transaction |
| 913 | + * This operation processes the given transaction by using the token associated with the transaction. |
| 914 | + * <p><b>200</b> - This status code indicates that a client request was successfully received, understood, and accepted. |
| 915 | + * <p><b>442</b> - This status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error. |
| 916 | + * <p><b>542</b> - This status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the client request. |
| 917 | + * @param spaceId |
| 918 | + * @param transactionId The id of the transaction for which we want to check if the token can be created or not. |
| 919 | + * @param params Map of query params. A collection will be interpreted as passing in multiple instances of the same query param. |
| 920 | + * @return Charge |
| 921 | + * @throws IOException if an error occurs while attempting to invoke the API |
| 922 | + * For more information visit this link. |
| 923 | + * @see <a href="https://checkout.postfinance.ch/doc/api/web-service#token-service--process-transaction">Process Transaction Documentation</a> |
| 924 | +
|
| 925 | + **/ |
| 926 | + public Charge processTransaction(Long spaceId, Long transactionId, Map<String, Object> params) throws IOException { |
| 927 | + HttpResponse response = processTransactionForHttpResponse(spaceId, transactionId, params); |
| 928 | + String returnType = "Charge"; |
| 929 | + if(returnType.equals("String")){ |
| 930 | + return (Charge) (Object) response.parseAsString(); |
| 931 | + } |
| 932 | + TypeReference typeRef = new TypeReference<Charge>() {}; |
| 933 | + return (Charge)apiClient.getObjectMapper().readValue(response.getContent(), typeRef); |
| 934 | + } |
| 935 | + |
| 936 | + public HttpResponse processTransactionForHttpResponse(Long spaceId, Long transactionId) throws IOException { |
| 937 | + // verify the required parameter 'spaceId' is set |
| 938 | + if (spaceId == null) { |
| 939 | + throw new IllegalArgumentException("Missing the required parameter 'spaceId' when calling processTransaction"); |
| 940 | + }// verify the required parameter 'transactionId' is set |
| 941 | + if (transactionId == null) { |
| 942 | + throw new IllegalArgumentException("Missing the required parameter 'transactionId' when calling processTransaction"); |
| 943 | + } |
| 944 | + UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/token/process-transaction"); |
| 945 | + if (spaceId != null) { |
| 946 | + String key = "spaceId"; |
| 947 | + Object value = spaceId; |
| 948 | + if (value instanceof Collection) { |
| 949 | + uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); |
| 950 | + } else if (value instanceof Object[]) { |
| 951 | + uriBuilder = uriBuilder.queryParam(key, (Object[]) value); |
| 952 | + } else { |
| 953 | + uriBuilder = uriBuilder.queryParam(key, value); |
| 954 | + } |
| 955 | + } if (transactionId != null) { |
| 956 | + String key = "transactionId"; |
| 957 | + Object value = transactionId; |
| 958 | + if (value instanceof Collection) { |
| 959 | + uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); |
| 960 | + } else if (value instanceof Object[]) { |
| 961 | + uriBuilder = uriBuilder.queryParam(key, (Object[]) value); |
| 962 | + } else { |
| 963 | + uriBuilder = uriBuilder.queryParam(key, value); |
| 964 | + } |
| 965 | + } |
| 966 | + |
| 967 | + String url = uriBuilder.build().toString(); |
| 968 | + GenericUrl genericUrl = new GenericUrl(url); |
| 969 | + |
| 970 | + HttpContent content = apiClient.new JacksonJsonHttpContent(null); |
| 971 | + HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); |
| 972 | + |
| 973 | + |
| 974 | + httpRequest.setReadTimeout(ApiClient.READ_TIMEOUT); |
| 975 | + return httpRequest.execute(); |
| 976 | + } |
| 977 | + |
| 978 | + public HttpResponse processTransactionForHttpResponse(Long spaceId, Long transactionId, Map<String, Object> params) throws IOException { |
| 979 | + // verify the required parameter 'spaceId' is set |
| 980 | + if (spaceId == null) { |
| 981 | + throw new IllegalArgumentException("Missing the required parameter 'spaceId' when calling processTransaction"); |
| 982 | + }// verify the required parameter 'transactionId' is set |
| 983 | + if (transactionId == null) { |
| 984 | + throw new IllegalArgumentException("Missing the required parameter 'transactionId' when calling processTransaction"); |
| 985 | + } |
| 986 | + UriBuilder uriBuilder = UriBuilder.fromUri(apiClient.getBasePath() + "/token/process-transaction"); |
| 987 | + |
| 988 | + // Copy the params argument if present, to allow passing in immutable maps |
| 989 | + Map<String, Object> allParams = params == null ? new HashMap<String, Object>() : new HashMap<String, Object>(params); |
| 990 | + // Add the required query param 'spaceId' to the map of query params |
| 991 | + allParams.put("spaceId", spaceId); |
| 992 | + // Add the required query param 'transactionId' to the map of query params |
| 993 | + allParams.put("transactionId", transactionId); |
| 994 | + |
| 995 | + for (Map.Entry<String, Object> entryMap: allParams.entrySet()) { |
| 996 | + String key = entryMap.getKey(); |
| 997 | + Object value = entryMap.getValue(); |
| 998 | + |
| 999 | + if (key != null && value != null) { |
| 1000 | + if (value instanceof Collection) { |
| 1001 | + uriBuilder = uriBuilder.queryParam(key, ((Collection) value).toArray()); |
| 1002 | + } else if (value instanceof Object[]) { |
| 1003 | + uriBuilder = uriBuilder.queryParam(key, (Object[]) value); |
| 1004 | + } else { |
| 1005 | + uriBuilder = uriBuilder.queryParam(key, value); |
| 1006 | + } |
| 1007 | + } |
| 1008 | + } |
| 1009 | + |
| 1010 | + String url = uriBuilder.build().toString(); |
| 1011 | + GenericUrl genericUrl = new GenericUrl(url); |
| 1012 | + |
| 1013 | + HttpContent content = apiClient.new JacksonJsonHttpContent(null); |
| 1014 | + HttpRequest httpRequest = apiClient.getHttpRequestFactory().buildRequest(HttpMethods.POST, genericUrl, content); |
| 1015 | + |
| 1016 | + |
882 | 1017 | httpRequest.setReadTimeout(ApiClient.READ_TIMEOUT);
|
883 | 1018 | return httpRequest.execute();
|
884 | 1019 | }
|
|
0 commit comments