Class: PatreonMockData
Defined in: schemas/v2/mock/data.ts:50
Constructors
Constructor
new PatreonMockData(
options?
):PatreonMockData
Defined in: schemas/v2/mock/data.ts:80
Parameters
options?
Returns
PatreonMockData
Properties
options
options:
PatreonMockDataOptions
Defined in: schemas/v2/mock/data.ts:51
random
random:
RandomDataResources
Defined in: schemas/v2/mock/data.ts:52
Methods
createAPIUrl()
createAPIUrl(
type
,id
):string
Defined in: schemas/v2/mock/data.ts:239
Creates the API url for a resource
Parameters
type
The type of the resource. The documentation currently allows requests (see documentation for the allowed methods) for:
- campaign
- member
- post
- webhook
Type
| keyof ItemMap
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:273
Create an error-like object. An error response is of type { errors: PatreonErrorData[] }
Parameters
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:254
Creates some headers that are generally returned by the Patreon API
Parameters
data?
The header values
Returns
Record
<string
, string
>
The following headers:
x-patreon-uuid
x-patreon-sha
Retry-After
(if a ratelimit is given)Content-Type
cf-ray
cf-cache-status
createId()
createId(
type
,options?
):string
Defined in: schemas/v2/mock/data.ts:211
Creates a random ID (UUID for a member) for a resource
Parameters
type
The type of the resource
Type
| keyof ItemMap
options?
For certain resources, additional information is required to create an ID
pledgeType?
"pledge_start"
| "pledge_upgrade"
| "pledge_downgrade"
| "pledge_delete"
| "subscription"
For 'pledge-event'
resource: the type of the event. Defaults to 'subscription'
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:286
Type Parameters
T
T
extends keyof ItemMap
Parameters
type
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
):object
&Relationship
<T
,I
>
Defined in: schemas/v2/mock/data.ts:343
Type Parameters
T
T
extends Type
I
I
extends never
A
A
extends RelationshipMap
<T
, I
>
Parameters
type
T
relatedItems
RelationshipItem
<T
, RelationshipFields
<T
>, RelationshipMap
<T
, RelationshipFields
<T
>>>[]
query
attributes
A
includes
I
[]
Returns
object
& Relationship
<T
, I
>
getAttributeItem()
getAttributeItem<
T
,A
>(type
,id
,data?
,attributes?
):object
Defined in: schemas/v2/mock/data.ts:302
Type Parameters
T
T
extends keyof ItemMap
A
A
extends string
| number
| symbol
= keyof ItemMap
[T
]
Parameters
type
T
id
string
data?
Partial
<ItemMap
[T
]>
attributes?
A
[]
Returns
object
attributes
attributes:
Pick
<ItemMap
[T
],A
>
id
id:
string
type
type:
T
getAttributeItems()
getAttributeItems<
T
,A
>(type
,items?
,attributes?
,options?
):object
[]
Defined in: schemas/v2/mock/data.ts:321
Type Parameters
T
T
extends keyof ItemMap
A
A
extends string
| number
| symbol
Parameters
type
T
items?
object
[]
attributes?
A
[]
options?
length?
number
| { max
: number
; min
: number
; }
Returns
object
[]
getListResponsePayload()
getListResponsePayload<
T
,I
,A
>(type
,query
,data
):ListRequestPayload
<T
,I
,A
>
Defined in: schemas/v2/mock/data.ts:146
Get a response body for multiple resources to mock a response payload
Type Parameters
T
T
extends Type
I
I
extends never
A
A
extends RelationshipMap
<T
, I
>
Parameters
type
T
The type of the resource that is returned
query
The query to select the relationships and attributes returned
attributes
A
The attribute map to filter the returned attributes
includes
I
[]
The requested relationships on the item
data
The resource item, id and related items
items
object
[]
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:102
Get a response body for a single resource to mock a response payload
Type Parameters
T
T
extends Type
I
I
extends never
A
A
extends RelationshipMap
<T
, I
>
Parameters
type
T
The type of the resource that is returned
query
The query to select the relationships and attributes returned
attributes
A
The attribute map to filter the returned attributes
includes
I
[]
The requested relationships on the item
data
The resource item, id and related items
id
string
The id of the resource
item
Partial
<ItemMap
[T
]>
The attributes of the resource. If partial, the other attributes will be generated randomly.
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