User's Notifications preferences

This section describes the API of the user's notifications preferences. An user can set his notifications preferences according to an event in Rexpense. These events are listed bellow:

Email notifications attributes

email_on_expense_created: boolean
email_on_expense_updated: boolean
email_on_expense_destroyed: boolean
email_on_expense_status_changed: boolean
email_on_attachment_created: boolean
email_on_attachment_destroyed: boolean
email_on_comment_created: boolean
email_on_comment_updated: boolean
email_on_comment_destroyed: boolean
email_on_organization_add_member: boolean
email_on_organization_remove_member: boolean
email_on_organization_left: boolean
email_on_organization_role_changed: boolean
email_on_advancement_created: boolean
email_on_advancement_updated: boolean
email_on_advancement_destroyed: boolean
email_on_reimbursement_created: boolean
email_on_reimbursement_updated: boolean
email_on_reimbursement_destroyed: boolean
email_on_advancement_devolution_created: boolean

Mobile notifications attributes

mobile_on_expense_created: boolean
mobile_on_expense_updated: boolean
mobile_on_expense_destroyed: boolean
mobile_on_expense_status_changed: boolean
mobile_on_attachment_created: boolean
mobile_on_attachment_destroyed: boolean
mobile_on_comment_created: boolean
mobile_on_comment_updated: boolean
email_on_comment_destroyed: boolean
mobile_on_organization_add_member: boolean
mobile_on_organization_remove_member: boolean
mobile_on_organization_left: boolean
mobile_on_organization_role_changed: boolean
mobile_on_advancement_created: boolean
mobile_on_advancement_updated: boolean
mobile_on_advancement_destroyed: boolean
mobile_on_reimbursement_created: boolean
mobile_on_reimbursement_updated: boolean
mobile_on_reimbursement_destroyed: boolean
mobile_on_advancement_devolution_created: boolean

Example User's Notifications

    {
      "user": {
        "id": 1,
        "locale": "pt",
        "timezone": "Brasilia",
        "mention_name": "JohnFoo",
        "default_currency": "USD",
        "avatar": [],
        "_links": [
          {
            "rel": "self",
            "href": "https://app.rexpense.com/api/v1/preferences",
            "method": "GET"
          },
          {
            "rel": "update",
            "href": "https://app.rexpense.com/api/v1/preferences",
            "method": "PUT"
          },
          {
            "rel": "partial_update",
            "href": "https://app.rexpense.com/api/v1/preferences",
            "method": "PATCH"
          }
        ]
      },
      "email_on_expense_created": true,
      "email_on_expense_updated": true,
      "email_on_expense_destroyed": true,
      "email_on_attachment_created": true,
      "email_on_attachment_destroyed": true,
      "email_on_comment_created": true,
      "email_on_comment_updated": true,
      "email_on_comment_destroyed": true,
      "email_on_organization_add_member": true,
      "email_on_organization_left": true,
      "email_on_organization_remove_member": true,
      "email_on_organization_role_changed": true,
      "email_on_advancement_created": true,
      "email_on_advancement_updated": true,
      "email_on_advancement_destroyed": true,
      "email_on_reimbursement_created": true,
      "email_on_reimbursement_updated": true,
      "email_on_reimbursement_destroyed": true,
      "email_on_advancement_devolution_created": true,
      "mobile_on_expense_created": true,
      "mobile_on_expense_updated": true,
      "mobile_on_expense_destroyed": true,
      "mobile_on_attachment_created": true,
      "mobile_on_attachment_destroyed": true,
      "mobile_on_comment_created": true,
      "mobile_on_comment_updated": true,
      "mobile_on_comment_destroyed": true,
      "mobile_on_organization_add_member": true,
      "mobile_on_organization_left": true,
      "mobile_on_organization_remove_member": true,
      "mobile_on_organization_role_changed": true,
      "mobile_on_advancement_created": true,
      "mobile_on_advancement_updated": true,
      "mobile_on_advancement_destroyed": true,
      "mobile_on_reimbursement_created": true,
      "mobile_on_reimbursement_updated": true,
      "mobile_on_reimbursement_destroyed": true,
      "mobile_on_advancement_devolution_created": true,
      "_links": [
        {
          "rel": "self",
          "href": "https://app.rexpense.com/api/v1/notifications",
          "method": "GET"
        },
        {
          "rel": "update",
          "href": "https://app.rexpense.com/api/v1/notifications",
          "method": "PUT"
        },
        {
          "rel": "partial_update",
          "href": "https://app.rexpense.com/api/v1/notifications",
          "method": "PATCH"
        }
      ]
    }
    

