/**
  * Process attachments for feed.
  * 
  * @access public
  * @param array $files
  * @return array $attachments
  */
 public function process_feed_attachments($files)
 {
     /* Prepare attachments array. */
     $attachments = array();
     /* If Help Scout instance is not initialized, return attachments. */
     if (!$this->initialize_api()) {
         return $attachments;
     }
     /* If there are no files, return. */
     if (rgblank($files)) {
         return $attachments;
     }
     /* Prepare attachment and add to array */
     foreach ($files as $file) {
         /* Get the file name and location of the file */
         $file_name = basename($file);
         $file_location = str_replace(WP_CONTENT_URL, WP_CONTENT_DIR, $file);
         /* Get the file's mime type */
         $file_info = finfo_open(FILEINFO_MIME_TYPE);
         $file_mime_type = finfo_file($file_info, $file_location);
         finfo_close($file_info);
         /* Prepare the attachment object. */
         $attachment = new \HelpScout\model\Attachment();
         $attachment->setFileName($file_name);
         $attachment->setMimeType($file_mime_type);
         $attachment->setData(file_get_contents($file_location));
         /* Create the attachment. */
         try {
             $this->api->createAttachment($attachment);
             $attachments[] = $attachment;
         } catch (Exception $e) {
             $this->log_error(__METHOD__ . "(): Unable to upload attachment; {$e->getMessage()}");
         }
     }
     return $attachments;
 }
try {
    // Attachments: attachments must be sent to the API before they can
    // be used when creating a thread. Use the hash value returned when
    // creating the attachment to associate it with a ticket.
    $attachments = array();
    if (!empty($row['attachment'])) {
        foreach (explode(' , ', $row['attachment']) as $url) {
            $attachment = new HelpScout\model\Attachment();
            if (endswith($url, '.png')) {
                $attachment->setMimeType('image/png');
            }
            if (endswith($url, '.jpg') || endswith($url, '.jpeg')) {
                $attachment->setMimeType('image/jpeg');
            }
            $attachment->setFileName(filename_from_url($url));
            $attachment->setData(file_get_contents($url));
            $client->createAttachment($attachment);
            $attachments[] = $attachment;
        }
    }
    // Create the customer
    $customer = new \HelpScout\model\ref\CustomerRef();
    $customer->setId(null);
    $customer->setEmail($row['email']);
    $customer->setFirstName($row['f_name']);
    $customer->setLastName($row['l_name']);
    // Create the conversation
    $conversation = new \HelpScout\model\Conversation();
    $conversation->setSubject($row['reason'] . ': ' . $row['subject']);
    $conversation->setCreatedAt(format_api_date($row['date']));
    $conversation->setMailbox($mailbox);