Web Services

Process Centric Services (SOAP)

initializeUser

Given a slack user id, and his username creates a new user in the system. Returns the id of the newly created user.

Parameters:

slack_user_id string
Slack Identifier
username string
Nickname to personalise messages

Output:

id integer
id that identifies the new user in the system.

Sample Input:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <initializeUser xmlns="http://ws.soap.processcentric.introsde/">
            <slack_user_id xmlns="">UF345DE</slack_user_id>
            <user_name xmlns="">dan.macri</user_name>
        </initializeUser>
    </Body>
</Envelope>

Sample Output:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:initializeUserResponse xmlns:ns2="http://ws.soap.processcentric.introsde/">
            <id>5</id>
        </ns2:initializeUserResponse>
    </S:Body>
</S:Envelope>

checkGoalStatus

Checks the goals status for a given slack user, identified by a slack_user_id. The user must be previously registered. The goal status tells how many goals he has met and how much he is missing for the others. The system will reward him with pictures, or motivate him with quotes.

Parameters:

slack_user_id string
Slack Identifier

Output:

goalStatusList Object containing a description of each goal, how much has been achieved, and until when the user has chance to accomplish it.
messages List of messages that should be displayed by the user interface.

Sample Input:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <checkGoalStatus xmlns="http://ws.soap.processcentric.introsde/">
            <slack_user_id xmlns="">UF345DE</slack_user_id>
        </checkGoalStatus>
    </Body>
</Envelope>

Sample Output:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:checkGoalStatusResponse xmlns:ns2="http://ws.soap.processcentric.introsde/">
            <goal>
                <messages>
                    <content>You haven't set any goals yet. We are sad. Maybe this can get you going?</content>
                    <type>text</type>
                </messages>
                <messages>
                    <content>https://scontent.cdninstagram.com/t51.2885-15/s640x640/sh0.08/e35/12568948_950354585078328_1256244383_n.jpg</content>
                    <type>image</type>
                </messages>
                <messages>
                    <content>"Be miserable. Or motivate yourself. Whatever has to be done, it's always your choice."
 -Wayne Dyer</content>
                    <type>quote</type>
                </messages>
            </goal>
        </ns2:checkGoalStatusResponse>
    </S:Body>
</S:Envelope>

updateRunInfo

Registers a new run. The user must provide distance, time, calories. Checks if any new goals were met with the run.

Parameters:

slack_user_id string
Slack Identifier
distance number
meters
moving_time number
seconds
calories number
kcal

Output:

messages List of messages that should be displayed by the user interface. Includes message in case a goal was met with the new run.

Sample Input:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <updateRunInfo xmlns="http://ws.soap.processcentric.introsde/">
            <slack_user_id xmlns="">UF345DE</slack_user_id>
            <distance xmlns="">4000</distance>
            <moving_time xmlns="">2800</moving_time>
            <calories xmlns="">340</calories>
        </updateRunInfo>
    </Body>
</Envelope>

Sample Output:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:updateRunInfoResponse xmlns:ns2="http://ws.soap.processcentric.introsde/">
            <person>
                <messages>
                    <content>Congratulations for your effort :D! Here's a little something to keep you going.</content>
                    <type>text</type>
                </messages>
                <messages>
                    <content>"He that is giddy thinks the world turns round.  "
 -William Shakespeare </content>
                    <type>quote</type>
                </messages>
            </person>
        </ns2:updateRunInfoResponse>
    </S:Body>
</S:Envelope>

setGoal {Params: Goal type, target, period}

Creates a new personal goal.

Parameters:

slack_user_id string
Slack Identifier
goal-type string
distance, time, or calories
target number
target value
period number
daily, weekly, monthly

Output:

messages Messages notifying the creation of the goal.

Sample Input:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <setGoal xmlns="http://ws.soap.processcentric.introsde/">
            <slack_user_id xmlns="">UF345DE</slack_user_id>
            <goal_type xmlns="">distance</goal_type>
            <target xmlns="">5000</target>
            <period xmlns="">daily</period>
        </setGoal>
    </Body>
</Envelope>

