original_string: public function create(): Letter
      {
          $multipartElements = [
              [
                  'name'     => 'envelope',
                  'contents' => \GuzzleHttp\json_encode($this->getEnvelope()),
                  'headers'  => ['Content-Type' => $this->getEnvelope()->getMimeType()],
              ],
          ];
  
          if ($this->getCoverLetter()) {
              $multipartElements[] = [
                  'name'     => 'cover_letter',
                  'contents' => $this->getCoverLetter(),
                  'headers'  => ['Content-Type' => 'text/html'],
              ];
          }
  
          foreach ($this->getAttachments() as $attachment) {
              $multipartElements[] = [
                  'name'     => 'file',
                  'contents' => fopen($attachment, 'rb'),
                  'headers'  => ['Content-Type' => static::getMimeTypeOfFile($attachment)],
              ];
          }
  
          $multipart      = new MultipartStream($multipartElements);
          $requestOptions = [
              'headers' => [
                  'Content-Type' => 'multipart/mixed; boundary='.$multipart->getBoundary(),
              ],
              'body'    => $multipart,
          ];
  
          $response = $this->getHttpClientForMailbox()->request('POST', '/letters', $requestOptions);
          $data     = \GuzzleHttp\json_decode($response->getBody()->getContents());
  
          $this->setLetterId($data->letterId);
  
          return $this;
      }
code: public function create(): Letter
      {
          $multipartElements = [
              [
                  'name'     => 'envelope',
                  'contents' => \GuzzleHttp\json_encode($this->getEnvelope()),
                  'headers'  => ['Content-Type' => $this->getEnvelope()->getMimeType()],
              ],
          ];
  
          if ($this->getCoverLetter()) {
              $multipartElements[] = [
                  'name'     => 'cover_letter',
                  'contents' => $this->getCoverLetter(),
                  'headers'  => ['Content-Type' => 'text/html'],
              ];
          }
  
          foreach ($this->getAttachments() as $attachment) {
              $multipartElements[] = [
                  'name'     => 'file',
                  'contents' => fopen($attachment, 'rb'),
                  'headers'  => ['Content-Type' => static::getMimeTypeOfFile($attachment)],
              ];
          }
  
          $multipart      = new MultipartStream($multipartElements);
          $requestOptions = [
              'headers' => [
                  'Content-Type' => 'multipart/mixed; boundary='.$multipart->getBoundary(),
              ],
              'body'    => $multipart,
          ];
  
          $response = $this->getHttpClientForMailbox()->request('POST', '/letters', $requestOptions);
          $data     = \GuzzleHttp\json_decode($response->getBody()->getContents());
  
          $this->setLetterId($data->letterId);
  
          return $this;
      }
code_tokens: public function create ( ) : Letter { $ multipartElements = [ [ 'name' => 'envelope' , 'contents' => \ GuzzleHttp \ json_encode ( $ this -> getEnvelope ( ) ) , 'headers' => [ 'Content-Type' => $ this -> getEnvelope ( ) -> getMimeType ( ) ] , ] , ] ; if ( $ this -> getCoverLetter ( ) ) { $ multipartElements [ ] = [ 'name' => 'cover_letter' , 'contents' => $ this -> getCoverLetter ( ) , 'headers' => [ 'Content-Type' => 'text/html' ] , ] ; } foreach ( $ this -> getAttachments ( ) as $ attachment ) { $ multipartElements [ ] = [ 'name' => 'file' , 'contents' => fopen ( $ attachment , 'rb' ) , 'headers' => [ 'Content-Type' => static :: getMimeTypeOfFile ( $ attachment ) ] , ] ; } $ multipart = new MultipartStream ( $ multipartElements ) ; $ requestOptions = [ 'headers' => [ 'Content-Type' => 'multipart/mixed; boundary=' . $ multipart -> getBoundary ( ) , ] , 'body' => $ multipart , ] ; $ response = $ this -> getHttpClientForMailbox ( ) -> request ( 'POST' , '/letters' , $ requestOptions ) ; $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) -> getContents ( ) ) ; $ this -> setLetterId ( $ data -> letterId ) ; return $ this ; }
docstring: Create a draft by given envelope and attachments
  
  @return self
  @throws BadResponseException See API Send Reference
docstring_tokens: Create a draft by given envelope and attachments