Org documentation¶
merit.org module¶
- class merit.org.Org(org_id: Optional[str] = None, app_id: Optional[str] = None, app_secret: Optional[str] = None, production: bool = True)[source]¶
Bases:
merit.merit.MeritMerit Organizations
To properly create an instance, begin with
merit.Merit.link_with_merit()flow, retreive an org_access_token, and exchange it for an org_id- Parameters
app_id – ID for the app, given during creation
app_secret – secret for the app, given during creation
production – specify the environment for your API calls
org_id – ID for the Merit Organization
- Returns
merit.Org object
- edit_merit(merit_id: str, data: dict) → bool[source]¶
Edit specified merit.
- Parameters
merit_id – the ID of the merit to edit
data – a dict with the edits you wish to make
- Returns
a bool indicating the status of the edit
- get_all_merits(template_id: Optional[str] = None, merit_status: Optional[str] = None, email: Optional[str] = None, limit: int = 100) → list[source]¶
Get all Org merits by specifications.
- Parameters
template_id (str, optional) – the ID of the MeritTemplate you wish to retreive
merit_status (str, optional) – the status you wish to filter by
email (str, optional) – a member’s email you wish to filter by
limit (int, optional) – the number of results you wish to retreive
- Returns
a list of merits issued by the Org, filtered as specified
- Return type
list
- get_all_org_merit_templates(limit: int = 100, org_id: Optional[str] = None) → list[source]¶
Return a list of all MeritTemplates owned by the Org.
- get_api(path: str, params: Optional[dict] = None) → requests.models.Response[source]¶
Unified endpoint for all GET calls out to API.
- Parameters
path – the relative path, appended to domain, be sure to include a leading slash
params – a dict of query params to include
- Returns
requests.response object
- get_field(field_id: str) → dict[source]¶
Return details of specified Field.
- Parameters
field_id – the ID of the field you wish to retreive
- Returns
a dict of the Field’s info
- get_member_access_merit(member_id: str) → dict[source]¶
Get Member’s Access merit for this app, which returns more details than get_member_info
- Parameters
member_id – the ID of the Member you wish to retreive
- Returns
a Merit dict
- get_member_id_from_token(member_id_token: str) → str[source]¶
Exchange member_id_token from login_with_merit for permanent member_id.
- Parameters
member_id_token – the token to exchange
- Returns
member_id
- get_member_info(member_id: str) → dict[source]¶
Get Merit information about Member.
- Parameters
member_id – the ID of the Member you wish to retreive
- Returns
{“id”: “573564e698ae3b96668fd517”,”name”: {“firstName”: “Omer”,”lastName”:”Zach”}}
- get_member_merits(member_id: str, template_id: Optional[str] = None, limit: int = 100) → list[source]¶
Get all Member merits by specifications.
- Parameters
member_id (str) – the ID of the Member you wish to retreive
template_id (str, optional) – the ID of the MeritTemplate you wish to retreive
limit (int, optional) – the number of results you wish to retreive
- Returns
a list of merits issued owned by the Member, filtered as specified
- Return type
list
- get_merit(merit_id: str) → dict[source]¶
Return details of specified Merit.
- Parameters
merit_id – the ID of the Merit you wish to retreive
- Returns
all details about that Merit
- get_merit_template(template_id: str) → dict[source]¶
Return details of specified MeritTemplate.
- Parameters
template_id – the ID of the MeritTemplate you wish to retreive
- Returns
all details about that MeritTemplate
- get_org_info() → dict[source]¶
Get Merit information about Organization.
- Returns
{“id”: “5b442b02b85f223fffe9e851”,”title”: “Millbrae CERT”,”description”: “This is an example Org”,”website”: “http://www.example.com”,”address”: “1001 Broadway, Millbrae, CA, USA”,”phone”: “+1 650-296-9525”,”email”: “admin@example.com”,”logoUrl”: “https://images.sig.ma/5c4f598f774d570006465f9e?rect=0,0,150,150”}
- get_org_merit_template_choices(include_none: bool = True) → list[source]¶
Return a formatted tuple of form choices of available MeritTemplates.
- get_template_field_choices(template_id: str) → list[source]¶
Return list of fields used in specified Template.
- Parameters
template_id – the ID of the MeritTemplate you wish to retreive
- Returns
a list of Field dicts used in that MeritTemplate
- get_template_pending_merits(template_id: str) → list[source]¶
Return all proposed merits from site MeritTemplate.
- Parameters
template_id – the ID of the MeritTemplate you wish to retreive
- Returns
a list of all merits matching criteria
- login_with_merit(success_url: str, failure_url: str, permissions: list = ['CanViewPublicProfile'], org_ids: Optional[list] = None) → str[source]¶
Initiate process to Login with Merit for a member.
- Parameters
success_url – relative path where Merit will redirect the user after successful authentication
failure_url – relative path where Merit will redirect the user after unsuccessful authentication
permissions – a list of permissions you wish to request from the member
org_ids – a list of org_ids for which you wish to request permission from the member. Must be included if CanViewAllStandardMeritsFromOrg is included in permissions.
- Returns
URL to redirect user to to begin link_with_merit flow (https://app.merits.com/link-app/?token=5aa5a3992bfa4e0006c47cdf)
- member_has_active_merit(member_id: str, template_id: str) → bool[source]¶
Check whether Member has an active merit from the Template specified.
- Parameters
member_id – the ID of the Member you wish to check
template_id – the ID of the MeritTemplate you wish to check
- Returns
a boolean whether the Member passes the test
- Return type
bool
- post_api(path: str, data: Optional[dict] = None) → requests.models.Response[source]¶
Unified endpoint for all POST calls out to API.
- Parameters
path – the relative path, appended to domain, be sure to include a leading slash
data – a dict of json data to send along with the POST
- Returns
a requests.response object
- propose_merit(data: dict) → str[source]¶
Propose a merit as specified.
- Parameters
data – a full dict ready to be proposed as a merit
- Returns
the ID of the proposed merit
- revoke_merit(merit_id: str, reason: str) → bool[source]¶
Revoke specified merit.
- Parameters
merit_id – the ID of the merit to edit
reason – the reason for revoking the merit
- Returns
a bool indicating the status of the revocation
- search_orgs(query: str) → list[source]¶
Search for Organization by name based on provided query.
- Parameters
query (str) – the name you wish to search for
- Returns
a list of dicts of all Organizations with a matching name.
- Return type
list
- send_merit(data: dict) → str[source]¶
Send merit as specified.
- Parameters
data – a full dict ready to be sent as a merit
- Returns
the ID of the sent merit