API documentation

1. OAuth2 Authentication

We are using the "password" grant type for authenticating users through a client application: http://tools.ietf.org/html/draft-ietf-oauth-v2-25#page-34 .
Using this web service you can get an "access_token" that will be used for authorization by the other web services.

You can use any OAuth2 client that will make a POST request to the OAuth providers.

POST /api/car_driver/token

Parameters:

Parameter name Parameter type Description
grant_type string type of login strategy (only 'password' accepted)
username string email of the user
password string password of the user
client_app_id string application id provided by the PARKING+PLUS
client_secret string application secret provided by PARKING+PLUS
{
  "grant_type"    : "password",
  "username"      : "user@example.com",
  "password"      : "sekret",
  "client_app_id" : "the_client_app_id",
  "client_secret" : "the_client_secret"
}

Response:

{
    "token_info": {
        "access_token": "c7876f24c47c57150007868b095f06a8c48cfdcfae3b697cf36e58de93a1a9a1",
        "refresh_token": "9bdd2d7a3c0023cb299798e62006983dca8bbf451b6caf5af4f45c5633619683",
        "token_type": "bearer",
        "expires_in": 7200
    },
    "last_payment_info": {
        "id": 69,
        "duration_minutes": 60,
        "start_time": "2015-09-15 11:14:28",
        "end_time": "2015-09-15 12:14:28",
        "pay_amount": "1.0",
        "currency": "USD",
        "duration_until_end_seconds": 3551,
        "car": {
            "id": 82,
            "plate_number": "SV90PPP",
            "is_default": true
        },
        "zone": {
            "id": 79,
            "name": "Bistrita Zone 2",
            "price": "1.0",
            "price_unit": "hour",
            "currency": "USD",
            "selected": false,
            "current_time": "2015-09-17 17:10:46"
        }
    },
    "account_info": {
        "email": "user@example.com",
        "first_name": "name",
        "last_name": "name",
        "phone": "0740000000",
        "birthdate": "2015-05-05 00:00:00",
        "gender": "",
        "newsletter": true,
        "image_url": null,
        "home_location": null,
        "work_location": null,
        "has_valid_card": true
    }
}

Response Parameters:

Node name Parameter name Parameter type Description
token_info object includes the oauth parameters
access_token string access_token used for oAuth
refresh_token string refresh token used for refreshing the expired Access token
token_type string "bearer"
expires_in int seconds until the access token is no longer valid
last_payment_info object or null the last active(ongoing) order to the logged in user
id int the id of the order
duration_minutes int total duration of the order from the start_time
start_time datetime starting date and time of this order
end_time datetime ending date of this order
pay_amount string string representation of the total amount of the order (2 decimals)
currency string currency iso code
duration_until_end_seconds int remaining duration to the end in seconds
car object the car of this order
zone object the zone of this order without scheduler hours
zone/price_unit string time unit for zone/price (hour/minute)
account_info object account information
email string email of the user
first_name string first name of the user
last_name string last name of the user
phone string phone number of the user
birthdate string 'yyyy-mm-dd'
gender string gender of the user; accepted values 'Male'/'Female'
image_url string url of the profile picture of the user
home_location object home location of the user(should not be used for now)
work_location object work location of the user(should not be used for now)
newsletter bool true if user accepts newsletter

Status Code: 401 if user or password incorrect

{
  "error": "invalid_grant",
  "error_description": "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."
}

2. Facebook login

POST /api/car_driver/fo_users/logins/facebook2

Parameters:

Parameter name Parameter type Description
facebook_access_token string access token returned by Facebook
client_app_id string application id provided by PARKING+PLUS
client_secret string application secret provided by PARKING+PLUS

Example:

{
  "facebook_access_token"     : facebook_user_access_token,
  "client_app_id" : "the_client_app_id",
  "client_secret" : "the_client_secret"
}

Then, you'll receive the access token back in the response:

Response:

# the same JSON response as from token/

Access_token should then be used in subsequent requests for authorization.
Including this HTTP header:

Authorization: Bearer 09ba487fc3df...

If the access_token has expired

POST /api/car_driver/token

using the refresh token and the "grand_type":"refresh_token"

Parameters:

Parameter name Parameter type Description
refresh_token string refresh token used for refreshing the expired access token
grant_type string grant_type="refresh_token"
{
  "grant_type"    : "refresh_token",
  "refresh_token": "ds0af717251950dbd4d73eefdf0a474a5c5119adad9993332f5b4fdsc4607266tgy"
}

Then, you'll receive the new access token and refresh token back in the response:

{
    "token_info": {
        "access_token": "c7876f24c47c57150007868b095f06a8c48cfdcfae3b697cf36e58de93a1a9a1",
        "refresh_token": "9bdd2d7a3c0023cb299798e62006983dca8bbf451b6caf5af4f45c5633619683",
        "token_type": "bearer",
        "expires_in": 7200
    },
    "last_payment_info": {
        "id": 69,
        "duration_minutes": 60,
        "start_time": "2015-09-15 11:14:28",
        "end_time": "2015-09-15 12:14:28",
        "pay_amount": "1.0",
        "duration_until_end_seconds": 3551,
        "car": {
            "id": 82,
            "plate_number": "SV90PPP",
            "is_default": true
        },
        "zone": {
            "id": 79,
            "name": "Bistrita Zone 2",
            "price": "1.0",
            "selected": false,
            "current_time": "2015-09-17 17:10:46"
        }
    },
    "account_info": {
        "email": "user@example.com",
        "first_name": "name",
        "last_name": "name",
        "phone": "0740000000",
        "birthdate": "2015-05-05 00:00:00",
        "gender": "",
        "newsletter": true,
        "image_url": null,
        "home_location": null,
        "work_location": null
    }
}