Adding a new client
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 each key.
// To be used after signing in. $o_lead_model = new \WellnessLiving\Wl\Lead\LeadModel($o_config); $o_lead_model->cookieSet($o_notepad->cookieGet()); // Store cookies to maintain the session. $o_lead_model->k_business='3'; // Perform the request. $o_lead_model->get(); foreach($o_lead_model->a_field_list as $a_field) { echo $a_field['k_field'].' '.$a_field['id_field_general'].' '.$a_field['text_field']."\n"; }
Once the fields are identified, they can be populated with the new client’s information. The second call uses the post method to create the new client.
// NotepadModel and EnterModel omitted for brevity. $o_lead_model = new \WellnessLiving\Wl\Lead\LeadModel($o_config); $o_lead_model->k_business='3'; // Perform the request. $o_lead_model->get(); $a_field_general = []; foreach($o_lead_model->a_field_list as $a_field) $a_field_general[$a_field['id_field_general']] = $a_field['k_field']; // Using k_field => value, create a new client. $o_lead_model->a_field_data = [ $a_field_general[WlFieldGeneralSid::NAME_FIRST] => 'First', $a_field_general[WlFieldGeneralSid::NAME_LAST] => 'Last', $a_field_general[WlFieldGeneralSid::LOGIN] => 'First@last.com', $a_field_general[WlFieldGeneralSid::PHONE_CELL] => '123-456-7890' ]; $o_lead_model->post(); echo 'User created with uid of '.$o_lead_model->uid."\n";