<?php use HelpScout\ApiClient; $client = ApiClient::getInstance(); $client->setKey('example-key'); // The mailbox associated with the conversation $mailbox = new \HelpScout\model\ref\MailboxRef(); $mailbox->setId(123); // The customer associated with the conversation $customer = new \HelpScout\model\ref\CustomerRef(); $customer->setId(12345); $customer->setEmail('*****@*****.**'); $conversation = new \HelpScout\model\Conversation(); $conversation->setSubject('I need help!'); $conversation->setMailbox($mailbox); $conversation->setCustomer($customer); $conversation->setType('email'); // A conversation must have at least one thread $thread = new \HelpScout\model\thread\Customer(); $thread->setType('customer'); $thread->setBody('Hello. I need some help.'); $thread->setStatus('active'); // Create by: required $createdBy = new \HelpScout\model\ref\PersonRef(); $createdBy->setId(12345); $createdBy->setType('customer'); $thread->setCreatedBy($createdBy); // Assigned to: not required - defaults to 'anyone' $assignedTo = new \HelpScout\model\ref\PersonRef(); $assignedTo->setId(100); $assignedTo->setType('user');
/** * @return \HelpScout\model\ref\CustomerRef */ public function toRef() { $ref = new \HelpScout\model\ref\CustomerRef(); $ref->setId($this->id); $ref->setFirstName($this->firstName); $ref->setLastName($this->lastName); return $ref; }
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); $conversation->setCustomer($customer); $conversation->setType('email'); $tags = array('backlog', strtolower($row['reason'])); if ($row['extension'] == 'Yes') { $tags[] = strtolower($row['extension_name']); }