Badge
Mixin Extends:
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"
}
}
});
Constructor Summary
Public Constructor | ||
public |
constructor(json: Object) 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 |
|
Public Constructors
public constructor(json: Object) source
Constructor for helper class representing an Badge
Override:
BadgeModel#constructorParams:
Name | Type | Attribute | Description |
json | Object | json api response from server |
Public Members
Private Members
Public Methods
public delete(): Promise source
Saves a badge (insert if id doesn't exist, update if it does)
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 });
public save(): Promise<Badge> source
Saves a badge (insert if id doesn't exist, update if it does)
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());