Class: PatreonMock
Defined in: schemas/v2/mock/mock.ts:136
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:162
Parameters
options
PatreonMockOptions = {}
Returns
PatreonMock
Properties
cache
cache:
CacheStore<false>
Defined in: schemas/v2/mock/mock.ts:158
data
data:
PatreonMockData
Defined in: schemas/v2/mock/mock.ts:159
options
options:
PatreonMockOptions={}
Defined in: schemas/v2/mock/mock.ts:163
webhooks
webhooks:
PatreonMockWebhooks
Defined in: schemas/v2/mock/mock.ts:160
origin
staticorigin:string
Defined in: schemas/v2/mock/mock.ts:141
The origin url for the Patreon API
Constant
path
staticpath:string
Defined in: schemas/v2/mock/mock.ts:147
The API path that every route starts with
Constant
'/api/oauth2/v2'
Methods
getMockAgentReplyCallback()
getMockAgentReplyCallback(
options?): (callbackOptions) =>object
Defined in: schemas/v2/mock/mock.ts:405
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
Whether to use a cache to search for the resource. When disabled, only generated items will be returned.
headers?
Record<string, string>
The headers to include in the response
random?
boolean
Whether to allow random generated responses if the resource is not found in the cache.
statusCode?
number
The status code the response should have, defaults to 200
Returns
the intercept callback
(
callbackOptions):object
Parameters
callbackOptions
MockResponseCallbackOptions
Returns
object
data
data:
string=body
responseOptions
responseOptions:
object
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",Handler>
Defined in: schemas/v2/mock/mock.ts:441
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
Whether to use a cache to search for the resource. When disabled, only generated items will be returned.
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
Whether to allow random generated responses if the resource is not found in the cache.
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()
staticpathFilter(path):boolean
Defined in: schemas/v2/mock/mock.ts:154
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