# User api description ## User sign up `POST` API_URL/api/v1/users/signup **Accepted params:** | Parameter | Description | Required | | ------------ | ------------ | ------------ | | `name` | String, user full name | `true` | | `email` | String, user email | `true` | | `password` | String, min length 8 | `true` | | `password_configrmation`| String, should be equal to `password` | `true` | | `phone` | String, user phone number | `true` | | `info` | String, user information, for example a description of the desired property | `false` | ```json { "data": { "id": "5e77fa6ac3e7c4220e3456de", "type": "user", "attributes": { "name": "Api User", "email": "apiuser@test.te", "phone": "1234567890", "role": "client", "info": "I want to buy a big house in Augusta, PS: preferably with an autonomous bunker and prepared for a zombie apocalypse", "welcomeSended": false, "welcomeStatus": "browsing", "photo": { "url": null, "thumb": { "url": null }, "profile": { "url": null } } } } } ``` **response headers contain authorization token: ** | Parameter | Value | | ------------ | ------------ | | `Authorization` | Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhZDYzZDYzYS0wZTk2LTQxNTctOTM0My05YjUyNTk1YTZiNDYiLCJzdWIiOiI1ZTc3ZmE2YWMzZTdjNDIyMGUzNDU2ZGUiLCJzY3AiOiJ1c2VyIiwiYXVkIjpudWxsLCJpYXQiOjE1ODQ5MjEzNDgsImV4cCI6MTU4NTA5NDE0OH0.EybdEOxEQIztRYdgUt7v2kI0Ypr8r5zV3cx4j4aWA4Y | ## User sign in `POST` API_URL/api/v1/users/login **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `email` | String, user email | | `password` | String, user password | reponse status** OK 200**, **response body:** ```json { "data": { "id": "5e77fa6ac3e7c4220e3456de", "type": "user", "attributes": { "name": "Api User", "email": "apiuser@test.te", "phone": "1234567890", "role": "client", "info": "I want to buy a big house in Augusta, PS: preferably with an autonomous bunker and prepared for a zombie apocalypse", "welcomeSended": false, "welcomeStatus": "browsing", "photo": { "url": null, "thumb": { "url": null }, "profile": { "url": null } } } } } ``` **response headers contain authorization token: ** | Parameter | Value | | ------------ | ------------ | | `Authorization` | Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhZDYzZDYzYS0wZTk2LTQxNTctOTM0My05YjUyNTk1YTZiNDYiLCJzdWIiOiI1ZTc3ZmE2YWMzZTdjNDIyMGUzNDU2ZGUiLCJzY3AiOiJ1c2VyIiwiYXVkIjpudWxsLCJpYXQiOjE1ODQ5MjEzNDgsImV4cCI6MTU4NTA5NDE0OH0.EybdEOxEQIztRYdgUt7v2kI0Ypr8r5zV3cx4j4aWA4Y | ## User logout *request should contain an authorization token in the header* `DELETE` API_URL/api/v1/users/logout response status code **No Content 204** **response body: nil** #### Email confirmation `GET` API_URL/api/v1/users/confirmation | Parameter | Value | | ------------ | ------------ | | `confirmation_token` | o2DCdxM1AY2EhnmyZNNj | **response status OK if token valid and email has not been previously confirmed. In all other cases it retrun stauts code unprocessable_entity 422 without body** ## Update user profile *request should contain an authorization token in the header* `POST` API_URL/api/v1/profile **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `phone` | String, user phone | | `info` | String, user info | ## Update user password `POST` API_URL/api/v1/profile/update_password **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `current_password` | String, current user password | | `new_password` | String, new user password | | `new_password_confirmation` | String, new user password confirmation | **response status code OK 200 response body: nil** ## Upload user photo *request should contain an authorization token in the header* endpoint accepts **form-data** `POST` API_URL/api/v1/profile/update_photo **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `file` | Image file, supported formats: jpeg, jpg, png | After uploading, 2 sizes will be created: tumb: 267x267px profile: 360x500px url: otriginal image size **response status code OK 200** response body: ```json { "photo": { "url": "https://s3.garagelabs.dev/listd-staging/user/photo/5e77fa6ac3e7c4220e3456de/uploads/2.jpeg", "thumb": { "url": "https://s3.garagelabs.dev/listd-staging/user/photo/5e77fa6ac3e7c4220e3456de/uploads/thumb_2.jpeg" }, "profile": { "url": "https://s3.garagelabs.dev/listd-staging/user/photo/5e77fa6ac3e7c4220e3456de/uploads/profile_2.jpeg" } } } ``` ## Invite new user *request should contain an authorization token in the header* `POST` API_URL/api/v1/users/invite **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `name` | String, invitable user name | | `email` | String, invitable user email | **response status code OK 200** **response body:** ```json { "data": { "id": "5e7817f3c3e7c4265ce6450c", "type": "user", "attributes": { "name": "Invited user", "email": "email_to_invite@test.te", "phone": null, "role": null, "info": null, "welcomeSended": false, "welcomeStatus": null, "photo": { "url": null, "thumb": { "url": null }, "profile": { "url": null } } } } } ``` ## Set welcome status *request should contain an authorization token in the header* *after registering a user, we suggest that client choose his preferred agent (if he already works with one of our agents) or choose another option: My agent is not in list, No, I am not working with anyone right now, Just browsing* `POST` API_URL/api/v1/profile/set_welcome_status **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `status` | String, user status key | | Key | Status | | ------------ | ------------ | | `agent_selected` | In case when user set the preferred agent | | `not_working` | No, I am not working with anyone right now | | `agent_is_not_listed` | My Realtor isn’t on this list | | `browsing` | Just browsing | **response status code OK 200**, **response body: nil** ## Get list of available users(for conversations, sharings, etc) *request should contain an authorization token in the header* `GET` API_URL/api/v1/profile/available_users **request does not require parameters** **response status code OK 200** **response body:** ```json { "data": [ { "id": "5e7815c4c3e7c426dddceca0", "type": "user", "attributes": { "name": "Invite User1", "email": "invitetest1@test.te", "photoThumb": null } }, { "id": "5e7816c4c3e7c4265ce6450b", "type": "user", "attributes": { "name": "Invite User2", "email": "invitetest2@test.te", "photoThumb": null } }, { "id": "5e7817f3c3e7c4265ce6450c", "type": "user", "attributes": { "name": "Invite User3", "email": "invitetest3@test.te", "photoThumb": null } } ] } ``` ## Get available staff (listing agent, mortgage broker, insurance agent, etc) *request should contain an authorization token in the header* `GET` API_URL/api/v1/profile/available_staff **request does not require parameters** **response status code OK 200** **response body:** ```json { "data": [ { "id": "5c6d865822616d52d56c7d92", "type": "Listing Agent", "attributes": { "name": "Sherry Goff", "email": "sgoff@vandermorganrealty.com", "photoThumb": "https://s3.garagelabs.dev/listd-staging/user/photo/5c6d865822616d52d56c7d92/uploads/thumb_Sherry_Golf.jpg" } }, { "id": "5c888ae122616d6f397e6b08", "type": "Support Agent", "attributes": { "name": "support agent", "email": "support@listd.com", "photoThumb": "https://s3.garagelabs.dev/listd-staging/user/photo/5c888ae122616d6f397e6b08//uploads/thumb_logo.png" } }, { "id": "5c5320eb22616d244976f175", "type": "Listing Agent", "attributes": { "name": "Evgeny Strashko", "email": "es@test.te", "photoThumb": "https://s3.garagelabs.dev/listd-staging/user/photo/5c5320eb22616d244976f175//uploads/thumb_IMG_0843.jpg" } } ] } ``` ## Set preferred agent *request should contain an authorization token in the header* `POST` API_URL/api/v1/profile/preferred_agent **Accepted params:** | Parameter | Description | | ------------ | ------------ | | `id` | String, agent id, can be founded in `Get available staff` response| **response status code OK 200** **response body: nil**