Class: PatreonMockData
Defined in: schemas/v2/mock/data.ts:173
Constructors
Constructor
new PatreonMockData(
options?):PatreonMockData
Defined in: schemas/v2/mock/data.ts:177
Parameters
| Parameter | Type |
|---|---|
options? | PatreonMockDataOptions |
Returns
PatreonMockData
Properties
| Property | Modifier | Type |
|---|---|---|
options | public | PatreonMockDataOptions |
random | public | PatreonMockDataRandomResources |
Methods
createAPIUrl()
createAPIUrl(
type,id):string
Defined in: schemas/v2/mock/data.ts:490
Creates the API url for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | Type | The type of the resource. The documentation currently allows requests (see documentation for the allowed methods) for: - campaign - member - post - webhook |
id | string | The id of the resource |
Returns
string
https://patreon.com/api/oauth2/v2/${type}s/${id}
See
https://docs.patreon.com/#apiv2-resource-endpoints
createError()
createError(
status,data?):PatreonErrorData
Defined in: schemas/v2/mock/data.ts:515
Create an error-like object. An error response is of type { errors: PatreonErrorData[] }
Parameters
| Parameter | Type | Description |
|---|---|---|
status | number | The response status |
data? | Partial<Omit<PatreonErrorData, "status">> | Optional data to better mock the error |
Returns
the mocked error
createHeaders()
createHeaders(
data?):Record<string,string>
Defined in: schemas/v2/mock/data.ts:505
Creates some headers that are generally returned by the Patreon API
Parameters
| Parameter | Type | Description |
|---|---|---|
data? | PatreonMockHeaderData | The header values |
Returns
Record<string, string>
The following headers:
x-patreon-uuidx-patreon-shaRetry-After(if a ratelimit is given)Content-Typecf-raycf-cache-status
createId()
createId(
type,options?):string
Defined in: schemas/v2/mock/data.ts:471
Creates a random ID (UUID for a member) for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | Type | The type of the resource |
options? | PatreonMockIdOptions | For certain resources, additional information can be used to create an ID |
Returns
string
a random string
createRelatedItems()
createRelatedItems<
T>(type,options?):RelationshipItem<T,RelationshipFields<T>,RelationshipMap<T,RelationshipFields<T>>>[]
Defined in: schemas/v2/mock/data.ts:306
Create items that can be related to the resource type.
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The resource type to create items for |
options? | { items?: RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[]; length?: RandomInteger; } | Options for how to generate the related items |
options.items? | RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[] | Return these items for related types. |
options.length? | RandomInteger | If no items are found in options.items for the related type, return length amount of random items. Default: 1. |
Returns
RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[]
filterRelationships()
filterRelationships<
T,I,A>(type,relatedItems,query): {included:RelationshipItem<T,I,A>[]; } &Relationship<T,I>
Defined in: schemas/v2/mock/data.ts:413
Filters relatedItems to return a filtered data.relationships and included fields based on query.
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
I extends never |
A extends RelationshipMap<T, I> |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The resource type of the response |
relatedItems | RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[] | The related items to the main resource to filter |
query | PatreonMockDataQuery<T, I, A> | The query to use for filtering the items |
Returns
{ included: RelationshipItem<T, I, A>[]; } & Relationship<T, I>
getAttributeItem()
getAttributeItem<
T,A>(type,id?,data?,attributes?):AttributeItem<T,Pick<ItemMap[T],A>>
Defined in: schemas/v2/mock/data.ts:329
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | - |
A extends string | number | symbol | keyof ItemMap[T] |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The resource type of the item to return |
id? | string | The id of the item to return. If not given, creates a random id |
data? | Partial<ItemMap[T]> | The attributes of the item. If no attributes are defined, they are merged with random attributes |
attributes? | A[] | The attributes query to apply. This filters all the attributes in the item |
Returns
AttributeItem<T, Pick<ItemMap[T], A>>
getAttributeItems()
getAttributeItems<
T,A>(type,items?,attributes?,options?):AttributeItem<T,Pick<ItemMap[T],A>>[]
Defined in: schemas/v2/mock/data.ts:350
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
A extends string | number | symbol |
Parameters
| Parameter | Type |
|---|---|
type | T |
items? | { data?: Partial<ItemMap[T]>; id?: string; }[] |
attributes? | A[] |
options? | { length?: RandomInteger; } |
options.length? | RandomInteger |
Returns
AttributeItem<T, Pick<ItemMap[T], A>>[]
getListResponsePayload()
getListResponsePayload<
T,I,A>(type,query,data):ListRequestPayload<T,I,A>
Defined in: schemas/v2/mock/data.ts:243
Get a response body for multiple resources to mock a response payload
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | Type |
I extends never |
A extends RelationshipMap<T, I> |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The type of the resource that is returned |
query | PatreonMockDataQuery<T, I, A> | The query to select the relationships and attributes returned |
data | { items: { included: RelationshipItem<T, I, A>[]; item: { attributes: Partial<ItemMap[T]>; id: string; }; }[]; } | The resource item, id and related items |
data.items | { included: RelationshipItem<T, I, A>[]; item: { attributes: Partial<ItemMap[T]>; id: string; }; }[] | The attributes of the resources. If partial, the other attributes will be generated randomly. |
Returns
ListRequestPayload<T, I, A>
the JSON:API response payload
getSingleResponsePayload()
getSingleResponsePayload<
T,I,A>(type,query,data):GetRequestPayload<T,I,A>
Defined in: schemas/v2/mock/data.ts:199
Get a response body for a single resource to mock a response payload
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | Type |
I extends never |
A extends RelationshipMap<T, I> |
Parameters
| Parameter | Type | Description |
|---|---|---|
type | T | The type of the resource that is returned |
query | PatreonMockDataQuery<T, I, A> | The query to select the relationships and attributes returned |
data | { id: string; item: Partial<ItemMap[T]>; relatedItems: RelationshipItem<T, I, A>[]; } | The resource item, id and related items |
data.id | string | The id of the resource |
data.item | Partial<ItemMap[T]> | The attributes of the resource. If partial, the other attributes will be generated randomly. |
data.relatedItems | RelationshipItem<T, I, A>[] | If requesting relationships, all items that can be returned as a relationship |
Returns
GetRequestPayload<T, I, A>
the JSON:API response payload
scrub()
scrub<
T>(data,options?):T
Defined in: schemas/v2/mock/data.ts:525
Experimental
Scrub sensitive data from resources
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
data | T | The API response, request, url or an id to scrub |
options? | PatreonMockDataScrubOptions | Options for how and what to replace This is not a stable method and can change in the future. |
Returns
T
createAPIUrl()
staticcreateAPIUrl(type,id):string
Defined in: schemas/v2/mock/data.ts:541
Creates the API url for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | Type | The type of the resource. The documentation currently allows requests (see documentation for the allowed methods) for: - campaign - member - post - webhook |
id | string | The id of the resource |
Returns
string
https://patreon.com/api/oauth2/v2/${type}s/${id}
See
https://docs.patreon.com/#apiv2-resource-endpoints
createError()
staticcreateError(status,data?):PatreonErrorData
Defined in: schemas/v2/mock/data.ts:574
Create an error-like object. An error response is of type { errors: PatreonErrorData[] }
Parameters
| Parameter | Type | Description |
|---|---|---|
status | number | The response status |
data? | Partial<Omit<PatreonErrorData, "status">> | Optional data to better mock the error |
Returns
the mocked error
createHeaders()
staticcreateHeaders(data?):Record<string,string>
Defined in: schemas/v2/mock/data.ts:598
Creates some headers that are generally returned by the Patreon API
Parameters
| Parameter | Type | Description |
|---|---|---|
data? | PatreonMockHeaderData | The header values |
Returns
Record<string, string>
The following headers:
x-patreon-uuidx-patreon-shaRetry-After(if a ratelimit is given)Content-Typecf-raycf-cache-status
createId()
staticcreateId(type,options?):string
Defined in: schemas/v2/mock/data.ts:551
Creates a random ID (UUID for a member) for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "live-access-rule" | "live" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | Type | The type of the resource |
options? | PatreonMockIdOptions | For certain resources, additional information can be used to create an ID |
Returns
string
a random string
scrub()
staticscrub<T>(data,options?):T
Defined in: schemas/v2/mock/data.ts:617
Experimental
Scrub sensitive data from resources
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Description |
|---|---|---|
data | T | The API response, request, url or an id to scrub |
options? | PatreonMockDataScrubOptions | Options for how and what to replace This is not a stable method and can change in the future. |
Returns
T