Beispiel #1
0
 /**
  * Return a stream of the local file attachment
  *
  * @return resource|null
  */
 public function getFileStream()
 {
     if (!$this->data instanceof File) {
         return null;
     }
     return $this->data->getStream();
 }
Beispiel #2
0
 /**
  * @param string $type
  * @param string $filePath
  */
 public function __construct($filePath, $type = Attachment::TYPE_FILE)
 {
     $this->path = $filePath;
     // Local image is sent with a multipart request
     $payload = [];
     if ($this->isRemoteFile()) {
         $payload = ['url' => $this->path];
     }
     $this->validateExtension();
     parent::__construct($type, $payload);
 }
 function it_send_attachment_message_to_user($client, Attachment $attachment, ResponseInterface $response)
 {
     $client->send('POST', '/me/messages', null, [], [], Argument::that(function ($value) use($attachment) {
         $message = $value['json']['message'];
         if (!$message instanceof Message) {
             return false;
         }
         return $message->getData() === $attachment->getWrappedObject();
     }))->willReturn($response);
     $response->getBody()->willReturn('
         {
             "recipient_id": "1008372609250235",
             "message_id": "mid.1456970487936:c34767dfe57ee6e339"
         }
     ');
     $this->sendMessage('1008372609250235', $attachment)->shouldBeLike(new MessageResponse('1008372609250235', 'mid.1456970487936:c34767dfe57ee6e339'));
 }