Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

Hierarchy

Index

Constructors

constructor

  • new ClientModel(collection: T["collection"], data?: Partial<T["properties"]>): ClientModel
  • Parameters

    • collection: T["collection"]
    • Default value data: Partial<T["properties"]> = {}

    Returns ClientModel

Properties

Optional Readonly annotated

busy

busy: boolean = false

collection

collection: T["collection"]

data

data: T["properties"]

delete

delete: (params?: T["delete"]["parameters"]) => CancellablePromise<T["delete"]["response"]> = flow(function* (this: ClientModel<any>, params) {if (!this.annotated.delete) {throw new Error("There is no delete method allowed");}this.busy = true;try {const {delete: { path, method },namespace} = this.annotated;const response: T["delete"]["response"] = yield this.annotated.request<T["delete"]["parameters"],T["delete"]["parameters"],T["delete"]["response"]>({location: {path,method: method || ERouteHttpVerb.DELETE,namespace},params: {...{ [this.annotated.keyId]: this.key },...(params || {})}});this.collection.entries.delete(this.key);this.afterDelete();return response;} catch (e) {console.log(e);throw e;} finally {this.busy = false;}})

Type declaration

    • (params?: T["delete"]["parameters"]): CancellablePromise<T["delete"]["response"]>
    • Parameters

      • Optional params: T["delete"]["parameters"]

      Returns CancellablePromise<T["delete"]["response"]>

patch

patch: (params?: T["patch"]["parameters"]) => CancellablePromise<void> = flow(function* (this: ClientModel<any>,params) {if (!this.annotated.patch) {throw new Error("There is no patch method allowed");}this.busy = true;try {const {patch: { path, method },namespace} = this.annotated;const response: T["patch"]["response"] = yield this.annotated.request<T["patch"]["request"],T["patch"]["parameters"],T["patch"]["response"]>({location: {path,method: method || ERouteHttpVerb.PATCH,namespace},request: this.transformDataForPatch(),params: {...{ [this.annotated.keyId]: this.key },...(params || {})}});this.fromResponse(response);this.afterPatch();} catch (e) {console.log(e);throw e;} finally {this.busy = false;}})

Type declaration

    • (params?: T["patch"]["parameters"]): CancellablePromise<void>
    • Parameters

      • Optional params: T["patch"]["parameters"]

      Returns CancellablePromise<void>

persist

persist: (params?: T["create"]["parameters"]) => CancellablePromise<void> = flow(function* (this: ClientModel<any>,params) {if (!this.annotated.create) {throw new Error("There is no persist method allowed");}this.busy = true;try {const {create: { path, method },namespace} = this.annotated;const response: T["create"]["response"] = yield this.annotated.request<T["create"]["request"],T["create"]["parameters"],T["create"]["response"]>({location: {path,method: method || ERouteHttpVerb.POST,namespace},request: this.transformDataForPersist(),params: params || {}});this.fromResponse(response);this.collection.entries.set(this.key, this);this.afterPersist();} catch (e) {console.log(e);throw e;} finally {this.busy = false;}})

Type declaration

    • (params?: T["create"]["parameters"]): CancellablePromise<void>
    • Parameters

      • Optional params: T["create"]["parameters"]

      Returns CancellablePromise<void>

Accessors

key

  • get key(): T["key"]
  • Returns T["key"]

Methods

afterDelete

  • afterDelete(): void
  • Returns void

afterPatch

  • afterPatch(): void
  • Returns void

afterPersist

  • afterPersist(): void
  • Returns void

fromResponse

  • fromResponse(response: T["properties"]): this
  • Parameters

    • response: T["properties"]

    Returns this

transformDataForPatch

  • transformDataForPatch(): any
  • Create your conditionals here and return only changed values.

    Returns any

transformDataForPersist

  • transformDataForPersist(): any
  • Transform the class-hold data to POSTable data. This can be useful if e. g. one property differs from the response property schema.

    Returns any

Static Optional annotate

  • Type parameters

    • T: { constructor: any }

    Parameters

    Returns (Anonymous function)

Generated using TypeDoc