User - Documentation

# User

### Namespaces

otp
providers

### Members

#### (route) retrieve

##### Route:

Method | Path
--- | ---
GET | /api/users/isLogged

Retrieve user metadata

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
user | Object | user model

##### Response Code:

Type | Description
--- | ---
200 | the user has been retrieved

### Methods

#### (route) attachCreditCard()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
POST | /api/users/payment/

Add a credit card to the user account

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Description
--- | --- | ---
token | String | card token generated by stripe

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Object | stripe credit card Object

##### Response Code:

Type | Description
--- | ---
400 | missing parameters
500 | stripe error
200 | succesfully added the card

#### (route) delete()

##### Route:

Method | Path
--- | ---
DELETE | /api/users/delete

Delete the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | user object

##### Response Code:

Type | Description
--- | ---
500 | database error
403 | permission denied (hold buckets)
200 | succesfully deleted the user

#### (route) deleteCreditCard(:card_id)

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
DELETE | /api/users/payment/card/:card_id

Delete a specific credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:card_id | String | the stripe id of the card

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully retieved the card
403 | the user must have one card active when having a subscription

##### Parameters:

Name | Type | Description
--- | --- | ---
`:card_id` |  | the stripe id of the card

#### (route) fetchCreditCard(:card_id)

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/card/:card_id

Fetch a specific credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:card_id | String | the stripe id of the card

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully retieved the card

##### Parameters:

Name | Type | Description
--- | --- | ---
`:card_id` |  | the stripe id of the card

#### (route) fetchDefaultCreditCard()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/card

Fetch the default credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
404 | the user doesn't have any default card
200 | succesfully retieved the card

#### (route) fetchMetadata()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/card/stripe_metadata

Fetch stripe metadata for a user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | stripe metadata object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully retrieved the metadata

#### (route) listCharges()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/charges

List the charges that the user have

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | list of stripe charges object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
200 | succesfully retieved the charges

#### (route) listSubscriptions()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/subcriptions

List the subscriptions that the user have

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | list of stripe subscriptions object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
200 | succesfully retrieved the charges

#### (route) setDefaultCard(:card_id)

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
POST | /api/users/payment/card/:card_id/default

Set a specific credit card as the user default card

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:card_id | String | the stripe id of the card

##### Response:

Name | Type | Description
--- | --- | ---
data | Object | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully set the card as default

##### Parameters:

Name | Type | Description
--- | --- | ---
`:card_id` |  | the stripe id of the card

#### (route) show(:id)

##### Route:

Method | Path
--- | ---
GET | /api/users/show/:id

Show public data about a user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:id | String | user id

##### Response:

Name | Type | Description
--- | --- | ---
String |  | email user email
String |  | username user pseudo

##### Response Code:

Type | Description
--- | ---
500 | database error
400 | invalid parameters (no id provided)
404 | no user account where found
200 | the mail has been sent to the provided email

##### Parameters:

Name | Type | Description
--- | --- | ---
`:id` |  | user id

#### (route) update()

##### Route:

Method | Path
--- | ---
POST | /api/users/update

Update metadata about the user

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
username | String | optional |
email | String | optional |
old_password | String | optional |
new_password | String | optional |
info | Object | optional |

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | user object

##### Response Code:

Type | Description
--- | ---
500 | database error
400 | missing parameters, no data to update
403 | when updating the password, it need a new one
406 | when updating the password, the old one is false
409 | when updating email or username another user already have one of those two
200 | succesfully updated the card

#### (route) updateCreditCard()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
PUT | /api/users/payment/card

Update a credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
id | String |  | stripe card id
metadata | Object | optional | the metadata you can update
metadata.address_line1 | String | optional |
metadata.address_country | String | optional |
metadata.address_zip | String | optional |
metadata.address_city | String | optional |

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters, you need to specify a card
200 | succesfully updated the card

#### (route) updateMetadata()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
PUT | /api/users/payment/stripe_metadata

Update a stripe metadata of the user

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
metadata | Object |  | the metadata you can update
metadata.vat_number | String | optional |
metadata.company_name | String | optional |

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe customer metadata object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters, you need to specify a card
200 | succesfully updated the card

## User

### Namespaces

otp
providers

### Members

#### (route) retrieve

##### Route:

Method | Path
--- | ---
GET | /api/users/isLogged

Retrieve user metadata

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
user | Object | user model

##### Response Code:

Type | Description
--- | ---
200 | the user has been retrieved

### Methods

