{"id":68,"date":"2022-08-01T06:39:21","date_gmt":"2022-08-01T06:39:21","guid":{"rendered":"https:\/\/www.wellnessliving.com\/developer-portal\/?p=68"},"modified":"2024-10-29T19:16:07","modified_gmt":"2024-10-29T19:16:07","slug":"adding-a-new-client","status":"publish","type":"post","link":"https:\/\/www.wellnessliving.com\/developer-portal\/tutorials\/adding-a-new-client\/","title":{"rendered":"Adding a new client"},"content":{"rendered":"\n<p>Adding a new client to a business can be accomplished using two API calls.<\/p>\n\n\n\n<p>The first call retrieves a list of fields that need to be populated for a new client, such as name, email, and phone number. Each field and its respective key(s) must be identified. You can use the <span class=\"coding_type\">id_field_general<\/span> value to identify each key.&nbsp;<\/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=\"\">\/\/ To be used after signing in. \n$o_lead_model = new \\WellnessLiving\\Wl\\Lead\\LeadModel($o_config); \n$o_lead_model->cookieSet($o_notepad->cookieGet()); \/\/ Store cookies to maintain the session. \n$o_lead_model->k_business='3'; \n\n\/\/ Perform the request. \n$o_lead_model->get(); \nforeach($o_lead_model->a_field_list as $a_field) \n{ \n\u202fecho $a_field['k_field'].' '.$a_field['id_field_general'].' '.$a_field['text_field'].\"\\n\"; \n} <\/pre>\n<\/div>\n<\/div>\n\n\n\n<p>Once the fields are identified, they can be populated with the new client\u2019s information. The second call uses the <span class=\"coding_type\">post<\/span> method to create the new client.<\/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=\"\">\/\/ NotepadModel and EnterModel omitted for brevity. \n$o_lead_model = new \\WellnessLiving\\Wl\\Lead\\LeadModel($o_config); \n$o_lead_model->k_business='3'; \n\n\/\/ Perform the request. \n$o_lead_model->get(); \n$a_field_general = []; \nforeach($o_lead_model->a_field_list as $a_field) \n\u202f$a_field_general[$a_field['id_field_general']] = $a_field['k_field']; \n\n\/\/ Using k_field => value, create a new client. \n$o_lead_model->a_field_data = [ \n\u202f$a_field_general[WlFieldGeneralSid::NAME_FIRST] => 'First', \n\u202f$a_field_general[WlFieldGeneralSid::NAME_LAST] => 'Last', \n\u202f$a_field_general[WlFieldGeneralSid::LOGIN] => 'First@last.com', \n\u202f$a_field_general[WlFieldGeneralSid::PHONE_CELL] => '123-456-7890' \n]; \n$o_lead_model->post(); \necho 'User created with uid of '.$o_lead_model->uid.\"\\n\"; <\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Adding a new client to a business can be accomplished using two API calls. The first call retrieves a list of fields that need to be populated for a new client, such as name, email, and phone number. Each field and its respective key(s) must be identified. You can use the id_field_general value to identify [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26,7],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts\/68"}],"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=68"}],"version-history":[{"count":23,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":479,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/posts\/68\/revisions\/479"}],"wp:attachment":[{"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellnessliving.com\/developer-portal\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}