@@ -20,6 +20,11 @@ interface SeamHttpRequestConfig<TResponseKey> {
20
20
readonly options ?: Pick < SeamHttpRequestOptions , 'waitForActionAttempt' >
21
21
}
22
22
23
+ interface Pagination {
24
+ readonly hasNextPage : boolean
25
+ readonly nextPageCursor : string | null
26
+ }
27
+
23
28
export class SeamHttpRequest <
24
29
const TResponse ,
25
30
const TResponseKey extends keyof TResponse | undefined ,
@@ -33,6 +38,8 @@ export class SeamHttpRequest<
33
38
readonly #parent: SeamHttpRequestParent
34
39
readonly #config: SeamHttpRequestConfig < TResponseKey >
35
40
41
+ #pagination: Pagination | null = null
42
+
36
43
constructor (
37
44
parent : SeamHttpRequestParent ,
38
45
config : SeamHttpRequestConfig < TResponseKey > ,
@@ -56,15 +63,18 @@ export class SeamHttpRequest<
56
63
57
64
const origin = getUrlPrefix ( client . defaults . baseURL ?? '' )
58
65
59
- const pathname = this . #config. path . startsWith ( '/' )
60
- ? this . #config. path
61
- : `/${ this . #config. path } `
62
-
63
- const path = params == null ? pathname : `${ pathname } ?${ serializer ( params ) } `
66
+ const path =
67
+ params == null ? this . pathname : `${ this . pathname } ?${ serializer ( params ) } `
64
68
65
69
return new URL ( `${ origin } ${ path } ` )
66
70
}
67
71
72
+ public get pathname ( ) : string {
73
+ return this . #config. path . startsWith ( '/' )
74
+ ? this . #config. path
75
+ : `/${ this . #config. path } `
76
+ }
77
+
68
78
public get method ( ) : Method {
69
79
return this . #config. method
70
80
}
@@ -73,6 +83,10 @@ export class SeamHttpRequest<
73
83
return this . #config. body
74
84
}
75
85
86
+ public get pagination ( ) : Pagination | null {
87
+ return this . #pagination
88
+ }
89
+
76
90
async execute ( ) : Promise <
77
91
TResponseKey extends keyof TResponse ? TResponse [ TResponseKey ] : undefined
78
92
> {
@@ -88,6 +102,7 @@ export class SeamHttpRequest<
88
102
? TResponse [ TResponseKey ]
89
103
: undefined
90
104
}
105
+ if ( 'pagination' in response . data ) this . #pagination = this . pagination
91
106
const data = response . data [ this . responseKey ]
92
107
if ( this . responseKey === 'action_attempt' ) {
93
108
const waitForActionAttempt =
0 commit comments