Example #1
0
 /**
  * Sends the client, product and appointment details to the API
  *
  * @param ClientContract $client
  * @param ProductContract|null $product
  * @param AppointmentContract|null $appointment
  * @return \Guzzle\Http\Message\Response
  */
 public function send(ClientContract $client, ProductContract $product = null, AppointmentContract $appointment = null)
 {
     $contentBody = [];
     if (empty($client)) {
         throw new \UnexpectedValueException('Client Details must be specified');
     }
     $contentBody['client'] = $client->toArray();
     if (!empty($product)) {
         $contentBody[$product->getKey()] = $product->toArray();
     }
     if (!empty($appointment)) {
         $contentBody['appointment'] = $appointment->toArray();
     }
     $result = $this->guzzleClient->post($this->url . "/" . $this->urn, null, empty($this->encryptor) ? $contentBody : $this->encryptor->encryptData(json_encode($contentBody)));
     return $result->send();
 }