Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ApiClient

Index

Constructors

constructor

  • new ApiClient(__namedParameters?: { adapter: AxiosAdapter; baseURL: string; dateAttrs: string[]; headers: {}; protectedAttrs: string[]; throttleThreshold: number; timeout: number; useCache: boolean; useThrottle: boolean; pagination: object }): ApiClient
  • Parameters

    • Default value __namedParameters: { adapter: AxiosAdapter; baseURL: string; dateAttrs: string[]; headers: {}; protectedAttrs: string[]; throttleThreshold: number; timeout: number; useCache: boolean; useThrottle: boolean; pagination: object } = {}
      • adapter: AxiosAdapter
      • baseURL: string
      • dateAttrs: string[]
      • headers: {}
      • protectedAttrs: string[]
      • throttleThreshold: number
      • timeout: number
      • useCache: boolean
      • useThrottle: boolean
      • pagination: object
        • size: number
        • totals: true
        • type: string

    Returns ApiClient

Properties

axios

axios: AxiosInstance

dateAttrs

dateAttrs: string[]

fetch

fetch: get = this.get

headers

headers: Object

jsonPatchHeaders

jsonPatchHeaders: Object

protectedAttrs

protectedAttrs: string[]

Methods

create

createRelationship

  • createRelationship(type: string, id: string, relationshipType: string, data: NormalizedResourceOrResources, headers?: undefined | object): Promise<AxiosResponse<any>>
  • Creates a relationship between a parent resource and the provided resource(s)

    Parameters

    • type: string

      Parent resource Type

    • id: string

      Parent resource ID

    • relationshipType: string

      Relationship resource Type

    • data: NormalizedResourceOrResources

      Related resource or collection of related resources

    • Optional headers: undefined | object

    Returns Promise<AxiosResponse<any>>

delete

  • delete(url: string, data?: undefined | object, headers?: undefined | object): Promise<any>
  • Delete a resource

    Can accept a resource object or collection of resources to delete

    Parameters

    • url: string

      Resource endpoint URL

    • Optional data: undefined | object
    • Optional headers: undefined | object

    Returns Promise<any>

get

getHeaders

  • getHeaders(headers?: undefined | object, jsonPatch?: undefined | false | true): Object & object
  • Merges provided header properties with the class instance properties

    Parameters

    • Optional headers: undefined | object
    • Optional jsonPatch: undefined | false | true

    Returns Object & object

getOptions

  • getOptions(__namedParameters?: { dateAttrs: string[]; idRequired: boolean; protectedAttrs: string[] }): { dateAttrs: never[]; idRequired: boolean; protectedAttrs: never[] }
  • Merges provided options with the class instance options

    property

    {string[]} [dateAttrs] Date attributes to be serialized

    property

    {bool} [idRequired] Is the resource ID required?

    property

    {string[]} [protectedAttrs] Attributes to be stripped from payload

    Parameters

    • Default value __namedParameters: { dateAttrs: string[]; idRequired: boolean; protectedAttrs: string[] } = {} as SerializeOptions
      • dateAttrs: string[]
      • idRequired: boolean
      • protectedAttrs: string[]

    Returns { dateAttrs: never[]; idRequired: boolean; protectedAttrs: never[] }

    • dateAttrs: never[]
    • idRequired: boolean
    • protectedAttrs: never[]

mutate

  • mutate(url: string, op: OperationType, path: string, data: NormalizedResource[], headers?: undefined | object): Promise<(null | { id: string; type: string } | { errors: Error[] })[]>
  • JSON Patch Extension mutation

    Parameters

    • url: string

      Resource endpoint URL

    • op: OperationType

      Mutation operation type

    • path: string

      Resource path

    • data: NormalizedResource[]

      Normalized resource data objects

    • Optional headers: undefined | object

    Returns Promise<(null | { id: string; type: string } | { errors: Error[] })[]>

patch

  • patch(url: string, data: object, headers?: undefined | object, jsonPatch?: undefined | false | true): Promise<AxiosResponse<any>>
  • Update a resource

    Does not serialize the request data or deserialize the response

    Parameters

    • url: string

      Resource endpoint URL

    • data: object

      Resource data object

    • Optional headers: undefined | object
    • Optional jsonPatch: undefined | false | true

    Returns Promise<AxiosResponse<any>>

post

  • post(url: string, data: object, headers?: undefined | object): Promise<AxiosResponse<any>>
  • Create a new resource

    Does not serialize the request data or deserialize the response

    Parameters

    • url: string

      Resource endpoint URL

    • data: object

      Resource data object

    • Optional headers: undefined | object

    Returns Promise<AxiosResponse<any>>

remove

  • remove(type: string, id: string | number, headers?: undefined | object): Promise<any>
  • Delete a resource by ID

    Parameters

    • type: string

      Resource type

    • id: string | number

      Resource ID

    • Optional headers: undefined | object

    Returns Promise<any>

removeRelationship

  • removeRelationship(type: string, id: string, relationshipType: string, data: NormalizedResourceOrResources, headers?: undefined | object): Promise<any>
  • Removes a relationship between a parent resource and the provided resource(s)

    Parameters

    • type: string

      Parent resource Type

    • id: string

      Parent resource ID

    • relationshipType: string

      Relationship resource Type

    • data: NormalizedResourceOrResources

      Related resource or collection of related resources

    • Optional headers: undefined | object

    Returns Promise<any>

serialize

update

Legend

  • Constructor
  • Property
  • Method
  • Property

Generated using TypeDoc