Show notifications preferences

Returns the detailed information of the user's notifications preferences.

Definition

GET https://app.rexpense.com/api/v1/notification_preferences

Example Request

$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/notification_preferences \
       -H 'Accept: application/json' \
       -H 'Content-type: application/json'

Response Example

HTTP 200 OK
    {
      "user": {
        ...
      },
      "email_on_expense_created": true,
      ...
    }
    

Update notifications preferences

There are two ways to update the user's notifications: partially or fully. If you'd like to change just one or a few attributes, you have to use the HTTP method PATCH. If you use the HTTP method PUT, you'll have to pass all attributes of the user's notifications preferences.

Parameters

Possible parameters are describe in the section above.

Definition

PUT/PATCH https://app.rexpense.com/api/v1/notification_preferences

Example Request

$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/notification_preferences \
       -H 'Accept: application/json' \
       -H 'Content-type: application/json' \
       -d '{"locale":"en"}'

Response Example Success

HTTP 200 OK
    {
      "user": {
        ...
      },
      "email_on_expense_created": true,
      ...
    }
    

Response Example Failure

HTTP 422 Unprocessable Entity
    {
      "errors": {
        "email_on_expense_created": ["can't be blank"]
      }
    }
    

Describe notifications preferences

Returns the names and description of the user's notifications.

Definition

GET https://app.rexpense.com/api/v1/notification_preferences/descriptions

Example Request

$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/notification_preferences/descriptions \
       -H 'Accept: application/json' \
       -H 'Content-type: application/json'

Response Example

HTTP 200 OK
    [
      {
        "names": ["email_on_expense_status_changed", "mobile_on_expense_status_changed"],
        "description": "The status of an expense was updated",
      },
      {
        "names": ["email_on_expense_created", "mobile_on_expense_created"]
        "description": "A new expense was created"
      },
      {
        "names": ["email_on_expense_updated", "mobile_on_expense_updated"],
        "description": "An expense was updated"
      },
      {
        "names": ["email_on_expense_destroyed", "mobile_on_expense_destroyed"],
        "description": "An expense was deleted"
      },
      {
        "names": ["email_on_attachment_created", "mobile_on_attachment_created"],
        "description": "A new attachment was added in the expense"
      },
      {
        "names": ["email_on_attachment_destroyed", "mobile_on_attachment_destroyed"],
        "description": "An attachment was deleted from an expense"
      },
      {
        "names": ["email_on_comment_created", "mobile_on_comment_created"],
        "description": "A comment was added in an expense"
      },
      {
        "names": ["email_on_comment_updated", "mobile_on_comment_updated"],
        "description": "A comment was updated"
      },
      {
        "names": ["email_on_comment_destroyed", "mobile_on_comment_destroyed"],
        "description": "A comment was deleted"
      },
      {
        "names": ["email_on_organization_add_member", "mobile_on_organization_add_member"],
        "description": "A new member was added to an organization"
      },
      {
        "names": ["email_on_organization_left", "mobile_on_organization_left"],
        "description": "A member left the organization",
      },
      {
        "names": ["email_on_organization_remove_member", "mobile_on_organization_remove_member"],
        "description": "A member was deleted from an organization"
      },
      {
        "names": ["email_on_organization_role_changed", "mobile_on_organization_role_changed"],
        "description": "A member has its role modified in the organization"
      },
      {
        "names": ["email_on_advancement_created", "mobile_on_advancement_created"],
        "description": "A new advancement was created"
      },
      {
        "names": ["email_on_advancement_updated", "mobile_on_advancement_updated"],
        "description": "An advancement was updated"
      },
      {
        "names": ["email_on_advancement_destroyed", "mobile_on_advancement_destroyed"],
        "description": "An advancement was deleted"
      },
      {
        "names": ["email_on_advancement_devolution_created", "mobile_on_advancement_devolution_created"],
        "description": "An new advancement devolution was created"
      },
      {
        "names": ["email_on_reimbursement_created", "mobile_on_reimbursement_created"],
        "description": "A new reimbursement was created"
      },
      {
        "names": ["email_on_reimbursement_updated", "mobile_on_reimbursement_updated"],
        "description": "A reimbursement was updated"
      },
      {
        "names": ["email_on_reimbursement_destroyed", "mobile_on_reimbursement_destroyed"],
        "description": "A reimbursement was deleted"
      }
    ]