Badgr Models¶
-
class
Assertion(client, eid: str = None)¶ Bases:
badgrclient.badgrmodels.Base-
ENDPOINT= '/v2/assertions'¶
-
create(recipient_email, badge_eid=None, issuer_eid=None, badge_name=None, narrative=None, evidence=None, expires=None, issued_on=None, notify=True) → badgrclient.badgrmodels.Assertion¶ Issue an Assetion to a single recipient
Parameters: - badge_eid (string) – entityId of the badgeclass to issue Not required if issuer_eid and badge_name is given
- badge_name (string) – Name of badge. issuer_eid is also required if using badge_name
- issuer_eid (string) – entityId of the the issuer badge belongs to
- recipient_email (string) – Email of the person to issue the badge
- narrative (string, optional) – Describe how to badge was earned
- evidence (list[dict { url (string), narrative (string) – optional): Evidence to attach to this assertion,
- expires (str, optional) – The expiry date of the assertion (ISO8601 formated datetime)
- issued_on (str, optional) – Override the issue date (ISO8601 formated datetime)
- notify (bool, optional) – Should the recipient be notified
Raises: BadgrClientError– Couldn’t get eid/ Eid not providedNote
You can indentify the badge either by providing eid or if unique_badge_names is enabled in your client then by providing issuer_eid and badge_name
-
revoke(reason) → dict¶ Revoke this assertion
Parameters: reason (string) – Reason of revocation Returns: API response dict Return type: dict
-
-
class
BadgeClass(client, eid: str = None, badge_name: str = None, issuer_eid: str = None)¶ Bases:
badgrclient.badgrmodels.Base-
ENDPOINT= '/v2/badgeclasses'¶
-
create(name, image, description, issuer_eid, criteria_text=None, criteria_url=None, alignments=None, tags=None, expires=None) → badgrclient.badgrmodels.BadgeClass¶ Create a new badgeclass
Parameters: - name (string) – Name of the badge
- image (string) – base64 encoded png/svg image
- description (String) – Short description of the badge
- issuer_eid (bool) – entityId of issuer to use to issue the badge
- criteria_text (string, optional) – The criteria of earning the badge
- criteria_url (string, optional) – Link of the criteria to earn the
- badge. – Defaults to None.
- (list[dict { (alignments) – “targetName”: “string”, “targetUrl”: “string”, “targetDescription”: “string”, “targetFramework”: “string”, “targetCode”: “string” }] , optional): Alignments. Defaults to None.
- tags (list [string], optional) – List of tags. Defaults to None.
- (dict { (expires) – “amount”: “string” “duration”: “string” }, optional): Expiry of the badge. Defaults to None.
Raises: BadgrClientError– At least one of criteria_text and criteria_url is required’sBadgrClientError– Badgeclass name is not unique (if unique_badge_names is enabled)
-
fetch_assertions(recipient=None, num=None, query=None) → List[badgrclient.badgrmodels.Assertion]¶ Get a list of Assertions for this badgeclass
Parameters: - recipient (string, optional) – Filter by recipient
- num (string, optional) – Request pagination of results
- query (dict, optional) – Query params
-
issue(recipient_email, narrative=None, evidence=None, expires=None, issued_on=None, notify=True) → badgrclient.badgrmodels.Assertion¶ Create a new assertion of this badge
Parameters: - recipient_email (string) – Email of the person to issue the badge
- narrative (string, optional) – Describe how to badge was earned
- evidence (list[dict { url (string), narrative (string) – optional): Evidence to attach to this assertion,
- expires (str, optional) – The expiry date of the assertion ISO8601 formated datetime
- issued_on (str, optional) – Override the issue date ISO8601 formated datetime
- notify (bool, optional) – Should the recipient be notified
-
-
class
Base(client, eid: str = None)¶ Bases:
abc.ABC-
__init__(client, eid: str = None)¶ Base model class
Parameters: - client (BadgrClient) – The BadgerClient instance to use for sending requests
- eid (str, optional) – the entityId of the entity
-
delete() → dict¶ Delete entity
Returns: Response dict Return type: dict
-
fetch()¶ Fetch entity from entityId
-
get_entity_ep() → str¶
-
set_data(data)¶ Populate the data
Parameters: data (dict) – The data to populate
-
update() → dict¶ Update entity
Returns: Response dict Return type: dict
-
-
class
Issuer(client, eid: str = None)¶ Bases:
badgrclient.badgrmodels.Base-
ENDPOINT= '/v2/issuers'¶
-
V1_ENDPOINT= '/v1/issuer/issuers/{slug}/staff'¶
-
create(name, description, email, url, image=None) → badgrclient.badgrmodels.Issuer¶ Create a new Issuer
Parameters: - name (string) – Name of issuer
- description (string) – Description of issuer
- email (string) – Verified email of the owner, email must be one
- your verified addresses. (of) –
- url (string) – Website URL
- image (string) – bade64 encoded string (data-uri)
-
create_badgeclass(name, image, description, criteria_text=None, criteria_url=None, alignment=None, tags=None, expires=None) → badgrclient.badgrmodels.BadgeClass¶ Create a badgeclass for this issuer
Parameters: - name (string) – Name of the badge
- image (string) – base64 encoded png/svg image (data-uri string)
- description (String) – Short description of the badge
- criteria_text (string, optional) – The criteria of earning the badge
- criteria_url (string, optional) – Link of the criteria to earn
- badge. Defaults to None. (the) –
- (dict { (expires) – “targetName”: “string”, “targetUrl”: “string”, “targetDescription”: “string”, “targetFramework”: “string”, “targetCode”: “string” } , optional): Alignments. Defaults to None.
- tags (list [string], optional) – List of tags. Defaults to None.
- (dict { – “amount”: “string” “duration”: “string” }, optional): Expiry of the badge. Defaults to None.
Raises: BadgrClientError– At least one of criteria_text and criteria_url is required’s
-
edit_staff(action: str, email: str, role: str) → dict¶ Edit the staff list of this issuer
Parameters: - action (str) – One of ‘add’, ‘modify’ or ‘remove’
- email (str) – Email of the staff
- role (str) – One of ‘owner’, ‘editor’, or ‘staff’
Raises: BadgrClientError– Action must be one of ‘add’, ‘modify’ or ‘remove’BadgrClientError– Action must be one of ‘owner’, ‘editor’, or ‘staff’
-
fetch_assertions(query=None) → List[badgrclient.badgrmodels.Assertion]¶ Get list of assertions for this issuer :param query: Query params :type query: dict, optional
-
fetch_badgeclasses(load_badge_names: bool = True, query=None) → List[badgrclient.badgrmodels.BadgeClass]¶ Get a list of BadgeClasses for this issuer
Parameters: - load_badge_names (bool, optional) – Should the fetched data be used to load badge names if unique_badge_names is True. Defaults to True.
- query (dict, optional) – Query params. Defaults to None.
Returns: [description]
Return type: List[BadgeClass]
-