GET /api/events

Description

Returns array of course events. Note that this will not return events that are modules of a parent course. These are nested in the children attribute of the object.

Parameters

view

String. Optional. Specifies either "full" or "simple" result type.

competence_id

Int. Optional. To list only events belonging to a specific competence.

organisation_ids

Array of ints. Optional. Only return events that have participants belonging to Organisations.

context_organisation_ids

Array of ints. Optional. Only return events that are available within the context of the given organisation as specified using by the organisation_id(s)

context_extern_organisation_ids

Array of ints. Optional. Only return events that are available within the context of the given organisation as specified by the extern_organisation_id(s)

host_organisation_ids

List. Optional. When specified, only courses hosted by the given organisations is returned.

host_organisation_external_ids

List. Optional. When specified, only courses hosted by the given organisations is returned.

user_check

Int. Optional 1 or 0. If set to 1, Snapper Grape will check if current logged in user (or user defined with user_name) is signed on to the course. 

recursive

Int. Optional. 1 or 0. Whether or not parameter organisation_ids should result in a recursive, tree search for participants or not. If set, will return events with participants belonging to branches of organisation tree defined by organisation_ids. Default: 0

term

String. Optional. Search term, to restrict results to events matching term.

cancelled

Int. Optional. Return cancelled events or not. Default: 0

category_ids

Array of ints. Optional. Restrict result to events whose definition (competence) is tagged with categories.

attribute_ids

Array of ints. Optional. Restrict result to events that are tagged with attributes.

competence_group_ids

Array of ints. Optional. Restrict result to events whose definition (competence) is tagged in groups.

external_competence_group_ids

List of ids. Restrict to competences belonging to these groups. Can be used together with competence_group_ids.

location_id

Int. Optional. Return only events held at given location. Startdate and enddate must also be given, otherwise will be ignored.

start

DEPRECATED. Will be removed in future version. Use offset in stead.

limit

Int. Optional. Default: 20. Maximum: 100. Limit the size of the result set.

offset

Int. Optional. Default: 0. Offset the result set, starting at this index. For batching/paging.

mode

String. Optional. ”future”/”finished”/"notfinished"/”all”.  Controls if we are to get future, finished, not finished events, or all. Default: ”future”

startdate

String, date on ISO format. Optional. Return only events starting on or after this time. Overrides ”mode” parameter.

enddate

String, date on ISO format. Optional. Return only events starting before this time. Overrides ”mode” parameter.

sort_direction

String. "asc"/"desc". Whether the result should be sorted ascendingly or descendingly. Default: "asc". 

custom_attributes

Dot-notation object. Example: "custom_attributes.my_attribute=123&custom_attributes.my_other_attribute=abc". Limit the result to Events with these custom attributes. Custom attributes are defined on a per-customer basis, and can be just about anything.

fields

String. Optional. See Field customization.

Return

Array of Event objects.

Security

Superuser, manager, person

GET /api/events/[event_id]

Description

Returns detailed view of course event.

Parameters

view

String. Optional. Specifies if you want either 'full' or 'simple' result type.

user_check

Int. Optional 1 or 0. If set to 1, Snapper Grape will check if current logged in user (or user defined with user_name) is signed on to the course. 

fields

String. Optional. See Field customization.

Return

Array of one Event object.

Security

Superuser, manager, person

GET /api/events/[event_id]/participants

Description

Returns a list of participants (Person) for the course event.

/api/participants/123 will yield the same result as /api/events/123/participants.

Parameters

view

String. Optional. Specifies if you want either 'full' or 'simple' result type.

fields

String. Optional. See Field customization.

Return

Array of Person objects.

Security

Superuser, manager, person

GET /api/events/[event_id]/check_join

Description

Check if a user can sign on to the course. Several testes are performed.

  • date limits for sign on 
  • that the user has completed prerequisite courses (if any)
  • age check for user, if there are age limits
  • that there are enough free seats (at the moment)
  • (configurable) that we have e-mail and mobile number for the user
  • (configurable) that the user is not already signed on to another course for the given date/time period
  • that the user is not already signed on to the course.
  • if the course is cancelled
  • if the course is locked

The check is performed either on for currently logged in user, or user as specified with user_name (see below).

Parameters

user_name

String. Optional. Specifies for which user to persform join check

Returns

Dictionary with the following attributes:

can_join

Boolean. True or False depending on whether the user can sign on to the course or not. Please note: The can_join is returned to FALSE for all reasons below, except for event_full, where can_join is True. The person may be signed on to the course, but will be added to the wait list.

places

Int. Number of free seats

reason

List og strings. Specifies one or more criterias the user did not fulfill. The criterias are: 

  • "conflicting_course" - the user is already signed on to another course within the same time frame as current event
  • "prerequisites" - the user does not fulfill one or more of the prerequisites for the given even (as specified on the competence)
  • "age" - the user does not fullfill the age requirements
  • "required_fields" - one or more required fields are missing, mobile or e-mail
  • "already_joined" - the user is already signed on to the given course event
  • "event_full" - there are no more free seats for the event
  • "cancelled" - the course is cancelled
  • "locked" - the course is locked

For each of the reasons a string will be returned that indicates why the user may not sign on. The string is defined in the returned dictionary, and the key is the same as the reason item. See examples below.

Security

Superuser, manager, person (self)

Example, check failes

URL

https://peendev.snappergrape.no/api/events/7299/check_join?user_name=pe@snapper.no

Returns

{ ​can_join: false, reason: ["age", "prerequisites" ], places: 20, prerequisites: "Petter Enholm oppfyller ikke vilkår(ene) for å kunne delta på dette kurset: Vikarkurs, sykepleier, Bufetat / Barnevern, Basiskurs - Foreldre/fosterhjem", age: "Petter Enholm kan ikke meldes på kurset på grunn av aldersgrenser", }

Example, check OK

URL

https://peendev.snappergrape.no/api/events/7299/check_join?user_name=knerten

Returns

{
  can_join: true,
  places: 20,
}