Manage Your Health and Share Information with the CarePass Plug-in

Posted: April 22nd, 2013 | Author: | Filed under: API, Plugin | Tags: , | Comments Off

img_CarePassSync

CarePass Sync is a secure personal health, wellness, and nutrition cloud created for all consumers. It enables users to consolidate their data from all of the CarePass Sync enabled apps that they use in a single location.

We’ve just made the CarePass plug-in available. You can log in to the consumer-facing https://www.carepass.com to view your CarePass profile and update or add information. Your profile will contain the aggregated information from all of the CarePass-enabled apps that you use.

Our CarePass Sync API Plug-in uses fitness and body measurement categories from the list available on CarePass Sync and allows you to add your own activities and body measurements. Also, you can look over your activities and body measurements and use filters to get information by type and date range of activity or body measurement.

Adding the CarePass Sync API Plug-in to Your App

To add this plug-in to an app, you will just need to follow these steps in Appery.io:

  1. From the Appery.io builder, select Create New and then From Plug-in.
  2. Click the check box for the CarePass Sync API, and then click on the Import selected plugins button.
  3. Open Services/CarePass_ServicesSettings file and set your API keys.

How to Get API Keys

To run the app you need to register a new account on https://developer.carepass.com, create a new application, and get the keys, Key and Shared Secret.

cp01

In Appery.io, go to Services -> CarePass_ServicesSetting and enter the keys in the appropriate fields:

cp02

Set the following values:
CarepassSync → set to the Key value from https://developer.carepass.com,
ClientSecret → set to the Shared Secret value from https://developer.carepass.com
ProjectURI → set this value by clicking Test, unchecking Show in mobile frame option, and getting the link:

cp03

The Sample App

To  use the sample app, follow these steps:

  1. On the start page, log in with your CarePass account.
  2. You can then control your external or internal measurements:
    cp40 cp41
    or input new measurements:
    cp42
  3. You can also look at your activities or add a new activity:
    cp43 cp44
  4. Using the app you can also retrieve and update your user information.

Under the Hood

Now that we’ve walked through the app, let’s take a peek under the hood.

Services

Services from the plug-in are linked to UI components as part of the design of the app. The following REST services that are defined in the CarePass Sync API plug-in are used in the app.

CarePass_GetAccessToken

The CarePass_GetAccessToken service is used to get Access Token during the authorization.
REST Service Properties displays the URL, main settings, and whether a proxy is used as shown below:

cp51

Request Parameters contains the parameters sent to CarePass service:

cp52

{CarepassSync}, {ClientSecret}, {ProjectURI} parameter values are set in the CarePass_ServicesSetting.

The service can be instantly tested and the response created automatically on the return response. Response parameters are shown below:

cp53

The other services are set in the same way with their own parameters.

CarePass_CurrentUser_GET

The CarePass_CurrentUser_GET service is used for getting personal information of the logged in user such as e-mail, first name, last name etc.

cp54

Request Parameters:

cp55

cp06

Response Parameters are automatically set after testing on the Test tab:

cp56

CarePass_Fitness_Activity_POST

The CarePass_Fitness_Activity_POST service is used for adding a new activity.

cp57

Request Parameters:

cp58

Description of the Request Parameters you can find on https://developer.carepass.com/docs/read/carepass/fitness/Activities_POST.

CarePass_Fitness_AllActivities_GET

The CarePass_Fitness_AllActivities_GET service retrieves the Activities data for the current user. The Settings tab:

cp59

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/fitness/activities

Request Parameters are shown below. Description you can find on https://developer.carepass.com/docs/read/carepass/fitness/Activities_GET.

cp60

Response Parameters:

cp61

CarePass_Fitness_ActivitiesFilter_GET

The CarePass_Fitness_ActivitiesFilter_GET service retrieves the Activities data for the current user for the given date range and type. The Settings tab:

cp62

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/fitness/activities
Request Parameters and their description are shown below:

cp63 cp13

Response Parameters:

cp64

CarePass_BodyMeasurements_Latest_GET

The CarePass_BodyMeasurements_Latest_GET service returns a list of the latest recorded body measurements (if available) for each of the measurement Types. This list can be further limited based on the measurement type. The Settings tab:

cp65

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/health/body/measurements/latest.

Request Parameters and their description are shown below:

cp66 cp17

Response Parameters are automatically set after testing on the Test tab:

cp67

CarePass_BodyMeasurements_Filter_GET

The CarePass_BodyMeasurements_Filter_GET service returns body measurements for the current user. This list limited based on the measurement type and date range. The Settings tab:

cp68

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/health/body/measurements.
Request Parameters and their description are shown below:

cp69 cp21

Response Parameters are automatically set after testing on the Test tab:

cp70

CarePass_BodyMeasurements_POST

The CarePass_BodyMeasurements_POST service is used for creating new Body Measurements. The Settings tab is shown below:

cp71

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/health/body/measurements

Request Parameters are shown below. Description is at https://developer.carepass.com/docs/read/carepass/body/health_body_measurements_POST

cp72

Response Parameters are automatically after testing on the Test tab:

cp73

CarePass_Fitness_Activity_Id_GET

The CarePass_Fitness_Activity_Id_GET service retrieves the Activities data for the current user for the given activity id. The Settings tab is shown below:

cp77

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/fitness/activities/{id}

Request Parameters and description are shown below:

cp78

cp28

Response Parameters are automatically set after testing on the Test tab:

cp79

CarePass_BodyMeasurements_Id_GET

The CarePass_BodyMeasurements_Id_GET service returns a specific body measurement entry. The Settings tab is shown below:

cp74

URL parameter: https://api.carepass.com/user-directory-api/users/currentUser/fitness/activities/{id}
Request Parameters and their descriptions are shown below:

cp75

cp32

Response Parameters:

cp76

Mapping the UI to the Services

One of the most important  part in the app design is mapping service to UI components. Here we will show you some examples of mapping for every page.

CarePass_Login

There are two services added to the CarePass_Login page:

cp80

CarePass_GetAccessToken needs the following mappings:

cp81cp82

CarePass_CurrentUser_GET needs the following mapping:

cp83cp84

CarePass_BodyMeasurements_New

There are two services added to the CarePass_BodyMeasurements_New page:

cp85

CarePass_BodyMeasurements_POST needs the following mapping:

cp87 cp86

CarePass_Measurement_query_service needs the following mapping:

cp89 cp88

CarePass_BodyMeasurements_Single

There is one service added to the CarePass_BodyMeasurements_Single page:

cp90

CarePass_BodyMeasurements_Id_GET needs the following mapping:

cp91cp92

CarePass_BodyMeasurementsType_Filter

There are two services added to the CarePass_BodyMeasurementsType_Filter page:

cp93

CarePass_BodyMeasurements_Latest_GET needs the following mapping:

cp95 cp94

CarePass_BodyMeasurements_Filter_GET needs the following mapping:

cp97 cp96

CarePass_Fitness_Activity_All

There is one service added to the CarePass_Fitness_Activity_All page:

cp98

CarePass_Fitness_AllActivities_GET needs the following mapping:

cp39 cp99

JavaScript

The CarePass_Login JS coding is used for authentication and authorization process.

cp46