-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
104 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,160 @@ | ||
// Code generated by RonyKIT Stub Generator (TypeScript); DO NOT EDIT. | ||
|
||
// @ts-ignore | ||
import useSWR, {SWRConfiguration} from 'swr' | ||
|
||
|
||
// ErrorMessage is a data transfer object | ||
export interface ErrorMessage { | ||
code: number | ||
item: string | ||
} | ||
|
||
// Code generated by RonyKIT Stub Generator (TypeScript); DO NOT EDIT. | ||
|
||
import useSWR, { SWRConfiguration } from 'swr' | ||
|
||
// KeyValue is a data transfer object | ||
export interface KeyValue { | ||
key: string | ||
value: number | ||
} | ||
|
||
// ErrorMessage is a data transfer object | ||
export interface ErrorMessage { | ||
code: number | ||
item: string | ||
} | ||
// KeyValue is a data transfer object | ||
export interface KeyValue { | ||
key: string | ||
value: number | ||
} | ||
// SimpleHdr is a data transfer object | ||
export interface SimpleHdr { | ||
sKey1: string | ||
sKey2: number | ||
} | ||
// VeryComplexRequest is a data transfer object | ||
export interface VeryComplexRequest extends SimpleHdr { | ||
key1: string | ||
key1Ptr?: string | ||
mapKey1: {[key: string]: number} | ||
mapKey2: {[key: number]: KeyValue} | ||
sliceKey1: boolean[] | ||
sliceKey2: KeyValue[] | ||
rawKey: any | ||
} | ||
// VeryComplexResponse is a data transfer object | ||
export interface VeryComplexResponse { | ||
key1: string | ||
key1Ptr?: string | ||
mapKey1: {[key: string]: number} | ||
mapKey2: {[key: number]: KeyValue} | ||
sliceKey1: number[] | ||
sliceKey2: KeyValue[] | ||
} | ||
// SimpleHdr is a data transfer object | ||
export interface SimpleHdr { | ||
sKey1: string | ||
sKey2: number | ||
} | ||
|
||
// VeryComplexRequest is a data transfer object | ||
export interface VeryComplexRequest extends SimpleHdr { | ||
key1: string | ||
key1Ptr?: string | ||
mapKey1: { [key: string]: number } | ||
mapKey2: { [key: number]: KeyValue } | ||
sliceKey1: boolean[] | ||
sliceKey2: KeyValue[] | ||
rawKey: any | ||
} | ||
|
||
// VeryComplexResponse is a data transfer object | ||
export interface VeryComplexResponse { | ||
key1: string | ||
key1Ptr?: string | ||
mapKey1: { [key: string]: number } | ||
mapKey2: { [key: number]: KeyValue } | ||
sliceKey1: number[] | ||
sliceKey2: KeyValue[] | ||
} | ||
|
||
|
||
export class sampleServiceStub { | ||
readonly serverURL: string ; | ||
readonly serverURL: string; | ||
|
||
constructor(serverURL: string) { | ||
this.serverURL = serverURL.replace(/\/$/, ''); | ||
} | ||
constructor(serverURL: string) { | ||
this.serverURL = serverURL.replace(/\/$/, ''); | ||
} | ||
|
||
|
||
// @ts-ignore | ||
async complexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise<VeryComplexResponse> { | ||
return fetch(this.serverURL + `/complexDummy`, { | ||
// @ts-ignore | ||
async complexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise<VeryComplexResponse> { | ||
return fetch(this.serverURL + `/complexDummy`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
...headers, | ||
"Content-Type": "application/json", | ||
...headers, | ||
}, | ||
body: JSON.stringify(req) | ||
}).then((res: Response) => { | ||
}).then((res: Response) => { | ||
if (res.status !== 200) { | ||
throw new Error("Failed to fetch the data"); | ||
throw new Error("Failed to fetch the data"); | ||
} | ||
|
||
return res.json() | ||
}) | ||
} | ||
// @ts-ignore | ||
async complexDummy2(req: VeryComplexRequest, headers?: HeadersInit): Promise<VeryComplexResponse> { | ||
return fetch(this.serverURL + `/complexDummy/${req.key1}`, { | ||
}) | ||
} | ||
|
||
// @ts-ignore | ||
async complexDummy2(req: VeryComplexRequest, headers?: HeadersInit): Promise<VeryComplexResponse> { | ||
return fetch(this.serverURL + `/complexDummy/${req.key1}`, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
...headers, | ||
"Content-Type": "application/json", | ||
...headers, | ||
}, | ||
body: JSON.stringify(req) | ||
}).then((res: Response) => { | ||
}).then((res: Response) => { | ||
if (res.status !== 200) { | ||
throw new Error("Failed to fetch the data"); | ||
throw new Error("Failed to fetch the data"); | ||
} | ||
|
||
return res.json() | ||
}) | ||
} | ||
// @ts-ignore | ||
async getComplexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise<VeryComplexResponse> { | ||
const keys = Object.keys(req); | ||
const keyValuePairs = keys.map(key => { | ||
}) | ||
} | ||
|
||
// @ts-ignore | ||
async getComplexDummy(req: VeryComplexRequest, headers?: HeadersInit): Promise<VeryComplexResponse> { | ||
const keys = Object.keys(req); | ||
const keyValuePairs = keys.map(key => { | ||
return encodeURIComponent(key) + '=' + encodeURIComponent((req as any)[key]); | ||
}).join('&'); | ||
const queryParams = (keyValuePairs.length > 0) ? `?${keyValuePairs}`: "" | ||
const url = `${this.serverURL}/complexDummy/${req.key1}/xs/${req.sKey1}${queryParams}`; | ||
return fetch(url, { | ||
}).join('&'); | ||
const queryParams = (keyValuePairs.length > 0) ? `?${keyValuePairs}` : "" | ||
const url = `${this.serverURL}/complexDummy/${req.key1}/xs/${req.sKey1}${queryParams}`; | ||
return fetch(url, { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
...headers, | ||
"Content-Type": "application/json", | ||
...headers, | ||
} | ||
}).then((res: Response) => { | ||
}).then((res: Response) => { | ||
if (res.status !== 200) { | ||
throw new Error("Failed to fetch the data"); | ||
throw new Error("Failed to fetch the data"); | ||
} | ||
|
||
return res.json() | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
} // end of sampleServiceStub | ||
|
||
|
||
export function useComplexDummy( | ||
export function useComplexDummy( | ||
stub: sampleServiceStub, | ||
req: VeryComplexRequest, | ||
reqHeader?: HeadersInit, | ||
options?: Partial<SWRConfiguration<VeryComplexResponse>> | ||
) { | ||
) { | ||
return useSWR( | ||
[req, 'ComplexDummy'], | ||
(req) => { | ||
return stub.complexDummy(req[0], reqHeader) | ||
}, | ||
options | ||
[req, 'ComplexDummy'], | ||
(req) => { | ||
return stub.complexDummy(req[0], reqHeader) | ||
}, | ||
options | ||
) | ||
} | ||
export function useComplexDummy2( | ||
} | ||
|
||
export function useComplexDummy2( | ||
stub: sampleServiceStub, | ||
req: VeryComplexRequest, | ||
reqHeader?: HeadersInit, | ||
options?: Partial<SWRConfiguration<VeryComplexResponse>> | ||
) { | ||
) { | ||
return useSWR( | ||
[req, 'ComplexDummy2'], | ||
(req) => { | ||
return stub.complexDummy2(req[0], reqHeader) | ||
}, | ||
options | ||
[req, 'ComplexDummy2'], | ||
(req) => { | ||
return stub.complexDummy2(req[0], reqHeader) | ||
}, | ||
options | ||
) | ||
} | ||
export function useGetComplexDummy( | ||
} | ||
|
||
export function useGetComplexDummy( | ||
stub: sampleServiceStub, | ||
req: VeryComplexRequest, | ||
reqHeader?: HeadersInit, | ||
options?: Partial<SWRConfiguration<VeryComplexResponse>> | ||
) { | ||
) { | ||
return useSWR( | ||
[req, 'GetComplexDummy'], | ||
(req) => { | ||
return stub.getComplexDummy(req[0], reqHeader) | ||
}, | ||
options | ||
[req, 'GetComplexDummy'], | ||
(req) => { | ||
return stub.getComplexDummy(req[0], reqHeader) | ||
}, | ||
options | ||
) | ||
} | ||
} |