{"id":56,"date":"2022-08-01T06:31:19","date_gmt":"2022-08-01T06:31:19","guid":{"rendered":"https:\/\/www.wellnessliving.com\/developer-portal\/?p=56"},"modified":"2024-10-29T19:04:43","modified_gmt":"2024-10-29T19:04:43","slug":"installing-the-sdk","status":"publish","type":"post","link":"https:\/\/www.wellnessliving.com\/developer-portal\/getting-started\/installing-the-sdk\/installing-the-sdk\/","title":{"rendered":"Installing the SDK"},"content":{"rendered":"\n<p>The WellnessLiving software development kit (SDK) can be installed like any other SDK. It has been tested with PHP 5.5 and above. If you\u2019re experiencing any issues with a PHP version that should be compatible with our SDK, please reach out using the <a href=\"https:\/\/www.wellnessliving.com\/developer-portal\/contact-us\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\">Contact us<\/a> page..<\/p>\n\n\n\n<p>When installing the SDK, it\u2019s important not to alter the internal directory structure of the SDK.<\/p>\n\n\n\n<h2>Downloading the SDK<\/h2>\n\n\n\n<p>To download the SDK, visit WellnessLiving\u2019s GitHub repository at <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\" target=\"_blank\" rel=\"noreferrer noopener\">github.com\/wellnessliving\/wl-sdk<\/a>. You can download our SDK as a ZIP file.<\/p>\n\n\n\n<h2>Configuring the SDK<\/h2>\n\n\n\n<p>Once you\u2019ve downloaded the SDK, we recommend storing it somewhere that&#8217;s easy for you to access frequently.<\/p>\n\n\n\n<p>To get started, you&#8217;ll need the following pieces of information:<\/p>\n\n\n\n<ul><li>Your <strong>authorization code<\/strong> and <strong>ID<\/strong>, which are set in <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-config.php\" target=\"_blank\" rel=\"noreferrer noopener\">example-config.php<\/a>.<\/li><li>Your <strong>username<\/strong>, <strong>password<\/strong>, and business ID (<strong>BID<\/strong>), which are set in <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-sdk.php\" target=\"_blank\" rel=\"noreferrer noopener\">example-sdk.php<\/a>. The username and password are values used in the <a href=\"#_Testing_the_SDK\" target=\"_blank\" rel=\"noreferrer noopener\">example call<\/a> to the <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/092b86f74316251a5ec78dca852de7a84450a2a3\/WellnessLiving\/Core\/Passport\/Login\/Enter\/EnterModel.php\" target=\"_blank\" rel=\"noreferrer noopener\">EnterModel<\/a> endpoint, and the BID is used in the call to the <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/041e7fc6cbf7c8126fc7cbbfe54e1f602c83dc24\/WellnessLiving\/Wl\/Report\/DataModel.php\" target=\"_blank\" rel=\"noreferrer noopener\">DataModel<\/a> endpoint.<\/li><\/ul>\n\n\n\n<p>The <span class=\"coding_type\">uid<\/span> value isn\u2019t used in this example, but it\u2019s relevant for many other calls and should be noted for later.<\/p>\n\n\n\n<p>To <a href=\"#_Testing_the_SDK\">run the SDK test example<\/a> call, ensure that you\u2019ve edited <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-config.php\" target=\"_blank\" rel=\"noreferrer noopener\">example-config.php<\/a> and <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-sdk.php\" target=\"_blank\" rel=\"noreferrer noopener\">example-sdk.php<\/a> to include your credentials, as your username must be set in both files.<\/p>\n\n\n\n<p><div class=\"note\"><strong>Note<\/strong>When performing your first SDK call, don&#8217;t forget to update the <span class=\"coding_type\">dt_date<\/span> value in the <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/041e7fc6cbf7c8126fc7cbbfe54e1f602c83dc24\/WellnessLiving\/Wl\/Report\/DataModel.php\" target=\"_blank\" rel=\"noreferrer noopener\">DataModel<\/a> endpoint (a placeholder date is included in MySQL format).<\/div><\/p>\n\n\n\n<h2>Testing the SDK example call<\/h2>\n\n\n\n<p>The SDK includes an example call that retrieves a copy of the <a rel=\"noreferrer noopener\" href=\"https:\/\/www.wellnessliving.com\/knowledge-sharing\/knowledge-base\/all-sales-report\/\" target=\"_blank\">All Sales Report<\/a> 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.<\/p>\n\n\n\n<p>Sample invocation on the command line:<\/p>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<!-- HTML generated using hilite.me --><div style=\"background: #000000; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .1em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #cccccc\">php example-sdk.php<\/span>\n<\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p>Sample output (simulated data from a business):<\/p>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<!-- HTML generated using hilite.me --><div style=\"background: #000000; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .1em;padding:.2em .6em;\"><pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #cccccc\">1. 2022-12-08 45.45 Mike Roberts 1 Year Appointment Membership<\/span>\n<span style=\"color: #cccccc\">2. 2022-12-15 20.20 Jose Sanchez 1 Month Appointment Membership<\/span>\n<span style=\"color: #cccccc\">3. 2022-12-16 75.00 Jerome Cartier 5 Class Membership<\/span>\n<span style=\"color: #cccccc\">4. 2022-12-16 10.00 Jerome Cartier Soap (Red)<\/span>\n<span style=\"color: #cccccc\">5. 2022-12-16 20.20 Jerome Cartier Towel<\/span>\n<span style=\"color: #cccccc\">6. 2022-12-18 75.00 Joe Johnson 5 Class Membership<\/span>\n<span style=\"color: #cccccc\">7. 2022-12-20 75.00 Lily Lexington 5 Class Membership<\/span>\n<span style=\"color: #cccccc\">8. 2022-12-20 50.00 Chuck Liddell 3 Month Appointment Membership<\/span>\n<span style=\"color: #cccccc\">9. 2022-12-20 200.00 Chuck Liddell 20 Class Membership<\/span>\n<span style=\"color: #cccccc\">10. 2022-12-21 75.00 Jerome Cartier 5 Class Membership<\/span>\n<span style=\"color: #cccccc\">11. 2022-12-21 20.00 Jerome Cartier 10 Class Pass<\/span>\n<span style=\"color: #cccccc\">12. 2022-12-21 20.20 Jerome Cartier Towel<\/span>\n<span style=\"color: #cccccc\">13. 2022-12-24 75.00 Laura Ross 5 Class Membership<\/span>\n<span style=\"color: #cccccc\">14. 2022-12-25 75.00 Laura Ross 5 Class Membership<\/span>\n<span style=\"color: #cccccc\">15. 2022-12-29 50.00 Denise Williams 1 on 1 Personal Training<\/span>\n<span style=\"color: #cccccc\">16. 2022-12-29 20.00 Anna Sanchez Kickboxing: Online<\/span>\n<span style=\"color: #cccccc\">17. 2022-12-29 25.00 Anna Sanchez Crossfit Training<\/span>\n<span style=\"color: #cccccc\">18. 2022-12-29 20.00 Anna Sanchez Ballet: Beginner<\/span>\n<span style=\"color: #cccccc\">19. 2022-12-29 50.00 Denise Williams 1 on 1 Personal Training<\/span>\n<span style=\"color: #cccccc\">20. 2022-12-29 15.15 Denise Williams Towel<\/span>\n<span style=\"color: #cccccc\">21. 2022-12-29 20.00 Denise Williams Private Group Bhangra Dance<\/span>\n<\/pre><\/div>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2>Understanding the SDK example call<\/h2>\n\n\n\n<p>The <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-sdk.php\" target=\"_blank\">example-sdk.php<\/a> file is used for this SDK example call.<\/p>\n\n\n\n<p>There are three main parts of the example code: <\/p>\n\n\n\n<ul><li>Signing in a user to the system<\/li><li>Executing the request<\/li><li>Using the result<\/li><\/ul>\n\n\n\n<p>In most cases, you&#8217;ll need to be signed in to use the SDK. Your SDK access relates to your user privileges. For instance, a user who&#8217;s an employee of one business can\u2019t change classes for another business.<\/p>\n\n\n\n<p>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 specific users. Note that some endpoints don&#8217;t require access or authentication. In such cases, you won\u2019t need to be signed in as a user to run those endpoints.<\/p>\n\n\n\n<p>For the example code below, you\u2019ll need access to the <a href=\"https:\/\/www.wellnessliving.com\/knowledge-sharing\/knowledge-base\/all-sales-report\/\" target=\"_blank\" rel=\"noreferrer noopener\">All Sales Report<\/a> in WellnessLiving. You can use either the user credentials given with the SDK or the credentials of a staff member with access to reports.<\/p>\n\n\n\n<p>The first step when signing in is to select the server region you want to use. For your Staging business, you&#8217;ll automatically use the North Virginia (United States) region. When signing in with your Production credentials for the first time, <a href=\"#_Contact_us\" target=\"_blank\" rel=\"noreferrer noopener\">contact us<\/a> to determine whether you should be using the North Virginia (United States) or New South Wales (Australia) region.<\/p>\n\n\n\n<p>To sign in to the system, you must create a Notepad object to establish a session. You can then hit the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/092b86f74316251a5ec78dca852de7a84450a2a3\/WellnessLiving\/Core\/Passport\/Login\/Enter\/EnterModel.php\" target=\"_blank\">EnterModel<\/a> endpoint with your WellnessLiving username and encrypted password. This allows us to set and use a cookie to perform full authentication with the password.<\/p>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">  $o_config=ExampleConfig::create(WlRegionSid::US_EAST_1);\n  \/\/ Retrieve the notepad string (this is a separate step in the user sign-in process).\n  $o_notepad=new NotepadModel($o_config);\n  $o_notepad->get();\n\n  \/\/ Sign in the user.\n  $o_enter=new EnterModel($o_config);\n  $o_enter->cookieSet($o_notepad->cookieGet()); \/\/ Store cookies to maintain the session.\n  $o_enter->s_login='\/** Put your login here *\/';\n  $o_enter->s_notepad=$o_notepad->s_notepad;\n  $o_enter->s_password=$o_notepad->hash('\/** Put your password here *\/');\n  $o_enter->post();<\/pre>\n\n\n\n<p>After you\u2019ve signed in, you can begin creating the <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/4a919efe7d18e8403639c4c94600205719f9805b\/WellnessLiving\/Wl\/Business\/DataModel.php\" target=\"_blank\">DataModel<\/a> object necessary to retrieve the report data. You&#8217;ll need to set four values to specify the report you want, along with the day, week, or month for which you want it. Once all values are set, use the <span class=\"coding_type\">get<\/span> method to call the object. <\/p>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$o_report=new DataModel($o_config);\n$o_report->cookieSet($o_notepad->cookieGet()); \/\/ Store cookies to maintain the session.\n$o_report->id_report_group=WlReportGroupSid::DAY;\n$o_report->id_report=WlReportSid::PURCHASE_ITEM_ACCRUAL_CASH;\n$o_report->k_business='2149'; \/\/ Put your business key here.\n$o_report->filterSet([\n  'dt_date' => '2018-08-21'\n]);\n$o_report->get();<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<p>The example writes all the report\u2019s information to the screen. Different calls will return data in various formats, so it\u2019s important to check the documentation for details and test thoroughly.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$i=0;\nforeach($o_report->a_data['a_row'] as $a_row)\n{\n  $i++;\n  echo $i.'. '.$a_row['dt_date'].' '.$a_row['f_total']['m_amount'].' '.$a_row['o_user']['text_name'].' '.$a_row['s_item'].\"\\r\\n\";\n}<\/pre>\n\n\n\n<p>The SDK uses exceptions to communicate when an error has occurred. In this example, exceptions are printed to the screen.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">catch(WlAssertException $e)\n{\n  echo $e;\n  return;\n}\ncatch(WlUserException $e)\n{\n  echo $e->getMessage().\"\\n\";\n  return;\n}<\/pre>\n\n\n\n<h2>Using the SDK on different servers<\/h2>\n\n\n\n<p>WellnessLiving maintains two development servers and two production server clusters.<\/p>\n\n\n\n<p>The two development servers are <a href=\"https:\/\/demo.wellnessliving.com\/\">demo.wellnessliving.com<\/a>, where our newest code is tested and <a href=\"https:\/\/staging.wellnessliving.com\/\">staging.wellnessliving.com<\/a>, which has a more stable set of changes.<\/p>\n\n\n\n<p>Our two production server clusters are <a href=\"https:\/\/us.wellnessliving.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">us.wellnessliving.com<\/a> and <a href=\"https:\/\/au.wellnessliving.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">au.wellnessliving.com<\/a>. 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.<\/p>\n\n\n\n<p>We strive to make calls between the different servers as consistent as possible, but there are small differences regarding how calls to different servers are made. All our servers use HTTPS.<\/p>\n\n\n\n<p>Keep in mind that when moving to a different server, identifiers, keys, and code will differ.<\/p>\n\n\n\n<h3>Setting Demo or Staging configurations<\/h3>\n\n\n\n<p>The default <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-config.php\">example-config.php<\/a> contains the following lines:<\/p>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use WellnessLiving\\Config\\WlConfigDeveloper;\n\nclass ExampleConfig extends WlConfigDeveloper<\/pre>\n\n\n\n<p>This lets us know <a href=\"https:\/\/github.com\/wellnessliving\/wl-sdk\/blob\/master\/example-config.php\">example-config.php<\/a> is set up to use the Demo and Staging servers. If you want to make calls to one of the Production servers, use the following code:<\/p>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\">\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">use WellnessLiving\\Config\\WlConfigProduction;\n\nclass ExampleConfig extends WlConfigProduction<\/pre>\n\n\n\n<p><\/p>\n<\/div>\n<\/div>\n\n\n\n<h3>Configuring API calls<\/h3>\n\n\n\n<p>To configure your API calls to work with a different server, you\u2019ll need to update the URL and the names of the cookies used. WellnessLiving uses both a persistent and a transient cookie to maintain sessions. These cookies are typically abbreviated using the first letter of the server and the type of cookie. For example, on the demo server, the persistent cookie is named <em>dp<\/em>. On the Asia Pacific cluster, the transient cookie is named <em>at<\/em>.<\/p>\n\n\n\n<p>For more information about cookies used by WellnessLiving, see <a href=\"#_Cookies\">Cookies<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table><tbody><tr><td><strong>Server Name<\/strong><strong><\/strong><\/td><td><strong>Server URL<\/strong><strong><\/strong><\/td><td><strong>Cookie Names<\/strong><strong><\/strong><\/td><\/tr><tr><td>Development, Demo<\/td><td><a href=\"https:\/\/demo.wellnessliving.com\/\">demo.wellnessliving.com<\/a><\/td><td><em>dp<\/em>, <em>dt<\/em><\/td><\/tr><tr><td>Development, Staging<\/td><td><a href=\"https:\/\/staging.wellnessliving.com\/\">staging.wellnessliving.com<\/a><\/td><td><em>sp<\/em>, <em>st<\/em><\/td><\/tr><tr><td>Production, North America<\/td><td><a href=\"https:\/\/us.wellnessliving.com\/\">us.wellnessliving.com<\/a><\/td><td><em>p<\/em>, <em>t<\/em><\/td><\/tr><tr><td>Production, Asia Pacific<\/td><td><a href=\"https:\/\/au.wellnessliving.com\/\">au.wellnessliving.com<\/a><\/td><td><em>ap<\/em>, <em>at<\/em><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<div class=\"wp-block-columns\">\n<div class=\"wp-block-column\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The WellnessLiving software development kit (SDK) can be installed like any other SDK. It has been tested with PHP 5.5 and above. If you\u2019re experiencing any issues with a PHP version that should be compatible with our SDK, please reach out using the Contact us page.. When installing the SDK, it\u2019s important not to alter [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts\/56"}],"collection":[{"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/comments?post=56"}],"version-history":[{"count":56,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts\/56\/revisions"}],"predecessor-version":[{"id":478,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts\/56\/revisions\/478"}],"wp:attachment":[{"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/media?parent=56"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/categories?post=56"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/tags?post=56"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}