Sample Output:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:setGoalResponse xmlns:ns2="http://ws.soap.processcentric.introsde/">
            <person>
                <messages>
                    <content>Goal saved! That's great. Keep working and soon 5000.0 will seem like a walk in the park.</content>
                    <type>text</type>
                </messages>
            </person>
        </ns2:setGoalResponse>
    </S:Body>
</S:Envelope>

Business Logic Services (REST)

GET /goal-types

Gets all the valid goal types.

No input

Output:

status string
ERROR if there was a problem.
OK otherwise.
resuts
Array of Goal Type
Each string is a goal type.
error string
Message describing encountered errors.

GoalType object:

id string
Goal type name
name string
Goal pretty name (e.g. ‘distance’, ‘calories’).
units string
(e.g. ‘meters’, ‘kcal’).

Sample output:

{
        "status": "OK",
        "results": [
                {
                        "id": "distance",
                        "name": "Distance",
                        "units" "m"
                },
                {       "id": "calories",
                        "name": "Calories",
                        "units": "kcal"
                },
                {
                        "id": "max_speed",
                        "name": "Maximum speed",
                        "units": "m/s"
                }
        ]
}

GET /goal-types/<goal-type>

Gets the definition of a specific goal type.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
id string
name string
units string

Sample output:

{
        "status": "OK",
        "id": "max_speed",
        "name": "Maximum Speed",
        "units": "km/h"
}

GET /user-id/<slack-id>

Given a user’s slack id, returns the corresponding user id.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
id integer

Sample output:

{
        "status": "OK",
        "id": 5
}

GET /users/<user-id>/goal-status

Returns the status for all the user’s goals in the current period.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
goal_status Array of `GoalStatus`

GoalStatus object:

type string
Goal id
name string
Goal name (e.g. Distance, Max. Speed)
units string
target float
The ammount the user wants to achieve in total.
period string e.g. daily, weekly
period_start integer
UNIX timestamp millisec.
period_end integer
UNIX timestamp millisec.
goal_met boolean
count float
How much user already accumulated for goal.

Sample output:

{
        "status": "OK",
        "goal_status": [
                {
                        "type": "distance",
                        "name": "Distance",
                        "units": "m",
                        "target": 5000.00,
                        "period": "weekly",
                        "period_start": 1452941107,
                        "period_end": 1453545907,
                        "goal_met": false,
                        "count": 3500.00
                }
        ]
}

POST /users

Creates a new user

HTTP Status code: 200, 404 (Code not found)

Parameters

slack_user_id string

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample output:

{
        "status": "OK"
}

PUT /users/<user_id>

Performs a partial update on the user’s fields. Either his profile data, or his slack identifiers. Only the passed fields are updated. The user identified by <user_id> must already exist.

Parameters:

slack_user_id string
email string
firstname string
lastname string

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample output:

{
  "status": "OK"
}

Storage Services (REST)

GET /goal-types

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
results Array of GoalType

GoalType object:

id string
Goal type name
name string
Goal pretty name (e.g. ‘distance’, ‘calories’).
units string
(e.g. ‘meters’, ‘kcal’).

Sample output:

{
        "status": "OK",
        "results": [
                {
                        "id": "distance",
                        "name": "Distance",
                        "units" "m"
                },
                {       "id": "calories",
                        "name": "Calories",
                        "units": "kcal"
                },
                {
                        "id": "max_speed",
                        "name": "Maximum speed",
                        "units": "m/s"
                }
        ]
}

GET /goal-types/<goal-type>

Gets the definition of a specific goal type.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
id string
name string
units string

Sample output:

{
        "status": "OK",
        "id": "max_speed",
        "name": "Maximum Speed",
        "units": "km/h"
}

POST /users

Creates a new user in the database

Parameters:

slack_user_id string
Generated by Slack.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample output:

{
        "status": "OK"
}

PUT /users/<user_id>

Performs a partial update on the user’s fields. Either his profile data, or his slack identifiers. Only the passed fields are updated. The user identified by <user_id> must already exist.

Parameters:

slack_user_id string
email string
firstname string
lastname string

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample output:

{
  "status": "OK"
}

GET /user-id/<slack-id>

Given a user’s slack id, returns the corresponding user id.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
id integer

Sample output:

{
        "status": "OK",
        "id": 5
}

GET /users/<user-id>/runs?start_date=<date>

