Manual Reference Source Test
public class | source

Content

Expression Extends:

class Content extends aggregate(ContentModel, Helper, Commentable)

Helper class representing Content.

Static Member Summary

Static Public Members
public static get

Constructor Summary

Public Constructor
public

constructor(contentType: String | ContentType, json: Object, options: Object, meta: Object)

Creates an instance of Content.

Member Summary

Public Members
public

[key]: Any

public set
public get
public set
public get
public get

Get objectType

public set

options(options: Object): Object

Set the options used for API calls

  • owner (unique identifier / id)
  • ownerType (content type)
  • version
public get
public get
public set
public get
public set
public get

Get resource

public set
public get

Get status

Private Members
private set

_data(data: Object)

Set _data to set information to the current object.

private get

_data: *

Get _data to quickly get the raw data without options.

private
private
private
private
private
private

Method Summary

Public Methods
public

Deletes a content

public

get(key: String): String | Number

Get the value of an attribute of the current content

public

getStatus(): Promise<any>

Get Status and set it to this._status

public

Saves the current instance of Content

public

set(key: String, value: String | Number)

Set the attribute of the current content

public

async syncRelationships(json: *): Promise

Synchronize the relationships from storage to the current object

Static Public Members

public static get type: String source

Public Constructors

public constructor(contentType: String | ContentType, json: Object, options: Object, meta: Object) source

Creates an instance of Content.

Params:

NameTypeAttributeDescription
contentType String | ContentType

Content Type string

json Object

The data of the object for ContentModel

json.id Number
  • nullable: true

The ID of the content

json.title String
  • nullable: true

Title of the content

json.description String
  • nullable: true

A description related to the content

json.created_at String
  • nullable: true

The time at which the content was created

json.updated_at String
  • nullable: true

The time at which the content was updated

json.position Number
  • nullable: true

The platform position content is put

json.tags Array
  • nullable: true

The tags to describe the content

json.brand Object
  • nullable: true

The brand to describe the content

options Object
  • optional
  • default: {}
  • nullable: true

Options available to support the API.

options.version String
  • nullable: true

Version defaults to 'v2'

options.owner_type String
  • nullable: true

Owner Type defaults to 'mobile_user'

meta Object
  • optional
  • default: {}
  • nullable: true

Meta data supporting this item

Public Members

public [key]: Any source

public set contentType: ContentType source

public get contentType: ContentType source

public set mobileUser: User source

public get mobileUser: User source

public get objectType: String: string source

Get objectType

Return:

String

Object Type

public set options(options: Object): Object source

Set the options used for API calls

  • owner (unique identifier / id)
  • ownerType (content type)
  • version

public get options: Object source

public get owner: User source

public set owner: User source

public get ownerType: String source

public set ownerType: String source

public get resource: String: * source

Get resource

Return:

String

resource - this.content_type

public set status: String source

public get status: String: * source

Get status

Return:

String

Status

Private Members

private set _data(data: Object) source

Set _data to set information to the current object.

private get _data: * source

Get _data to quickly get the raw data without options.

private _meta: Object source

private _mobile_user: User source

private _options: Object source

private _owner: User source

private _relationships: {} source

private _status: String source

Public Methods

public delete(): Promise source

Deletes a content

Return:

Promise

Returns a promise via ajax call.

Example:

import { Content, Client } from 'clinical6';

// Removes content from server and local storage
const content = new Content({...});
content.delete();

// No longer in storage
Client.instance.storageUtility.has('contents', { id: 1 });

Test:

public get(key: String): String | Number source

Get the value of an attribute of the current content

Params:

NameTypeAttributeDescription
key String

A String indicating the attribute key

Return:

String | Number

The value of the attribute

Example:

myContent.get('title');

public getStatus(): Promise<any> source

Get Status and set it to this._status

Return:

Promise<any>

A Promise containing the status (String)

Example:

myContent.getStatus((status) => {
  console.log('status', status);
  console.log('status', myContent.status);
});

public save(): Object source

Saves the current instance of Content

Return:

Object

Returns a promise via ajax call.

Example:

let car = new client.Content();
car.set('content_type', 'car');
car.set('title', 'My Car');
car.set('make', 'Toyota')
car.set('model', 'Corolla')
car.set('year', 2006)
// inserts
car.save().then(() => {
  // car now has id
  car.set('year', 2007);
  return car.save(); // car had id so this last save is an update
});

Test:

public set(key: String, value: String | Number) source

Set the attribute of the current content

Params:

NameTypeAttributeDescription
key String

A String indicating the attribute key

value String | Number

Needs to be a String or Number

Example:

myContent.set('title', 'The Tale of Two Cities');

public async syncRelationships(json: *): Promise source

Synchronize the relationships from storage to the current object

Params:

NameTypeAttributeDescription
json *

Return:

Promise