Skip to content

Commit b0ff55c

Browse files
Release 5.1.0
1 parent 5f14dd9 commit b0ff55c

File tree

204 files changed

+8141
-13592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+8141
-13592
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add this dependency to your project's POM:
2323
<dependency>
2424
<groupId>ch.postfinance</groupId>
2525
<artifactId>postfinancecheckout-java-sdk</artifactId>
26-
<version>5.0.0</version>
26+
<version>5.1.0</version>
2727
<scope>compile</scope>
2828
</dependency>
2929
```
@@ -33,7 +33,7 @@ Add this dependency to your project's POM:
3333
Add this dependency to your project's build file:
3434

3535
```groovy
36-
compile "ch.postfinance:postfinancecheckout-java-sdk:5.0.0"
36+
compile "ch.postfinance:postfinancecheckout-java-sdk:5.1.0"
3737
```
3838

3939
### Others
@@ -46,7 +46,7 @@ mvn clean package
4646

4747
Then manually install the following JARs:
4848

49-
* `target/postfinancecheckout-java-sdk-5.0.0.jar`
49+
* `target/postfinancecheckout-java-sdk-5.1.0.jar`
5050
* `target/lib/*.jar`
5151

5252
## Usage

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apply plugin: 'idea'
22
apply plugin: 'eclipse'
33

44
group = 'ch.postfinance'
5-
version = '5.0.0'
5+
version = '5.1.0'
66

77
buildscript {
88
repositories {
@@ -97,19 +97,19 @@ ext {
9797
swagger_annotations_version = "1.5.17"
9898
jackson_version = "2.14.1"
9999
google_api_client_version = "1.23.0"
100-
jersey_common_version = "2.34"
101100
jodatime_version = "2.9.9"
102101
junit_version = "4.13.2"
102+
httpclient_version = "4.5.14"
103103
}
104104

105105
dependencies {
106106
compile "io.swagger:swagger-annotations:$swagger_annotations_version"
107107
compile "com.google.api-client:google-api-client:${google_api_client_version}"
108-
compile "org.glassfish.jersey.core:jersey-common:${jersey_common_version}"
109108
compile "com.fasterxml.jackson.core:jackson-core:$jackson_version"
110109
compile "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
111110
compile "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
112111
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jackson_version"
112+
compile "org.apache.httpcomponents:httpclient:$httpclient_version"
113113
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_version"
114114
testCompile "junit:junit:$junit_version"
115115
}

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ lazy val root = (project in file(".")).
22
settings(
33
organization := "ch.postfinance",
44
name := "postfinancecheckout-java-sdk",
5-
version := "5.0.0",
5+
version := "5.1.0",
66
scalaVersion := "2.11.4",
77
scalacOptions ++= Seq("-feature"),
88
javacOptions in compile ++= Seq("-Xlint:deprecation"),
@@ -15,6 +15,7 @@ lazy val root = (project in file(".")).
1515
"com.fasterxml.jackson.core" % "jackson-core" % "2.14.1" % "compile",
1616
"com.fasterxml.jackson.core" % "jackson-annotations" % "2.14.1" % "compile",
1717
"com.fasterxml.jackson.core" % "jackson-databind" % "2.14.1" % "compile",
18+
"org.apache.httpcomponents" % "httpclient" % "4.5.14" % "compile",
1819
"com.fasterxml.jackson.datatype" % "jackson-datatype-jsr310" % "2.14.1" % "compile",
1920
"junit" % "junit" % "4.13.2" % "test",
2021
"com.novocode" % "junit-interface" % "0.10" % "test"

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>postfinancecheckout-java-sdk</artifactId>
66
<packaging>jar</packaging>
77
<name>postfinancecheckout-java-sdk</name>
8-
<version>5.0.0</version>
8+
<version>5.1.0</version>
99
<url>https://postfinance.ch/en/business/products/e-commerce/postfinance-checkout-all-in-one.html</url>
1010
<description>The SDK for simplifying the integration with PostFinance Checkout API.</description>
1111
<scm>
@@ -269,11 +269,11 @@
269269
<artifactId>google-api-client</artifactId>
270270
<version>${google-api-client-version}</version>
271271
</dependency>
272-
<!-- Jersey common to get an implementation of javax.ws.rs.core.UriBuilder for building URLs from templates -->
272+
<!-- Apache HttpClient for building URLs from templates -->
273273
<dependency>
274-
<groupId>org.glassfish.jersey.core</groupId>
275-
<artifactId>jersey-common</artifactId>
276-
<version>${jersey-common-version}</version>
274+
<groupId>org.apache.httpcomponents</groupId>
275+
<artifactId>httpclient</artifactId>
276+
<version>${apache-httpclient-version}</version>
277277
</dependency>
278278
<!-- JSON processing: jackson -->
279279
<dependency>
@@ -309,8 +309,8 @@
309309
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
310310
<swagger-annotations-version>1.5.17</swagger-annotations-version>
311311
<google-api-client-version>1.23.0</google-api-client-version>
312-
<jersey-common-version>2.34</jersey-common-version>
313312
<jackson-version>2.14.1</jackson-version>
313+
<apache-httpclient-version>4.5.14</apache-httpclient-version>
314314
<maven-plugin-version>1.0.0</maven-plugin-version>
315315
<junit-version>4.13.2</junit-version>
316316
</properties>

src/main/java/ch/postfinance/sdk/DefaultHeaders.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public void intercept(HttpRequest request) throws IOException {
3434

3535
private HttpHeaders getDefaultHeaders() {
3636
HttpHeaders headers = new HttpHeaders();
37-
headers.put("x-meta-sdk-version", "5.0.0");
37+
headers.put("x-meta-sdk-version", "5.1.0");
3838
headers.put("x-meta-sdk-language", "java");
3939
headers.put("x-meta-sdk-provider", "PostFinance Checkout");
4040
headers.put("x-meta-sdk-language-version", System.getProperty("java.version"));

src/main/java/ch/postfinance/sdk/PostFinanceCheckoutSdkException.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,36 @@ public class PostFinanceCheckoutSdkException extends RuntimeException {
2626

2727
private static final long serialVersionUID = 1675383192982547616L;
2828

29+
private final ErrorCode code;
30+
31+
private final String message;
32+
2933
/**
3034
* Constructor.
3135
*
32-
* @param errorCode
36+
* @param code
3337
* the PostFinanceCheckout SDK error code
3438
* @param message
3539
* the exception message details
3640
*/
37-
public PostFinanceCheckoutSdkException(ErrorCode errorCode, String message) {
38-
super(String.format("Error code: %d. %s", errorCode.getCode(), message));
41+
public PostFinanceCheckoutSdkException(ErrorCode code, String message) {
42+
super();
43+
this.code = code;
44+
this.message = String.format("Error code: %d. %s", code.getCode(), message);
3945
}
4046

47+
/**
48+
* @return the PostFinanceCheckout SDK error code
49+
*/
50+
public ErrorCode getCode() {
51+
return this.code;
52+
}
53+
54+
/**
55+
* @return the PostFinanceCheckout SDK error message
56+
*/
57+
public String getMessage() {
58+
return this.message;
59+
}
60+
4161
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* PostFinance Checkout SDK
3+
*
4+
* This library allows to interact with the PostFinance Checkout payment service.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
20+
package ch.postfinance.sdk;
21+
22+
import com.google.api.client.http.UriTemplate;
23+
import java.net.URI;
24+
import java.net.URISyntaxException;
25+
import java.util.Collection;
26+
import java.util.Map;
27+
import java.util.regex.Matcher;
28+
import java.util.regex.Pattern;
29+
import java.util.stream.Collectors;
30+
import org.apache.http.client.utils.URIBuilder;
31+
32+
/**
33+
* Helper class for creating and modifying URIBuilder {@link URIBuilder}
34+
*/
35+
public final class URIBuilderUtil {
36+
/**
37+
* Create a new URIBuilder instance from url
38+
*
39+
* @throws IllegalArgumentException if url is not a valid URI template or is null.
40+
* @param url to be used as URI
41+
* @return a new {@link URIBuilder}
42+
*/
43+
public static URIBuilder create(String url) {
44+
try {
45+
return new URIBuilder(url);
46+
} catch (URISyntaxException e) {
47+
throw new IllegalArgumentException("Invalid URI: " + e.getLocalizedMessage());
48+
}
49+
}
50+
51+
/**
52+
* Create a new {@link URIBuilder} instance from url with parameters
53+
*
54+
* @throws IllegalArgumentException if url is not a valid URI template or is null.
55+
* @param url to be used as URI template
56+
* @param pathParameters path parameters to be resolved in url
57+
* @return a new {@link URIBuilder}
58+
*/
59+
public static URIBuilder create(String url, Map<String, Object> pathParameters) {
60+
try {
61+
return new URIBuilder(UriTemplate.expand(url, pathParameters, false));
62+
} catch (URISyntaxException e) {
63+
throw new IllegalArgumentException("Invalid URI: " + e.getLocalizedMessage());
64+
}
65+
}
66+
67+
/**
68+
* Build {@link URIBuilder} to {@link URI}
69+
*
70+
* @throws IllegalArgumentException if url is not a valid URI template or is null.
71+
* @param uriBuilder {@link URIBuilder} to build
72+
* @return a new {@link URI}
73+
*/
74+
public static URI build(URIBuilder uriBuilder) {
75+
try {
76+
return uriBuilder.build();
77+
} catch (URISyntaxException e) {
78+
throw new IllegalArgumentException("Invalid URI: " + e.getLocalizedMessage());
79+
}
80+
}
81+
82+
/**
83+
* Apply query parameter
84+
* @param uriBuilder uri builder instance query parameters will applied to
85+
* @param paramName query parameter name
86+
* @param paramValue query parameter value
87+
* @return uri builder with applied parameters
88+
*/
89+
public static URIBuilder applyQueryParam(URIBuilder uriBuilder, String paramName, Object paramValue) {
90+
if (paramValue instanceof Collection) {
91+
uriBuilder = applyCollection(uriBuilder, paramName, ((Collection) paramValue).toArray());
92+
} else if (paramValue instanceof Object[]) {
93+
uriBuilder = applyCollection(uriBuilder, paramName, (Object[]) paramValue);
94+
} else {
95+
uriBuilder = uriBuilder.addParameter(paramName, paramValue.toString());
96+
}
97+
return uriBuilder;
98+
}
99+
100+
private static URIBuilder applyCollection(URIBuilder uriBuilder, String paramName, Object[] paramValues) {
101+
for (Object paramValue: paramValues) {
102+
uriBuilder.addParameter(paramName, paramValue.toString());
103+
}
104+
return uriBuilder;
105+
}
106+
}

src/main/java/ch/postfinance/sdk/model/AbstractAccountUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public AbstractAccountUpdate lastModifiedDate(OffsetDateTime lastModifiedDate) {
5555
}
5656

5757
/**
58-
*
58+
* The date and time when the object was last modified.
5959
* @return lastModifiedDate
6060
**/
61-
@ApiModelProperty(value = "")
61+
@ApiModelProperty(value = "The date and time when the object was last modified.")
6262
public OffsetDateTime getLastModifiedDate() {
6363
return lastModifiedDate;
6464
}

src/main/java/ch/postfinance/sdk/model/AbstractApplicationUserUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public AbstractApplicationUserUpdate state(CreationEntityState state) {
9393
}
9494

9595
/**
96-
*
96+
* The object&#39;s current state.
9797
* @return state
9898
**/
99-
@ApiModelProperty(value = "")
99+
@ApiModelProperty(value = "The object's current state.")
100100
public CreationEntityState getState() {
101101
return state;
102102
}

src/main/java/ch/postfinance/sdk/model/AbstractCustomerActive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ public AbstractCustomerActive language(String language) {
149149
}
150150

151151
/**
152-
*
152+
* The language that is linked to the object.
153153
* @return language
154154
**/
155-
@ApiModelProperty(value = "")
155+
@ApiModelProperty(value = "The language that is linked to the object.")
156156
public String getLanguage() {
157157
return language;
158158
}

src/main/java/ch/postfinance/sdk/model/AbstractHumanUserUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,10 @@ public AbstractHumanUserUpdate state(CreationEntityState state) {
170170
}
171171

172172
/**
173-
*
173+
* The object&#39;s current state.
174174
* @return state
175175
**/
176-
@ApiModelProperty(value = "")
176+
@ApiModelProperty(value = "The object's current state.")
177177
public CreationEntityState getState() {
178178
return state;
179179
}

src/main/java/ch/postfinance/sdk/model/AbstractSpaceUpdate.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public AbstractSpaceUpdate lastModifiedDate(OffsetDateTime lastModifiedDate) {
7979
}
8080

8181
/**
82-
*
82+
* The date and time when the object was last modified.
8383
* @return lastModifiedDate
8484
**/
85-
@ApiModelProperty(value = "")
85+
@ApiModelProperty(value = "The date and time when the object was last modified.")
8686
public OffsetDateTime getLastModifiedDate() {
8787
return lastModifiedDate;
8888
}
@@ -174,10 +174,10 @@ public AbstractSpaceUpdate state(CreationEntityState state) {
174174
}
175175

176176
/**
177-
*
177+
* The object&#39;s current state.
178178
* @return state
179179
**/
180-
@ApiModelProperty(value = "")
180+
@ApiModelProperty(value = "The object's current state.")
181181
public CreationEntityState getState() {
182182
return state;
183183
}

src/main/java/ch/postfinance/sdk/model/AbstractTokenUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ public AbstractTokenUpdate language(String language) {
123123
}
124124

125125
/**
126-
*
126+
* The language that is linked to the object.
127127
* @return language
128128
**/
129-
@ApiModelProperty(value = "")
129+
@ApiModelProperty(value = "The language that is linked to the object.")
130130
public String getLanguage() {
131131
return language;
132132
}

src/main/java/ch/postfinance/sdk/model/AbstractTransactionPending.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,10 @@ public AbstractTransactionPending language(String language) {
313313
}
314314

315315
/**
316-
*
316+
* The language that is linked to the object.
317317
* @return language
318318
**/
319-
@ApiModelProperty(value = "")
319+
@ApiModelProperty(value = "The language that is linked to the object.")
320320
public String getLanguage() {
321321
return language;
322322
}

src/main/java/ch/postfinance/sdk/model/AbstractWebhookListenerUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ public AbstractWebhookListenerUpdate state(CreationEntityState state) {
126126
}
127127

128128
/**
129-
*
129+
* The object&#39;s current state.
130130
* @return state
131131
**/
132-
@ApiModelProperty(value = "")
132+
@ApiModelProperty(value = "The object's current state.")
133133
public CreationEntityState getState() {
134134
return state;
135135
}

src/main/java/ch/postfinance/sdk/model/AbstractWebhookUrlUpdate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ public AbstractWebhookUrlUpdate state(CreationEntityState state) {
7474
}
7575

7676
/**
77-
*
77+
* The object&#39;s current state.
7878
* @return state
7979
**/
80-
@ApiModelProperty(value = "")
80+
@ApiModelProperty(value = "The object's current state.")
8181
public CreationEntityState getState() {
8282
return state;
8383
}

0 commit comments

Comments
 (0)