Gets all the recent runs for the specified user.

Query Parameters:

start_date integer
UNIX timestamp in milliseconds.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
runs Array of Run

Run object:

id integer
distance float
meters
calories float
kilocalories
start_date time string
moving_time integer
seconds
elevation_gain float
meters
max_speed float
meters per second
avg_speed float
meters per second

Sample output:

{
        "status": "OK",
        "runs": [
                {
                        "id": 2,
                        "distance": 5000,
                        "calories": 3000,
                        "start_date": 1454512708,
                        "moving_time": 1800,
                        "elevation_gain": 200,
                        "max_speed": 3,
                        "avg_speed": 2.5
                },
                ...
        ]
}

POST /users/<user-id>/runs

Calls Local Database Services to saves the passed run information.

Parameters:

distance float
meters
calories float
kilocalories
start_date time string
moving_time integer
seconds
elevation_gain float
meters
max_speed float
meters per second
avg_speed float
meters per second

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample input:

{
        "distance": 5000,
        "calories": 3000,
        "start_date": 1454512708,
        "moving_time": 1800,
        "elevation_gain": 200,
        "max_speed": 3,
        "avg_speed": 2.5
}

Sample output:

{
        "status": "OK"
}

GET /users/<user-id>/goals

Connects to LocalDatabaseService and gets all the goals for the user.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
goals Array of Goal

Goal object:

id integer
created integer
UNIX epoch timestamp in millisec.
target float
Target goal value.
period_days integer
How long does the period measure.
period string
(e.g. ‘weekly’, ‘daily’, ‘monthly’)
measure_type float
meters
units float
meters per second

Sample output:

{
        "status": "OK",
        "goals": [
                {
                        "id": 2,
                        "created": 1454512708,
                        "target": 5000.00,
                        "measure_type": "distance",
                        "name": "Distance",
                        "units": "m",
                        "period": "weekly",
                        "period_days": 7
                },
                ...
        ]
}

PUT /users/<user-id>/goals/<goal-type>

Sets a goal of the specified type for the specified user.

Parameters:

target float
Target goal value.
period string
(e.g. ‘weekly’, ‘daily’, ‘monthly’)

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample input:

{
        "target": 2000,
        "period": "daily"
}

Sample output:

{
        "status": "OK"
}

GET /pretty-pic

Connects to the adapterServices and returns 1 picture url.

Parameters:

tag string
Instagram tag to search for.

Output:

status string
ERROR if there was a problem.
OK otherwise.
picture Object
Picture with its url and thumbnail url
error string
Message describing encountered errors.
picture.url string
path to image.
picture.thumbUrl string
path to thumbnail.

Sample input:

{
        "tag": "tagName"
}

Sample output:

{
        "status": "OK",
        "picture":
                {
                        "url": "http://instagram.com/.../12dsfzH.jpg",
                        "thumbUrl": "http://instagram.com/.../12dsfzH.jpg"
                }
}

GET /motivation-quote

Connects to the adapterServices and returns 1 motivation quote.

No input

Output:

status string
ERROR if there was a problem.
OK otherwise.
resut Object
error string
Message describing encountered errors.
result.quote string
Authentication token
result.author Object
User profile

Sample output:

{
        "status": "OK",
        "result":
        {
                "quote":"There is time for everything, except for losing time.",
                "author":"Anonymous"
        }
}

Local Database Services (REST)

POST /users

Creates a new user in the database

Parameters:

slack_user_id string
Generated by Slack.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample output:

{
        "status": "OK"
}

PUT /users/<user_id>

Performs a partial update on the user’s fields. Either his profile data, or his slack identifiers. Only the passed fields are updated. The user identified by <user_id> must already exist.

Parameters:

slack_user_id string
email string
firstname string
lastname string

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample output:

{
        "status": "OK"
}

GET /goal-types

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
results Array of GoalType

GoalType object:

id string
Goal type name
name string
Goal pretty name (e.g. ‘distance’, ‘calories’).
units string
(e.g. ‘meters’, ‘kcal’).

Sample output:

{
        "status": "OK",
        "results": [
                {
                        "id": "distance",
                        "name": "Distance",
                        "units" "m"
                },
                {       "id": "calories",
                        "name": "Calories",
                        "units": "kcal"
                },
                {
                        "id": "max_speed",
                        "name": "Maximum speed",
                        "units": "m/s"
                }
        ]
}

