User

The User is the main actor of the Push Api. All the system is turning arround him.

Push Api stores the basic information needed to send the notifications such as the email address and devices identifications.

Once an user is created, it is generated a unique ID in order to be stored in the external system that is using the Push API, this ID will be used with all calls that requires to refer an user so, it should be stored in your user database.

User contains more requests than the other calls and for this reason here are some shortcuts to improve user routes navitagion.

Routes

/user

πŸ“˜

Creates a user with the given the email.

It is created with email in order to have some basic data. As all users have an email address, it can be used immediately after creating user to send notifications.

ParamsTypeRequired?Description
emailstringtrueEmail of the new user.

Response

{
    "result": {
        "id": 1,
        "email": [
          1: "[email protected]"
        ],
        "android": [],
      	"ios": []
    }
}

🚧

Response keys description

  • id is the value created by Push API to that user (unique and non mutable).
  • email/android/ios are the device addresses that user have set. They are stored into an array. If user has not got values, the result value is an empty array.
  • int: deviceId: the 'int' references the unique device identification by Push API (so it can be later deleted) and the 'deviceId' does not need explanation.

Back to Index

/user/:id

πŸ“˜

Gets all user :id data.

No params expected.

Response

{
    "result": {
        "id": 1,
        "email": [
          1: "[email protected]",
          3: "[email protected]"
        ],
        "android": [
          5: "AAAAA-AA-SAMPLE-A-AAAA-AAAA-AAAA"
        ],
      	"ios": []
    }
}

Back to Index

/user/:id

πŸ“˜

Deletes the given user :id.

Response

{
    "result": true
}

Back to Index

/user/:id/device

πŸ“˜

Adds user :id devices.

  • It can be updated only one value per param if it is set.
  • It prevents to add duplicate values and updates smartphones device ids when a new user is using the same smartphone (it works only with smartphones ids).
ParamsTypeRequired?Description
emailstringfalseEmail of the new user.
androidstringfalseAndroid id of the user device.
iosstringfalseIos id of the user device.

Response

{
    "result": {
        "id": 1,
        "email": [
          1: "[email protected]",
          3: "[email protected]"
        ],
        "android": [
          5: "AAAAA-AA-SAMPLE-A-AAAA-AAAA-AAAA"
        ],
      	"ios": []
    }
}

Back to Index

/user/:id/device

πŸ“˜

Retrives user :id device unique id given its reference by param.

If the user does not have that reference, the response is false value.

ParamsTypeRequired?Description
referencestringtrueThe device address identification.

Response

πŸ“˜

Searching [email protected] unique id.

{
    "result": {
        "id": 10,
        "type": "ios",
        "user_id": 2,
        "reference": "XXXXXXXX-SAMPLE-XXXX-XXXX-XXXXXXXXXXXX"
    }
}

🚧

Responses

  • If found, the result is the unique id.
  • If not found, the result is boolean false.

Back to Index

/user/:id/device/:idDevice

πŸ“˜

Retrives user :id device unique id given its reference by param.

If the user does not have that device, the response is false value.

Response

{
    "result": {
        "id": 10,
        "type": "ios",
        "user_id": 2,
        "reference": "XXXXXXXX-SAMPLE-XXXX-XXXX-XXXXXXXXXXXX"
    }
}

Back to Index

/user/:id/device/:idDevice

πŸ“˜

Removes the device :idDevice from user :id.

Response

{
    "result": true
}

Back to Index

/user/:id/device/type/:type

πŸ“˜

Removes all user devices given its type.

Email type cannot be removed, there must be always one email.

Response

{
    "result": true
}

Back to Index

/user/:id/smartphones

πŸ“˜

Retrives the smartphones registered by user :id.

No params expected.

Response

{
    "result": [
    		"Android"
    ]
}

Back to Index

/users

πŸ“˜

Creates new users given its emails.

Only users with valid mails will be created.

ParamsTypeRequired?Description
emailsJsontrueA Json array of the users emails that should be registered. I.e: ["[email protected]","[email protected]","[email protected]"]

Response

{
    "result": [
        {
            "id": 8,
            "email": [
                "[email protected]"
            ],
            "android": [],
            "ios": []
        },
        {
            "id": 9,
            "email": [
                "[email protected]"
            ],
            "android": [],
            "ios": []
        },
        {
            "id": 10,
            "email": [
                "[email protected]"
            ],
            "android": [],
            "ios": []
        }
    ]
}

