Manual Reference Source Test
public class | source

Badge

Mixin Extends:

BadgeModel, Helper

Helper class representing an badge.

Example:

import { Badge, clinical6 } from 'clinical6';

// Typically use clinical6.get()
clinical6.get(Badge).then(badges => console.log(badges));

const badge = new Badge({
 "data": {
   "id": "15",
   "type": "badges",
   "attributes": {
     "created_at": "2017-08-07T22:26:30Z",
     "updated_at": "2017-08-07T22:26:30Z",
     "title": "dummy_892",
     "description": "Demo Content info...",
     "redemption_points": 250,
     "image": {
       "image": {
         "url": "/uploads/test/reward/image/15/1.png",
         "small": {
           "url": "/uploads/test/reward/image/15/small_1.png"
         },
         "small_hd": {
           "url": "/uploads/test/reward/image/15/small_hd_1.png"
         },
         "fullscreen": {
           "url": "/uploads/test/reward/image/15/fullscreen_1.png"
         },
         "main": {
           "url": "/uploads/test/reward/image/15/main_1.png"
         },
         "fullscreen_hd": {
           "url": "/uploads/test/reward/image/15/fullscreen_hd_1.png"
         },
         "main_hd": {
           "url": "/uploads/test/reward/image/15/main_hd_1.png"
         }
       }
     },
     "position": 4,
     "enabled": true,
     "featured": null,
     "based_on": null,
     "threshold": null,
     "time_unit": null,
     "start_point": null,
     "start_at": null,
     "disabled_image": {
       "disabled_image": {
         "url": "/default/default.png",
         "small": {
           "url": "/default/small_default.png"
         },
         "small_hd": {
           "url": "/default/small_hd_default.png"
         },
         "fullscreen": {
           "url": "/default/fullscreen_default.png"
         },
         "main": {
           "url": "/default/main_default.png"
         },
         "fullscreen_hd": {
           "url": "/default/fullscreen_hd_default.png"
         },
         "main_hd": {
           "url": "/default/main_hd_default.png"
         }
       }
     },
     "cache_token": "BnSwoIJMt64"
   }
 }
});

Test:

Static Member Summary

Static Public Members
public static get

Constructor Summary

Public Constructor
public

Constructor for helper class representing an Badge

Member Summary

Public Members
public get
public set
public get
public set
public get
public set
public

disabledImage: C6Image

public

image: C6Image

public get
public set
public get
public set
public get
public set
public get
public set
public get
public set
public get
public set
Private Members
private
private
private
private
private
private
private
private
private
private

Method Summary

Public Methods
public

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

public

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

Inherited Summary

From class BadgeModel
public
public
public
public
public
public
public

featured: Any

public
public
public
public
public
public
public
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 Badge

Override:

BadgeModel#constructor

Params:

NameTypeAttributeDescription
json Object

json api response from server

Public Members

public get accessible: Object source

public set accessible: Object source

public get brand: Object source

public set brand: Object source

public get callback: Object source

public set callback: Object source

public disabledImage: C6Image source

Override:

BadgeModel#disabledImage

public image: C6Image source

Override:

BadgeModel#image

public get pointsRecords: Object source

public set pointsRecords: Object source

public get rewardEarnings: Object source

public set rewardEarnings: Object source

public get schedules: Object source

public set schedules: Object source

public get segmentations: Object source

public set segmentations: Object source

public get tag: Object source

public set tag: Object source

public get taggings: Object source

public set taggings: Object source

Private Members

private _accessible: Object source

private _brand: Object source

private _callback: Object source

private _points_records: Object source

private _relationships: Object source

private _reward_earnings: Object source

private _schedules: Object source

private _segmentations: Object source

private _tag: Object source

private _taggings: Object source

Public Methods

public delete(): Promise source

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

Return:

Promise

Returns a promise via ajax call.

Example:

import { Badge, Client } from 'clinical6';

// Removes badge from server and local storage
const badge = new Badge({
  "id": 1,
  "type": "badges",
  "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
  }
});
badge.delete();

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

Test:

public save(): Promise<Badge> source

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

Return:

Promise<Badge>

Returns a promise via ajax call.

Example:

import { Badge, clinical6 } from 'clinical6';

// Insert is different from other inserts.  Uses mobile application key
const badge = new Badge({
  "title": "You are a winner"
});
badge.save();

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

// Updates existing badge (has existing id)
clinical6.get(Badge).then(badges => badges[0].save());

Test: