1- import type { AxiosRequestConfig } from 'axios'
1+ import type { Method } from 'axios'
22
33import type { Client } from './client.js'
44import { SeamHttpActionAttempts } from './index.js'
@@ -10,6 +10,13 @@ export interface SeamHttpRequestParent {
1010 readonly defaults : Required < SeamHttpRequestOptions >
1111}
1212
13+ export interface SeamHttpRequestConfig < TBody > {
14+ url ?: string
15+ method ?: Method
16+ params ?: any
17+ data ?: TBody
18+ }
19+
1320export type ResponseFromSeamHttpRequest < T > =
1421 T extends SeamHttpRequest < any , infer TResponse , infer TResourceKey >
1522 ? TResourceKey extends keyof TResponse
@@ -27,27 +34,39 @@ export class SeamHttpRequest<
2734 >
2835{
2936 readonly parent : SeamHttpRequestParent
30- readonly requestConfig : AxiosRequestConfig < TBody >
37+ readonly config : SeamHttpRequestConfig < TBody >
3138 readonly resourceKey : TResourceKey
3239 readonly options : Pick < SeamHttpRequestOptions , 'waitForActionAttempt' >
3340
3441 constructor (
3542 parent : SeamHttpRequestParent ,
36- requestConfig : AxiosRequestConfig < TBody > ,
43+ config : SeamHttpRequestConfig < TBody > ,
3744 resourceKey : TResourceKey ,
3845 options : Pick < SeamHttpRequestOptions , 'waitForActionAttempt' > = { } ,
3946 ) {
4047 this . parent = parent
41- this . requestConfig = requestConfig
48+ this . config = config
4249 this . resourceKey = resourceKey
4350 this . options = options
4451 }
4552
53+ public get url ( ) : string {
54+ return this . config . url ?? ''
55+ }
56+
57+ public get method ( ) : Method {
58+ return this . config . method ?? 'get'
59+ }
60+
61+ public get data ( ) : TBody {
62+ return this . config . data as TBody
63+ }
64+
4665 async execute ( ) : Promise <
4766 TResourceKey extends keyof TResponse ? TResponse [ TResourceKey ] : undefined
4867 > {
4968 const { client } = this . parent
50- const response = await client . request ( this . requestConfig )
69+ const response = await client . request ( this . config )
5170 if ( this . resourceKey === undefined ) {
5271 return undefined as TResourceKey extends keyof TResponse
5372 ? TResponse [ TResourceKey ]
0 commit comments