#### (route) attachCreditCard()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
POST | /api/users/payment/

Add a credit card to the user account

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Description
--- | --- | ---
token | String | card token generated by stripe

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Object | stripe credit card Object

##### Response Code:

Type | Description
--- | ---
400 | missing parameters
500 | stripe error
200 | succesfully added the card

#### (route) delete()

##### Route:

Method | Path
--- | ---
DELETE | /api/users/delete

Delete the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | user object

##### Response Code:

Type | Description
--- | ---
500 | database error
403 | permission denied (hold buckets)
200 | succesfully deleted the user

#### (route) deleteCreditCard(:card_id)

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
DELETE | /api/users/payment/card/:card_id

Delete a specific credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:card_id | String | the stripe id of the card

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully retieved the card
403 | the user must have one card active when having a subscription

##### Parameters:

Name | Type | Description
--- | --- | ---
`:card_id` |  | the stripe id of the card

#### (route) fetchCreditCard(:card_id)

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/card/:card_id

Fetch a specific credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:card_id | String | the stripe id of the card

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully retieved the card

##### Parameters:

Name | Type | Description
--- | --- | ---
`:card_id` |  | the stripe id of the card

#### (route) fetchDefaultCreditCard()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/card

Fetch the default credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
404 | the user doesn't have any default card
200 | succesfully retieved the card

#### (route) fetchMetadata()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/card/stripe_metadata

Fetch stripe metadata for a user

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | stripe metadata object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully retrieved the metadata

#### (route) listCharges()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/charges

List the charges that the user have

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | list of stripe charges object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
200 | succesfully retieved the charges

#### (route) listSubscriptions()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
GET | /api/users/payment/subcriptions

List the subscriptions that the user have

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | list of stripe subscriptions object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
200 | succesfully retrieved the charges

#### (route) setDefaultCard(:card_id)

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
POST | /api/users/payment/card/:card_id/default

Set a specific credit card as the user default card

##### Authentication

A authentication is needed to access this endpoint

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:card_id | String | the stripe id of the card

##### Response:

Name | Type | Description
--- | --- | ---
data | Object | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters card_id
200 | succesfully set the card as default

##### Parameters:

Name | Type | Description
--- | --- | ---
`:card_id` |  | the stripe id of the card

#### (route) show(:id)

##### Route:

Method | Path
--- | ---
GET | /api/users/show/:id

Show public data about a user

##### Route Parameters:

Name | Type | Description
--- | --- | ---
:id | String | user id

##### Response:

Name | Type | Description
--- | --- | ---
String |  | email user email
String |  | username user pseudo

##### Response Code:

Type | Description
--- | ---
500 | database error
400 | invalid parameters (no id provided)
404 | no user account where found
200 | the mail has been sent to the provided email

##### Parameters:

Name | Type | Description
--- | --- | ---
`:id` |  | user id

#### (route) update()

##### Route:

Method | Path
--- | ---
POST | /api/users/update

Update metadata about the user

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
username | String | optional |
email | String | optional |
old_password | String | optional |
new_password | String | optional |
info | Object | optional |

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
. | Object | user object

##### Response Code:

Type | Description
--- | ---
500 | database error
400 | missing parameters, no data to update
403 | when updating the password, it need a new one
406 | when updating the password, the old one is false
409 | when updating email or username another user already have one of those two
200 | succesfully updated the card

#### (route) updateCreditCard()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
PUT | /api/users/payment/card

Update a credit card of the user

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
id | String |  | stripe card id
metadata | Object | optional | the metadata you can update
metadata.address_line1 | String | optional |
metadata.address_country | String | optional |
metadata.address_zip | String | optional |
metadata.address_city | String | optional |

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe card object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters, you need to specify a card
200 | succesfully updated the card

#### (route) updateMetadata()

Deprecated:
  - Yes

##### Route:

Method | Path
--- | ---
PUT | /api/users/payment/stripe_metadata

Update a stripe metadata of the user

##### Authentication

A authentication is needed to access this endpoint

##### Body Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
metadata | Object |  | the metadata you can update
metadata.vat_number | String | optional |
metadata.company_name | String | optional |

##### Header Parameters:

Name | Type | Description
--- | --- | ---
Authorization | String | bearer access token issued for the user

##### Response:

Name | Type | Description
--- | --- | ---
data | Array | stripe customer metadata object

##### Response Code:

Type | Description
--- | ---
500 | stripe error
400 | missing parameters, you need to specify a card
200 | succesfully updated the card