User's Preferences
This section describes the API of the user's preferences. An user can set his preferences and these preferences are: locale and timezone.
Parameters
id: | integer |
locale: | string 'en' or 'pt' |
timezone: | string |
mention_name: | string |
default_currency: | string based on currencies code |
avatar: |
array of object array of styles and URL of the avatar |
_links: | array of object array of links of the user's preferences |
Example User's Preferences
{
"id": 1,
"locale": "pt",
"timezone": "Brasilia",
"mention_name": "JohnFoo",
"default_currency": "USD",
"avatar": [
{
"style": "original",
"url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/original/avatar.png",
"width": 716,
"height": 655,
"expiration": "2014-06-27T20:31:43Z"
},
{
"style": "medium",
"url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/medium/avatar.png",
"width": 300,
"height": 300,
"expiration": "2014-06-27T20:31:43Z"
},
{
"style": "thumb",
"url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/thumb/avatar.png",
"width": 100,
"height": 100,
"expiration": "2014-06-27T20:31:43Z"
}
{
"style": "tiny",
"url": "https://rexpense-uploads.s3.amazonaws.com/user_avatar/1/tiny/avatar.png",
"width": 48,
"height": 48,
"expiration": "2014-06-27T20:31:43Z"
}
],
"_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"
}
]
}
Show preferences
Returns the detailed information of the user's preferences.
Definition
GET https://app.rexpense.com/api/v1/preferences
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/preferences \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
HTTP 200 OK
{
"locale": "pt",
...
}
Update preferences
There are two ways to update the user's preferences: 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 preferences.
Parameters
locale: | string 'en' or 'pt' |
timezone: | string |
mention_name: | string |
default_currency: | string based on currencies code |
_links: | array of object array of links of the user's preferences |
To update the user avatar, you have to send the avatar
parameter. This parameter is a JSON object with the following information:
Parameters
file: | string |
_destroy: | boolean |
The file parameter must be an URL of the avatar. This URL may be achieve following the steps in Uploads section.
To remove the avatar, you have to pass the _destroy
parameter with value true
.
Definition
PUT/PATCH https://app.rexpense.com/api/v1/preferences
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/preferences \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"locale":"en"}'
Response Example Success
HTTP 200 OK
{
"locale": "en",
...
}
Response Example Failure
HTTP 422 Unprocessable Entity
{
"errors": {
"locale": ["can't be blank"]
}
}