GET /goal-types/<goal-type>

Gets the definition of a specific goal type.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
id string
name string
units string

Sample output:

{
        "status": "OK",
        "id": "max_speed",
        "name": "Maximum Speed",
        "units": "km/h"
}

GET /user-id/<slack-id>

Given the slack identifier of the user, returns the corresponding id used by this system to identify the user.

No input.

Output:

id integer

Sample output:

{
        "status": "OK",
        "id": 5
}

PUT /users/<user-id>/goals/<goal-type>

Sets a goal of the specified type for the specified user.

Parameters:

target float
Target goal value.
period string
(e.g. ‘weekly’, ‘daily’, ‘monthly’)

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample input:

{
        "target": 2000,
        "period": "daily"
}

Sample output:

{
        "status": "OK"
}

GET /users/<user-id>/goals

Gets all the goals for the specified user.

No input.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
goals Array of Goal

Goal object:

id integer
created integer
UNIX epoch timestamp in millisec.
target float
Target goal value.
period_days integer
How long does the period measure.
period string
(e.g. ‘weekly’, ‘daily’, ‘monthly’)
measure_type float
meters
units float
meters per second

Sample output:

{
        "status": "OK",
        "goals": [
                {
                        "id": 2,
                        "created": 1454512708,
                        "target": 5000.00,
                        "measure_type": "distance",
                        "name": "Distance",
                        "units": "m",
                        "period": "weekly",
                        "period_days": 7
                },
                ...
        ]
}

GET /users/<user-id>/runs?start_date=<date>

Gets all the recent runs for the specified user.

Query Parameters:

start_date integer
UNIX timestamp in millisec.

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.
runs Array of Run

Run object:

id integer
distance float
meters
calories float
kilocalories
start_date long
Timestamp in millisec.
moving_time integer
seconds
elevation_gain float
meters
max_speed float
meters per second
avg_speed float
meters per second

Sample output:

{
        "status": "OK",
        "runs": [
                {
                        "id": 2,
                        "distance": 5000,
                        "calories": 3000,
                        "start_date": 1454512708,
                        "moving_time": 1800,
                        "elevation_gain": 200,
                        "max_speed": 3,
                        "avg_speed": 2.5
                },
                ...
        ]
}

POST /users/<user-id>/runs

Saves the passed run information in the RUN_HISTORY table.

Parameters:

distance float
meters
calories float
kilocalories
start_date time string
moving_time integer
seconds
elevation_gain float
meters
max_speed float
meters per second
avg_speed float
meters per second

Output:

status string
ERROR if there was a problem.
OK otherwise.
error string
Message describing encountered errors.

Sample input:

{
        "distance": 5000,
        "calories": 3000,
        "start_date": 1454512708,
        "moving_time": 1800,
        "elevation_gain": 200,
        "max_speed": 3,
        "avg_speed": 2.5
}

Sample output:

{
        "status": "OK"
}

Adapter Services (REST)

GET /instagram-pics

Connects to instagram and gets latest pics that match a tag name.

Parameters:

tag string
Instagram tag to search for.
limit integer optional
Max images to retrieve. Default is 5.

Output:

status string
ERROR if there was a problem.
OK otherwise.
resuts Array of Images
error string
Message describing encountered errors.
results.url string
path to image.
results.thumbUrl string
path to thumbnail.

Sample input:

{
        "tag": "tagName",
        "limit": 5
}

Sample output:

{
        "status": "OK",
        "resultCount": 5,
        "results": [
                {
                        "url": "http://instagram.com/.../12dsfzH.jpg",
                        "thumbUrl": "http://instagram.com/.../12dsfzH.jpg"
                },
                ...
        ]
}

GET /motivation-quote

Gets a random inspirational quote.

No input

Output:

status string
ERROR if there was a problem.
OK otherwise.
resut Object
error string
Message describing encountered errors.
result.access_token string
Authentication token
result.athlete Object
User profile

Sample output:

{
        "status": "OK",
        "result":
        {
                "quote":"There is time for everything, except for losing time.",
                "author":"Anonymous"
        }
}