Class: PatreonMockData
Defined in: schemas/v2/mock/data.ts:74
Constructors
Constructor
new PatreonMockData(
options?):PatreonMockData
Defined in: schemas/v2/mock/data.ts:78
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:326
Creates the API url for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "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:351
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:341
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:307
Creates a random ID (UUID for a member) for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "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:201
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
Parameters
| Parameter | Type |
|---|---|
type | T |
options? | { items?: RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[]; } |
options.items? | RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[] |
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:254
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" |
I extends never |
A extends RelationshipMap<T, I> |
Parameters
| Parameter | Type |
|---|---|
type | T |
relatedItems | RelationshipItem<T, RelationshipFields<T>, RelationshipMap<T, RelationshipFields<T>>>[] |
query | { attributes: A; includes: I[]; } |
query.attributes | A |
query.includes | I[] |
Returns
{ included: RelationshipItem<T, I, A>[]; } & Relationship<T, I>
getAttributeItem()
getAttributeItem<
T,A>(type,id,data?,attributes?): {attributes:Pick<ItemMap[T],A>;id:string;type:T; }
Defined in: schemas/v2/mock/data.ts:217
Type Parameters
| Type Parameter | Default type |
|---|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "media" | "member" | "post" | "pledge-event" | "tier" | "user" | "webhook" | - |
A extends string | number | symbol | keyof ItemMap[T] |
Parameters
| Parameter | Type |
|---|---|
type | T |
id | string |
data? | Partial<ItemMap[T]> |
attributes? | A[] |
Returns
{ attributes: Pick<ItemMap[T], A>; id: string; type: T; }
attributes
attributes:
Pick<ItemMap[T],A>
id
id:
string
type
type:
T
getAttributeItems()
getAttributeItems<
T,A>(type,items?,attributes?,options?): {attributes:Pick<ItemMap[T],A>;id:string;type:T; }[]
Defined in: schemas/v2/mock/data.ts:236
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "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
{ attributes: Pick<ItemMap[T], A>; id: string; type: T; }[]
getListResponsePayload()
getListResponsePayload<
T,I,A>(type,query,data):ListRequestPayload<T,I,A>
Defined in: schemas/v2/mock/data.ts:143
Get a response body for multiple resources to mock a response payload
Type Parameters
| Type Parameter |
|---|
T extends "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "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 | { attributes: A; includes: I[]; } | The query to select the relationships and attributes returned |
query.attributes | A | The attribute map to filter the returned attributes |
query.includes | I[] | The requested relationships on the item |
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:99
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" | "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 | { attributes: A; includes: I[]; } | The query to select the relationships and attributes returned |
query.attributes | A | The attribute map to filter the returned attributes |
query.includes | I[] | The requested relationships on the item |
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
createAPIUrl()
staticcreateAPIUrl(type,id):string
Defined in: schemas/v2/mock/data.ts:367
Creates the API url for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "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:400
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:424
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:377
Creates a random ID (UUID for a member) for a resource
Parameters
| Parameter | Type | Description |
|---|---|---|
type | "address" | "benefit" | "campaign" | "client" | "deliverable" | "goal" | "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