Skip to content

Commit fbcc591

Browse files
committed
initial commit
0 parents  commit fbcc591

5 files changed

Lines changed: 5927 additions & 0 deletions

File tree

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
target
2+
node
3+
node_modules
4+
.idea
5+
*.iml
6+
.classpath
7+
.project
8+
.settings
9+
.tmp
10+
.merge_file*
11+
.sass-cache
12+
.DS_Store
13+
src/main/webapp/dist
14+
src/main/webapp/bower_components
15+
.gradle
16+
build
17+
misc
18+
19+
# spring-xd related
20+
spring-xd*
21+
custom-modules
22+
23+
# rsa
24+
JAStatus*
25+
rsa_api.log

README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
An example how to generate & use the Datatrans Java SDK from the [openapi](https://api-reference.datatrans.ch/) specification.
2+
3+
### Generating the Java SDK
4+
5+
```sh
6+
# Generate the source files
7+
$ mvn clean compile
8+
```
9+
10+
### Deploy to your own artifacts sever
11+
Currently, the Datatrans Java SDK is not yet available on Maven Central (or something similar).
12+
Thats why you manually need to deploy it to your own artifacts hosting solution.
13+
14+
```
15+
# You might have to adjust your ~/.m2/settings.xml or add a <distributionManagement> section to the pom.xml
16+
$ mvn deploy
17+
```
18+
19+
## Using the Java SDK
20+
Once deployed, add the following dependency:
21+
22+
### Maven users
23+
24+
Add this dependency to your project's POM:
25+
26+
```xml
27+
<dependency>
28+
<groupId>ch.datatrans</groupId>
29+
<artifactId>datatrans-java-sdk</artifactId>
30+
<version>2.0.15</version>
31+
<scope>compile</scope>
32+
</dependency>
33+
```
34+
35+
### Gradle users
36+
37+
Add this dependency to your project's build file:
38+
39+
```groovy
40+
compile "ch.datatrans:datatrans-java-sdk:2.0.15"
41+
```
42+
43+
### Invoking the SDK
44+
```java
45+
ApiClient defaultClient = Configuration.getDefaultApiClient();
46+
defaultClient.setBasePath("https://api.sandbox.datatrans.com");
47+
48+
// Configure HTTP basic authorization: Basic
49+
HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic");
50+
Basic.setUsername("1100017675"); // your Datatrans merchantId
51+
Basic.setPassword("password"); // your Datatrans server to server password
52+
53+
V1TransactionsApi transactionsApiInstance = new V1TransactionsApi(defaultClient);
54+
55+
AuthorizeRequest authorizeRequest = new AuthorizeRequest();
56+
authorizeRequest.setCurrency("CHF");
57+
authorizeRequest.setAmount(100L);
58+
authorizeRequest.setRefno(String.valueOf(System.currentTimeMillis()));
59+
60+
CardAuthorizeRequest cardAuthorizeRequest = new CardAuthorizeRequest();
61+
cardAuthorizeRequest.setAlias("AAABcH0Bq92s3kgAESIAAbGj5NIsAHWC");
62+
cardAuthorizeRequest.setExpiryMonth("12");
63+
cardAuthorizeRequest.setExpiryYear("21");
64+
65+
authorizeRequest.setCard(cardAuthorizeRequest);
66+
67+
try {
68+
AuthorizeResponse result = transactionsApiInstance.authorize(authorizeRequest);
69+
System.out.println(result);
70+
} catch (ApiException e) {
71+
System.err.println("Exception when calling V1AliasesApi#aliasesConvert");
72+
System.err.println("Status code: " + e.getCode());
73+
System.err.println("Reason: " + e.getResponseBody());
74+
System.err.println("Response headers: " + e.getResponseHeaders());
75+
e.printStackTrace();
76+
}
77+
```
78+

UNLICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org/>

pom.xml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>ch.datatrans</groupId>
8+
<artifactId>datatrans-java-sdk-generator</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
<java.version>11</java.version>
14+
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
15+
<gson-fire-version>1.8.5</gson-fire-version>
16+
<swagger-core-version>1.6.2</swagger-core-version>
17+
<okhttp-version>4.9.1</okhttp-version>
18+
<gson-version>2.8.6</gson-version>
19+
<commons-lang3-version>3.11</commons-lang3-version>
20+
<javax-annotation-version>1.3.2</javax-annotation-version>
21+
<junit-version>4.13.1</junit-version>
22+
<jsr305.version>3.0.2</jsr305.version>
23+
<datatrans-json-api.version>2.0.15</datatrans-json-api.version>
24+
<openapi-generator-maven-plugin>5.1.0</openapi-generator-maven-plugin>
25+
<default.package>ch.datatrans</default.package>
26+
</properties>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>io.swagger</groupId>
31+
<artifactId>swagger-annotations</artifactId>
32+
<version>${swagger-core-version}</version>
33+
</dependency>
34+
<!-- @Nullable annotation -->
35+
<dependency>
36+
<groupId>com.google.code.findbugs</groupId>
37+
<artifactId>jsr305</artifactId>
38+
<version>${jsr305.version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>com.squareup.okhttp3</groupId>
42+
<artifactId>okhttp</artifactId>
43+
<version>${okhttp-version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>com.squareup.okhttp3</groupId>
47+
<artifactId>logging-interceptor</artifactId>
48+
<version>${okhttp-version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>com.google.code.gson</groupId>
52+
<artifactId>gson</artifactId>
53+
<version>${gson-version}</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>io.gsonfire</groupId>
57+
<artifactId>gson-fire</artifactId>
58+
<version>${gson-fire-version}</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.apache.commons</groupId>
62+
<artifactId>commons-lang3</artifactId>
63+
<version>${commons-lang3-version}</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>javax.annotation</groupId>
67+
<artifactId>javax.annotation-api</artifactId>
68+
<version>${javax-annotation-version}</version>
69+
<scope>provided</scope>
70+
</dependency>
71+
<!-- test dependencies -->
72+
<dependency>
73+
<groupId>junit</groupId>
74+
<artifactId>junit</artifactId>
75+
<version>${junit-version}</version>
76+
<scope>test</scope>
77+
</dependency>
78+
</dependencies>
79+
80+
<build>
81+
<plugins>
82+
<plugin>
83+
<groupId>org.apache.maven.plugins</groupId>
84+
<artifactId>maven-compiler-plugin</artifactId>
85+
<version>${maven-compiler-plugin.version}</version>
86+
<configuration>
87+
<source>${java.version}</source>
88+
<target>${java.version}</target>
89+
</configuration>
90+
</plugin>
91+
<plugin>
92+
<groupId>org.openapitools</groupId>
93+
<artifactId>openapi-generator-maven-plugin</artifactId>
94+
<version>${openapi-generator-maven-plugin}</version>
95+
<executions>
96+
<execution>
97+
<goals>
98+
<goal>generate</goal>
99+
</goals>
100+
<configuration>
101+
<inputSpec>
102+
${project.basedir}/src/main/resources/datatrans-openapi-specification-${datatrans-json-api.version}.json
103+
</inputSpec>
104+
<generatorName>java</generatorName>
105+
<configOptions>
106+
<groupId>ch.datatrans</groupId>
107+
<artifactId>datatrans-java-sdk</artifactId>
108+
<artifactVersion>2.0.15</artifactVersion>
109+
<!-- https://stackoverflow.com/questions/56237650/use-java-time-instant-to-represent-datetime-instead-of-offsetdatetime/60641140#60641140 -->
110+
<dateLibrary>custom</dateLibrary>
111+
<snapshotVersion>false</snapshotVersion>
112+
<apiPackage>${default.package}.api</apiPackage>
113+
<modelPackage>${default.package}.model</modelPackage>
114+
<invokerPackage>${default.package}.invoker</invokerPackage>
115+
<generateApiTests>false</generateApiTests>
116+
<developerEmail>info@datatrans.ch</developerEmail>
117+
<developerName>Datatrans-Java-SDK-Generator Contributors</developerName>
118+
<developerOrganization>Datatrans AG</developerOrganization>
119+
<developerOrganizationUrl>https://www.datatrans.ch</developerOrganizationUrl>
120+
<scmConnection>scm:git:git@github.com:datatrans/openapi-java-sdk-generator.git</scmConnection>
121+
<scmDeveloperConnection>scm:git:git@github.com:datatrans/openapi-java-sdk-generator.git</scmDeveloperConnection>
122+
<scmUrl>https://github.com/datatrans/openapi-java-sdk-generator</scmUrl>
123+
</configOptions>
124+
<importMappings>
125+
<importMapping>LocalDate=java.time.LocalDate</importMapping>
126+
<importMapping>LocalTime=java.time.LocalTime</importMapping>
127+
</importMappings>
128+
</configuration>
129+
</execution>
130+
</executions>
131+
</plugin>
132+
</plugins>
133+
</build>
134+
135+
136+
</project>

0 commit comments

Comments
 (0)