public function getTestClient($fixture, $method = 'get') { $client = ApiClient::getInstance(); $client->setCurl($this->getCurlMock($fixture, $method)); $client->setKey('X'); return $client; }
/** * Returns the raw data for this attachment. * * @return string */ public function getData() { if ($this->data === false) { $this->data = \HelpScout\ApiClient::getInstance()->getAttachmentData($this->id); } return $this->data; }
private function initializeDI() { $this->container = new Container(); // Setup our Help Scout API client $this->container['api_key'] = $this->config['ApiKey']; $this->container['helpscout'] = $this->container->factory(function ($c) { $helpscout = ApiClient::getInstance(); $helpscout->setKey($c['api_key']); return $helpscout; }); }
/** * @return the $folders */ public function getFolders($cache = true) { if ($this->folders === false) { $folders = \HelpScout\ApiClient::getInstance()->getFolders($this->id); if ($folders) { if ($cache) { $this->folders = $folders->getItems(); } else { return $folders->getItems(); } } } return $this->folders; }
public function __construct() { parent::__construct(); $this->grooveClient = new GrooveClient(config('services.groove.key')); $this->helpscoutClient = ApiClient::getInstance(); try { $this->helpscoutClient->setKey(config('services.helpscout.key')); } catch (ApiException $e) { $this->error("There was an error creating the HelpScout client. Message was: " . APIHelper::formatApiExceptionArray($e)); return; } self::$rate_limits[GROOVE] = config('services.groove.ratelimit'); self::$rate_limits[HELPSCOUT] = config('services.helpscout.ratelimit'); }
<?php include_once 'ApiClient.php'; use HelpScout\ApiClient; $client = ApiClient::getInstance(); $client->setKey('example-key'); // The customer associated with the conversation $customerRef = $client->getCustomerRefProxy(null, '*****@*****.**'); $conversation = new \HelpScout\model\Conversation(); $conversation->setType('email'); $conversation->setSubject('I need help'); $conversation->setCustomer($customerRef); $conversation->setCreatedBy($customerRef); // The mailbox associated with the conversation $conversation->setMailbox($client->getMailboxProxy(2431)); // A conversation must have at least one thread $thread = new \HelpScout\model\thread\Customer(); $thread->setBody('Hello there - I need some help please.'); // Create by: required $thread->setCreatedBy($customerRef); $conversation->addLineItem($thread); $client->createConversation($conversation); echo $conversation->getId(); // if the customer id is important to you (for the customer created above), // grab the newly created convo $conversation = $client->getConversation($conversation->getId()); $customerId = $conversation->getCreatedBy()->getId();
/** * @param bool $cache * @param bool $apiCall * @return array|null */ public function getThreads($cache = true, $apiCall = true) { if ($this->threads === false && $apiCall) { $convo = \HelpScout\ApiClient::getInstance()->getConversation($this->id); if ($convo) { if ($cache) { $this->threads = $convo->getThreads(false, false); } else { return $convo->getThreads(false, false); } } } return $this->threads; }