/**
  * @param $results
  * @return static
  */
 protected function getCollection($results)
 {
     $final = [];
     foreach ($results as $record) {
         $recordArray = $record->toArray();
         $final[] = $this->factory->create($recordArray);
     }
     return Collection::make($final);
 }
 /**
  * @param array $searchParams
  * @param int $limit
  * @param int $offset
  * @return Collection
  */
 public function search($searchParams, $limit = 0, $offset = 0)
 {
     $mg = new Mailgun($this->key);
     $apiParams['event'] = $searchParams['event'];
     if (isset($searchParams['recipient']) && $searchParams['recipient']) {
         $apiParams['recipient'] = $searchParams['recipient'];
     }
     if ($limit > 0) {
         $apiParams['limit'] = $limit;
     }
     if ($limit > 0) {
         $apiParams['page'] = $offset > 0 ? (int) ($offset / $limit) : 1;
     }
     $result = $mg->get($this->domain . '/campaigns/' . $searchParams['id'] . '/events', $apiParams);
     $final = [];
     foreach ($result->http_response_body as $event) {
         $recordArray = (array) $event;
         $final[] = $this->factory->create($recordArray);
     }
     return Collection::make($final);
 }