Manual Reference Source Test
public class | source

Event

Mixin Extends:

EventModel, Helper

Helper class representing a event.

Example:

import { Event, eventService } from 'clinical6';

// Typically use EventService.get()
eventService.get().then(events => console.log(events));

const event = new Event({
  "data": {
    "id": "1",
    "type": "events",
    "attributes": {
      "udid": "this-is-a-udid-string",
      "technology": "ios",
      "access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
      "push_id": null,
      "created_at": "2017-05-19T17:21:26.311Z",
      "updated_at": "2017-05-19T17:21:26.311Z",
      "app_version": null
    }
  }
});

Test:

Static Member Summary

Static Public Members
public static get

Constructor Summary

Public Constructor
public

Constructor for helper class representing an Event

Member Summary

Public Members
public get
public set
public get
public set

Method Summary

Public Methods
public

Saves a event (insert if id doesn't exist, update if it does)

public

mark(ruleId: String, eventAction: String): Promise

Saves the current instance of Event

public

Saves a event (insert if id doesn't exist, update if it does)

public

saveEventAction(resource: String, action: String, context: String): Promise<Event>

Saves/Tracks reported actions from an event - if a mobile user token is available

Inherited Summary

From class EventModel
public
public
public

extras: Any

public
public
public

Static Public Members

public static get type: String source

Public Constructors

public constructor(json: Object) source

Constructor for helper class representing an Event

Override:

EventModel#constructor

Params:

NameTypeAttributeDescription
json Object

json api response from server

Public Members

public get mobileUser: User source

public set mobileUser: User source

public get rule: Rule source

public set rule: Rule source

Public Methods

public delete(): Promise source

Saves a event (insert if id doesn't exist, update if it does)

Return:

Promise

Returns a promise via ajax call.

Example:

import { Event, Client } from 'clinical6';

// Removes event from server and local storage
const event = new Event({
  "id": 1,
  "type": "events",
  "attributes": {
    "udid": "this-is-a-udid-string",
    "technology": "ios",
    "access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
    "push_id": null,
    "created_at": "2017-05-19T17:21:26.311Z",
    "updated_at": "2017-05-19T17:21:26.311Z",
    "app_version": null
  }
});
event.delete();

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

Test:

public mark(ruleId: String, eventAction: String): Promise source

Saves the current instance of Event

Params:

NameTypeAttributeDescription
ruleId String
  • nullable: false

Permanent link of hte rule of the event to update

eventAction String
  • nullable: false

The optional event action indicates the action to mark the event

Return:

Promise

Returns a promise via ajax call.

public save(): Promise<Event> source

Saves a event (insert if id doesn't exist, update if it does)

Return:

Promise<Event>

Returns a promise via ajax call.

Example:

import { Event, eventService } from 'clinical6';

// Insert is different from other inserts.  Uses mobile application key
const event = new Event({
  "type": "events",
  "attributes": {
    "udid": "this-is-a-udid-string",
    "technology": "ios",
    "access_token": "cd68fa04e458d6d1a9d29faec6a329d3",
    "push_id": null,
    "created_at": "2017-05-19T17:21:26.311Z",
    "updated_at": "2017-05-19T17:21:26.311Z",
    "app_version": null
  }
});
event.save();

// After you have the authtoken and then you've logged in

// Updates existing event (has existing id)
eventService.get().then(events => events[0].save());

Test:

public saveEventAction(resource: String, action: String, context: String): Promise<Event> source

Saves/Tracks reported actions from an event - if a mobile user token is available

Params:

NameTypeAttributeDescription
resource String

resource attribute

action String

action attribute

context String

result of if this was approved or not

Return:

Promise<Event>

Returns a promise via ajax call.

Test: