function it_send_message_to_user($client, Message $message, ResponseInterface $response)
 {
     $message->hasFileToUpload()->willReturn(false);
     $client->send('POST', '/me/messages', null, [], [], [RequestOptions::JSON => ['recipient' => ['id' => '1008372609250235'], 'message' => $message, 'notification_type' => NotificationType::REGULAR]])->willReturn($response);
     $response->getBody()->willReturn('
         {
             "recipient_id": "1008372609250235",
             "message_id": "mid.1456970487936:c34767dfe57ee6e339"
         }
     ');
     $this->sendMessage('1008372609250235', $message)->shouldBeLike(new MessageResponse('1008372609250235', 'mid.1456970487936:c34767dfe57ee6e339'));
 }
 /**
  * @param string $recipientOrPhone
  * @param Message $message
  * @param string $notificationType
  *
  * @return array
  */
 public static function createForMessage($recipientOrPhone, Message $message, $notificationType = NotificationType::REGULAR)
 {
     $options = [];
     $data = ['recipient' => self::createRecipientField($recipientOrPhone), 'message' => $message, 'notification_type' => $notificationType];
     if ($message->hasFileToUpload()) {
         // Create a multipart request
         $options[RequestOptions::MULTIPART] = [['name' => 'recipient', 'contents' => json_encode($data['recipient'])], ['name' => 'message', 'contents' => json_encode($data['message'])], ['name' => 'notification_type', 'contents' => $data['notification_type']], ['name' => 'filedata', 'contents' => $message->getFileStream()]];
         // Update timeout if we upload a file
         $options['timeout'] = Client::DEFAULT_FILE_UPLOAD_TIMEOUT;
         return $options;
     }
     $options[RequestOptions::JSON] = $data;
     return $options;
 }
 function it_should_a_json_option_for_message(Message $message)
 {
     $message->hasFileToUpload()->willReturn(false);
     $this::createForMessage('rid', $message, 'notif')->shouldReturn([RequestOptions::JSON => ['recipient' => ['id' => 'rid'], 'message' => $message, 'notification_type' => 'notif']]);
 }