File tree 8 files changed +82
-7
lines changed
java/io/dirigible/samples/api
resources/META-INF/dirigible/custom-api
8 files changed +82
-7
lines changed Original file line number Diff line number Diff line change 1
1
package io .dirigible .samples .api .client ;
2
2
3
- import java .time .ZonedDateTime ;
3
+ import java .util .Date ;
4
+
5
+ import com .google .gson .Gson ;
4
6
5
7
import io .dirigible .samples .api .domain .Example ;
6
8
import io .dirigible .samples .api .domain .SubExample ;
@@ -13,10 +15,11 @@ public class ExampleClient implements ExampleService {
13
15
@ Override
14
16
public ExampleResponse doExample (ExampleRequest request ) {
15
17
final var exampleResponse = new ExampleResponse ();
16
- final var subexample = new SubExample ().withDate (ZonedDateTime . now ());
18
+ final var subexample = new SubExample ().withDate (new Date ());
17
19
final var example = new Example ().withId (request .getExampleId ()).withName ("Example Name" );
18
20
example .getSubexamples ().add (subexample );
19
21
exampleResponse .getExamples ().add (example );
22
+ new Gson ().fromJson ("" , ExampleRequest .class );
20
23
return exampleResponse ;
21
24
}
22
25
Original file line number Diff line number Diff line change
1
+ package io .dirigible .samples .api .client ;
2
+
3
+ import java .util .Date ;
4
+
5
+ import com .google .gson .Gson ;
6
+
7
+ import io .dirigible .samples .api .domain .Example ;
8
+ import io .dirigible .samples .api .domain .SubExample ;
9
+ import io .dirigible .samples .api .domain .input .ExampleRequest ;
10
+ import io .dirigible .samples .api .domain .output .ExampleResponse ;
11
+
12
+ public class ExampleClientV2 {
13
+
14
+ public String doExample (String requestAsString ) {
15
+ final var gson = new Gson ();
16
+ final var request = gson .fromJson (requestAsString , ExampleRequest .class );
17
+ final var exampleResponse = new ExampleResponse ();
18
+ final var subexample = new SubExample ().withDate (new Date ());
19
+ final var example = new Example ().withId (request .getExampleId ()).withName ("Example Name" );
20
+ example .getSubexamples ().add (subexample );
21
+ exampleResponse .getExamples ().add (example );
22
+ return gson .toJson (exampleResponse );
23
+ }
24
+
25
+ }
Original file line number Diff line number Diff line change 1
1
package io .dirigible .samples .api .domain ;
2
2
3
- import java .time . ZonedDateTime ;
3
+ import java .util . Date ;
4
4
5
5
public class SubExample {
6
6
7
- private ZonedDateTime date ;
7
+ private Date date ;
8
8
9
- public ZonedDateTime getDate () {
9
+ public Date getDate () {
10
10
return date ;
11
11
}
12
12
13
- public void setDate (ZonedDateTime date ) {
13
+ public void setDate (Date date ) {
14
14
this .date = date ;
15
15
}
16
16
17
- public SubExample withDate (ZonedDateTime date ) {
17
+ public SubExample withDate (Date date ) {
18
18
setDate (date );
19
19
return this ;
20
20
}
Original file line number Diff line number Diff line change
1
+ import { ExampleResponseV2 } from "./ExampleResponseV2" ;
2
+ import { ExampleRequestV2 } from "./ExampleRequestV2" ;
3
+
4
+ const ExampleClientV2Class = Java . type ( "io.dirigible.samples.api.client.ExampleClientV2" ) ;
5
+
6
+ export class ExampleClientV2 {
7
+
8
+ public doExample ( request : ExampleRequestV2 ) : ExampleResponseV2 {
9
+ const response = new ExampleClientV2Class ( ) . doExample ( JSON . stringify ( request ) ) ;
10
+ return JSON . parse ( response ) ;
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ export interface ExampleRequestV2 {
2
+ readonly exampleId : string ;
3
+ readonly exampleName : string ;
4
+ }
Original file line number Diff line number Diff line change
1
+ export interface SubExampleV2 {
2
+ readonly date : Date ;
3
+ }
4
+
5
+ export interface ExampleV2 {
6
+ readonly id : string ;
7
+ readonly name : string ;
8
+ readonly subexamples : SubExampleV2 [ ] ;
9
+ }
10
+
11
+ export interface ExampleResponseV2 {
12
+ readonly examples : ExampleV2 [ ] ;
13
+ }
Original file line number Diff line number Diff line change
1
+ import { response } from "sdk/http" ;
2
+ import { ExampleClientV2 } from "custom-api/ExampleClientV2" ;
3
+ import { ExampleRequestV2 } from "custom-api/ExampleRequestV2" ;
4
+
5
+ const exampleRequest : ExampleRequestV2 = {
6
+ exampleId : 'example-id-1234' ,
7
+ exampleName : 'Custom Stack Example'
8
+ } ;
9
+
10
+ const exampleClient = new ExampleClientV2 ( ) ;
11
+ const exampleResponse = exampleClient . doExample ( exampleRequest ) ;
12
+
13
+ response . println ( JSON . stringify ( exampleResponse , null , 2 ) ) ;
Original file line number Diff line number Diff line change 155
155
</exclusions >
156
156
</dependency >
157
157
158
+ <dependency >
159
+ <groupId >com.google.code.gson</groupId >
160
+ <artifactId >gson</artifactId >
161
+ </dependency >
162
+
158
163
</dependencies >
159
164
160
165
<dependencyManagement >
You can’t perform that action at this time.
0 commit comments