Home /Getting started/Installing the SDK
Installing the SDK

The WellnessLiving software development kit (SDK) can be installed like any other SDK. The SDK has been tested with PHP 5.5 and above. Please contact us using the Contact us page if you’re experiencing any issues with a PHP version that should be compatible with our SDK.

Also, when installing the SDK, it’s important not to alter the internal directory structure of the SDK.

Downloading the SDK

To download the SDK, visit WellnessLiving’s GitHub repository at: https://github.com/wellnessliving/wl-sdk. On the GitHub page, you can download our SDK as a zip file.

Configuring the SDK

Once you’ve downloaded the SDK, we recommend storing it somewhere that will be easy for you to access frequently.

We’ll send you six pieces of information that you’ll need to start making API calls:

  • The authorization code and ID are set in example-config.php.
  • The username, password, and business ID (BID) are set in example-sdk.php. Username and password are values used in the example call to the EnterModel endpoint and the BID is used in the call to the DataModel endpoint.
  • The last value, uid, isn’t used in this example, but it’s used in many other calls and it should be noted for later.

To run the SDK test example call, ensure that you’ve edited example-config.php and example-sdk.php to include your credentials, as your username must be set in these two places.

NoteWhen performing your first SDK call, don’t forget to update the dt_date value in the DataModel endpoint. A placeholder date has been included in MySQL format.

Testing the SDK example call

The SDK includes an example call that will get a copy of the All Sales Report for your Staging business. The example should run with no warnings or errors, outputting all information for the current month. Each report is structured like a spreadsheet, with every line item represented by a new row. If your business is new, the example call may return zero rows.

Sample invocation on the command line:

php example-sdk.php

Sample output (simulated data from a business):

1. 2022-12-08 45.45 Mike Roberts 1 Year Appointment Membership
2. 2022-12-15 20.20 Jose Sanchez 1 Month Appointment Membership
3. 2022-12-16 75.00 Jerome Cartier 5 Class Membership
4. 2022-12-16 10.00 Jerome Cartier Soap (Red)
5. 2022-12-16 20.20 Jerome Cartier Towel
6. 2022-12-18 75.00 Joe Johnson 5 Class Membership
7. 2022-12-20 75.00 Lily Lexington 5 Class Membership
8. 2022-12-20 50.00 Chuck Liddell 3 Month Appointment Membership
9. 2022-12-20 200.00 Chuck Liddell 20 Class Membership
10. 2022-12-21 75.00 Jerome Cartier 5 Class Membership
11. 2022-12-21 20.00 Jerome Cartier 10 Class Pass
12. 2022-12-21 20.20 Jerome Cartier Towel
13. 2022-12-24 75.00 Laura Ross 5 Class Membership
14. 2022-12-25 75.00 Laura Ross 5 Class Membership
15. 2022-12-29 50.00 Denise Williams 1 on 1 Personal Training
16. 2022-12-29 20.00 Anna Sanchez Kickboxing: Online
17. 2022-12-29 25.00 Anna Sanchez Crossfit Training
18. 2022-12-29 20.00 Anna Sanchez Ballet: Beginner
19. 2022-12-29 50.00 Denise Williams 1 on 1 Personal Training
20. 2022-12-29 15.15 Denise Williams Towel
21. 2022-12-29 20.00 Denise Williams Private Group Bhangra Dance

Understanding the SDK example call

We’ll be discussing as part of the SDK example call is the example-sdk.php file.

There are three main parts of the example code: signing a user in to the system, executing the request, and using the result. Error handling will also be shown. To use the SDK, a user will generally need to be signed in. SDK access is limited depending on who’s signed in as the user. For instance, an employee of Business A can’t change the classes of Business B.

SDK calls can be made for clients and staff members. These two user groups can be used if you need to limit the data returned or options presented to specified users. Note that some endpoints don’t require access or authentication. In such cases, you won’t need to be signed in as a user to run those endpoints.

For the example code, you’ll need a user who can access the All Sales Report in WellnessLiving. You can use either the user credentials given with the SDK or the credentials of a staff member with access to reports.

The first step when signing in is to select the server region you want to use. For your Staging business, you’ll automatically use the North Virginia (United States) region. When signing in using your Production credentials for the first time, contact us to determine if you should be using the North Virginia (United States) or New South Wales (Australia) region.

