AwardedBadge
Mixin Extends:
Helper class representing an badge.
Example:
import { AwardedBadge, userService } from 'clinical6';
// Typically use userService.getAwardedBadges()
userService.getAwardedBadges().then(badges => console.log(badges));
const badge = new AwardedBadge({
data: {
id: '20',
type: 'awarded_badges',
attributes: {
created_at: '2017-08-10T17:54:18Z',
updated_at: '2017-08-10T17:54:18Z',
count: 0,
earned_on_date: null
},
relationships: {
awardee: {
data: {
type: 'mobile_users',
id: '510'
}
},
badge: {
data: {
type: 'badges',
id: '41'
}
}
}
},
included: [
{
id: '41',
type: 'badges',
attributes: {
created_at: '2017-08-09T16:23:56Z',
updated_at: '2017-08-09T16:23:56Z',
title: 'dummy_462',
description: 'Demo Content info...',
redemption_points: 250,
image: {
image: {
url: '/uploads/test/reward/image/17/1.png',
small: {
url: '/uploads/test/reward/image/17/small_1.png'
},
small_hd: {
url: '/uploads/test/reward/image/17/small_hd_1.png'
},
fullscreen: {
url: '/uploads/test/reward/image/17/fullscreen_1.png'
},
main: {
url: '/uploads/test/reward/image/17/main_1.png'
},
fullscreen_hd: {
url: '/uploads/test/reward/image/17/fullscreen_hd_1.png'
},
main_hd: {
url: '/uploads/test/reward/image/17/main_hd_1.png'
}
}
},
position: 1,
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: 'xMnLvzU_uu4'
}
}
]
});
Constructor Summary
Public Constructor | ||
public |
constructor(json: Object) Constructor for helper class representing an AwardedBadge |
Member Summary
Public Members | ||
public get |
|
|
public set |
|
|
public get |
|
|
public set |
|
Method Summary
Public Methods | ||
public |
Saves an awarded badge (insert if id doesn't exist, update if it does) |
|
public |
save(): Promise<AwardedBadge> Saves an awarded badge (insert if id doesn't exist, update if it does) |
Inherited Summary
From class AwardedBadgeModel | ||
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
Public Constructors
public constructor(json: Object) source
Constructor for helper class representing an AwardedBadge
Override:
AwardedBadgeModel#constructorParams:
Name | Type | Attribute | Description |
json | Object | json api response from server |
Public Members
Public Methods
public delete(): Promise source
Saves an awarded badge (insert if id doesn't exist, update if it does)
Example:
import { AwardedBadge, Client } from 'clinical6';
// Removes awarded badge from server and local storage
const awardedBadge = new AwardedBadge({...});
awardedBadge.delete();
// No longer in storage
Client.instance.storageUtility.has('awarded_badges', 1);
public save(): Promise<AwardedBadge> source
Saves an awarded badge (insert if id doesn't exist, update if it does)
Example:
import { AwardedBadge, userService } from 'clinical6';
// Insert is different from other inserts. Uses mobile application key
const awardedBadge = new AwardedBadge({...});
awardedBadge.save();
// After you have the authtoken and then you've logged in
// Updates existing awarded badge (has existing id)
userService.getAwardedBadges().then(awardedBadges => awardedBadges[0].save());