Class: PatreonMock
Defined in: schemas/v2/mock/mock.ts:86
A class with utitilies to mock the Patreon API
See
https://patreon-api.pages.dev/guide/features/sandbox
Constructors
Constructor
new PatreonMock(
options
):PatreonMock
Defined in: schemas/v2/mock/mock.ts:114
Parameters
options
PatreonMockOptions
= {}
Returns
PatreonMock
Properties
cache
cache:
PatreonMockCache
Defined in: schemas/v2/mock/mock.ts:110
data
data:
PatreonMockData
Defined in: schemas/v2/mock/mock.ts:111
options
options:
PatreonMockOptions
={}
Defined in: schemas/v2/mock/mock.ts:115
webhooks
webhooks:
PatreonMockWebhooks
Defined in: schemas/v2/mock/mock.ts:112
origin
static
origin:string
Defined in: schemas/v2/mock/mock.ts:91
The origin url for the Patreon API
Constant
path
static
path:string
Defined in: schemas/v2/mock/mock.ts:97
The API path that every route starts with
Constant
'/api/oauth2/v2'
Methods
getMockAgentReplyCallback()
getMockAgentReplyCallback(
options?
): (options
) =>object
Defined in: schemas/v2/mock/mock.ts:296
Note: Uses the undici-types
package for typing. If you don't have undici
or undici-types
installed, ts will be not be able to import the types.
Creates a callback for an intercepted request on a mock agent.
Parameters
options?
Options for the mocked response
cache?
boolean
headers?
Record
<string
, string
>
The headers to include in the response
random?
boolean
statusCode?
number
The status code the response should have, defaults to 200
Returns
the intercept callback
(
options
):object
Parameters
options
MockResponseCallbackOptions
Returns
object
data
data:
string
responseOptions
responseOptions:
object
responseOptions.headers
headers:
Record
<string
,string
>
statusCode
statusCode:
number
getMockHandlers()
getMockHandlers<
R
>(options?
):Record
<"getCampaign"
|"getCampaigns"
|"getIdentity"
|"getCampaignMembers"
|"getMember"
|"getCampaignPosts"
|"getPost"
|"editWebhook"
|"deleteWebhook"
|"getWebhooks"
|"createWebhook"
,Handler
>
Defined in: schemas/v2/mock/mock.ts:350
Get handlers for mocking a route
Type Parameters
R
R
= { body
: string
; headers
: Record
<string
, string
>; status
: number
; }
Parameters
options?
Options for generating the routes
cache?
boolean
includeOrigin?
boolean
Whether to include the API origin in the url of the handler, defaults to true
pathParam?
string
The path param template value, defaults to *
random?
boolean
transformResponse?
(response
) => R
Method to transform the default response for a handler
Returns
Record
<"getCampaign"
| "getCampaigns"
| "getIdentity"
| "getCampaignMembers"
| "getMember"
| "getCampaignPosts"
| "getPost"
| "editWebhook"
| "deleteWebhook"
| "getWebhooks"
| "createWebhook"
, Handler
>
Handlers for each route that returns a successful response.
See
https://patreon-api.pages.dev/guide/features/sandbox#msw
pathFilter()
static
pathFilter(path
):boolean
Defined in: schemas/v2/mock/mock.ts:104
A filter to check if a random path is an API route
Parameters
path
string
The path to check. Can include query parameters
Returns
boolean
if the path is valid route for the V2 Patreon API