To sign in to the system, you must create a Notepad object to create a session to allow you to sign in. you can then contact the EnterModel endpoint with your WellnessLiving username and encrypted password. With this, we can set and use a cookie to perform a full authentication with the password.

  $o_config=ExampleConfig::create(WlRegionSid::US_EAST_1);
  // Retrieve the notepad string (this is a separate step of user sign in process).
  $o_notepad=new NotepadModel($o_config);
  $o_notepad->get();

  // Sign in a user.
  $o_enter=new EnterModel($o_config);
  $o_enter->cookieSet($o_notepad->cookieGet()); // Keep cookies to keep session.
  $o_enter->s_login='/** Put your login here */';
  $o_enter->s_notepad=$o_notepad->s_notepad;
  $o_enter->s_password=$o_notepad->hash('/** Put your password here */');
  $o_enter->post();

After you’ve signed in, you can begin creating the DataModel object necessary to get the report data. You’ll have to set four values to specify the report you want, along with the day, week, or month for which you want it. Once all the values are set, the get() method is called on the object. All our SDK endpoints have at least one method that corresponds to the applicable HTTP method (see HTTP methods). The HTTP method used will indicate what type of operation is performed. In this case, get() means we’ll be retrieving information.

$o_report=new DataModel($o_config);
$o_report->cookieSet($o_notepad->cookieGet()); // Keep cookies to keep session.
$o_report->id_report_group=WlReportGroupSid::DAY;
$o_report->id_report=WlReportSid::PURCHASE_ITEM_ACCRUAL_CASH;
$o_report->k_business='2149'; // Put your business key here.
$o_report->filterSet([
  'dt_date' => '2018-08-21'
]);
$o_report->get();

The example writes all the report’s information to the screen. Different calls will return data in different formats, so it’s important to check the documentation for details and test thoroughly.

$i=0;
foreach($o_report->a_data['a_row'] as $a_row)
{
  $i++;
  echo $i.'. '.$a_row['dt_date'].' '.$a_row['f_total']['m_amount'].' '.$a_row['o_user']['text_name'].' '.$a_row['s_item']."\r\n";
}

The SDK uses exceptions to communicate when an error has occurred. In the example, exceptions are printed to the screen.

catch(WlAssertException $e)
{
  echo $e;
  return;
}
catch(WlUserException $e)
{
  echo $e->getMessage()."\n";
  return;
}

Using the SDK on different servers

WellnessLiving maintains two development servers and two production server clusters.

The two development servers are demo.wellnessliving.com, where our newest code is tested and staging.wellnessliving.com, which has a more stable set of changes.

Our two production server clusters are us.wellnessliving.com and au.wellnessliving.com. These server clusters are used for the United States cluster located in Virginia (United States) and the Asia Pacific cluster located in New South Wales (Australia), respectively.

We try and make calls between the different servers as consistent as possible, but there are small differences with respect to how calls to different servers are made. All our servers use HTTPS.

Keep in mind that when moving to a different server identifiers, keys and code will differ.

Setting Demo or Staging configurations

The default example-config.php contains the following lines:

use WellnessLiving\Config\WlConfigDeveloper;

class ExampleConfig extends WlConfigDeveloper

This lets us know example-config.php is set up to use the Demo and Staging servers. If you wanted to make calls to one of the Production servers, you’d just need to change those lines to the following:

use WellnessLiving\Config\WlConfigProduction;

class ExampleConfig extends WlConfigProduction

Configuring API calls

To configure your API calls to work with a different server, you’ll need to change the URL of the name of the cookies extracted. WellnessLiving uses a persistent and a transient cookie to maintain a session. The names of these cookies are typically abbreviated using the first letter of the server and the cookie type. The persistent cookie on demo is dp and the transient cookie on the Asia Pacific cluster is at.

For more information about cookies used by WellnessLiving, see Cookies.

Server NameServer URLCookie Names
Development, Demodemo.wellnessliving.comdp, dt
Development, Stagingstaging.wellnessliving.comsp, st
Production, North Americaus.wellnessliving.comp, t
Production, Asia Pacificau.wellnessliving.comap, at