Back to Index

/users

πŸ“˜

Retrives all the users registered.

ParamsTypeRequired?Description
limitstringfalseMax results that must be displayed.
pagestringfalsePage to start displaying results.

Response

{
    "result": {
        "users": [
            {
                "id": 1,
                "email": [
                    1: "[email protected]",
                    3: "[email protected]"
                ],
                "android": [
                    5: "AAAAA-AA-SAMPLE-A-AAAA-AAAA-AAAA"
                ],
                "ios": []
            },
            {
                "id": 2,
                "email": {
                    "6": "[email protected]"
                },
                "android": [],
                "ios": []
            },
            {
                "id": 3,
                "email": {
                    "7": "[email protected]"
                },
                "android": [],
                "ios": [
										10: "XXXXXXXX-SAMPLE-XXXX-XXXX-XXXXXXXXXXXX"
                ]
            }
        ],
        "limit": 3,
        "page": 1,
        "totalInPage": 3
    }
}

🚧

If it is being searched using pages, when the last page is reached the next page response will display an array of users key empty.

Back to Index

User Channel Subscriptions

Users that are interested in receive notifications of different channels should be first subscribed. A channel subscription is a symbolic link of the user id and the channel id.

/user/:id/subscribe/:idchannel

πŸ“˜

Subscribes a user :id with a channel :idchannel.

Response

{
    "result": {
        "user_id": 1,
        "channel_id": 1,
        "id": 1
    }
}

Back to Index

/user/:id/subscribed/:idchannel

πŸ“˜

Gets the channel subscription of the user :id if exists the subscription.

No params expected.

Response

{
    "result": {
        "user_id": 1,
        "channel_id": 1,
        "id": 1
    }
}

Back to Index

/user/:id/subscribed/:idchannel

πŸ“˜

Deletes a user :id channel subscription.

Response

{
    "result": true
}

Back to Index

/user/:id/subscribed

πŸ“˜

Retrives all the subscriptions that user :id is subscribed.

No params expected.

Response

{
    "result": [
        {
            "id": 1,
            "user_id": 1,
            "channel_id": 1
        },
        {
            "id": 2,
            "user_id": 1,
            "channel_id": 2
        }
    ]
}

Back to Index

User Theme Preferences

By default user will receive all notifications to all the devices that he has registered if he has not managed preferences before.

User can enable/disable notifications or choose to which device he wants to receive each notification or all of them.

/user/:id/preference/:idtheme

πŸ“˜

Creates the preference that user :id wants to have set with a given theme :idtheme..

ParamsTypeRequired?Description
optioninteger (see mask values)trueThe mask value that distinguish between which device user wants to receive the notifications.

Response

{
    "result": {
        "user_id": 1,
        "theme_id": 1,
        "option": "1",
        "id": 1
    }
}

Back to Index

/user/:id/preference/:idtheme

πŸ“˜

Gets the preference value of the user :id.

Response

{
    "result": {
        "user_id": 1,
        "theme_id": 1,
        "option": "1",
        "id": 1
    }
}

Back to Index

/user/:id/preference/:idtheme

πŸ“˜

Updates user preference with the given value

ParamsTypeRequired?Description
optioninteger (see mask values)trueThe mask value that distinguish between which device user wants to receive the notifications.

Response

{
    "result": {
        "user_id": 1,
        "theme_id": 1,
        "option": "3",
        "id": 1
    }
}

Back to Index

/user/:id/preference/:idtheme

πŸ“˜

Deletes a user :id preference.

Response

{
    "result": true
}

Back to Index

/user/:id/preferences

πŸ“˜

Retrives all user :id the preferences of the user :id.

No params expected.

Response

{
    "result": [
        {
            "id": 1,
            "option": "1",
            "user_id": 1,
            "theme_id": 1
        },
        {
            "id": 2,
            "option": "0",
            "user_id": 1,
            "theme_id": 2
        },
        {
            "id": 3,
            "option": "1",
            "user_id": 1,
            "theme_id": 3
        }
    ]
}

Back to Index

/user/:id/preferences

πŸ“˜

Updates all user preferences to the same option. It can enable/disable all or choose to which device wants to receive all the notifications.

ParamsTypeRequired?Description
optioninteger (see mask values)trueThe mask value that distinguish between which device user wants to receive the notifications.

Response

{
    "result": true
}

Back to Index