Class: PatreonMock
Defined in: schemas/v2/mock/mock.ts:169
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:174
Parameters
| Parameter | Type |
|---|---|
options | PatreonMockOptions |
Returns
PatreonMock
Properties
| Property | Modifier | Type | Default value | Description |
|---|---|---|---|---|
cache | public | CacheStore<false> | undefined | - |
data | public | PatreonMockData | undefined | - |
options | public | PatreonMockOptions | {} | - |
webhooks | public | PatreonMockWebhooks | undefined | - |
origin | static | string | undefined | The origin url for the Patreon API Constant 'https://patreon.com' |
path | static | string | undefined | The API path that every route starts with Constant '/api/oauth2/v2' |
Methods
getMockAgentReplyCallback()
getMockAgentReplyCallback(
options?): (callbackOptions) => {data:string;responseOptions: {headers:Record<string,string>; };statusCode:number; }
Defined in: schemas/v2/mock/mock.ts:480
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
| Parameter | Type | Description |
|---|---|---|
options? | PatreonMockHandlerOptions | Options for the mocked response |
Returns
the intercept callback
(
callbackOptions): {data:string;responseOptions: {headers:Record<string,string>; };statusCode:number; }
Parameters
| Parameter | Type |
|---|---|
callbackOptions | PatreonMockHandlerCallbackOptions |
Returns
{ data: string; responseOptions: { headers: Record<string, string>; }; statusCode: number; }
data
data:
string
responseOptions
responseOptions: {
headers:Record<string,string>; }
responseOptions.headers
headers:
Record<string,string>
statusCode
statusCode:
number=status
getMockHandlers()
getMockHandlers<
R>(options?):Record<"getCampaign"|"getCampaigns"|"getIdentity"|"getCampaignMembers"|"getMember"|"getCampaignPosts"|"getPost"|"editWebhook"|"deleteWebhook"|"getWebhooks"|"createWebhook",PatreonMockHandler<R>>
Defined in: schemas/v2/mock/mock.ts:506
Get handlers for mocking a route
Type Parameters
| Type Parameter | Default type |
|---|---|
R | PatreonMockHandlerDefaultResponse |
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | PatreonMockHandlerOptions & { includeOrigin?: boolean; pathParam?: string; transformResponse?: (response) => R; } | Options for generating the routes |
Returns
Record<"getCampaign" | "getCampaigns" | "getIdentity" | "getCampaignMembers" | "getMember" | "getCampaignPosts" | "getPost" | "editWebhook" | "deleteWebhook" | "getWebhooks" | "createWebhook", PatreonMockHandler<R>>
Handlers for each route that returns a successful response.
See
https://patreon-api.pages.dev/guide/features/sandbox#msw
pathFilter()
staticpathFilter(path):boolean
Defined in: schemas/v2/mock/mock.ts:203
A filter to check if a random path is an API route
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | The path to check. Can include query parameters |
Returns
boolean
if the path is valid route for the V2 Patreon API
route()
staticroute(path,options?):string
Defined in: schemas/v2/mock/mock.ts:215
Create a mocked route
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | The request path to use: /api/oauth2/v2 |
options? | { includeOrigin?: boolean; query?: string; } | Path options |
options.includeOrigin? | boolean | Include the origin url (default false) |
options.query? | string | The url query to append |
Returns
string
the mocked API route