/** * Returns a route and replaces tokenized parts of the string with * the passed params * * @param $name * @param array $params * * @return mixed The default routes, or if $name is set to `findAll`, any of the following formats * based on the parent chain * GET /api/v2/groups.json * GET /api/v2/users/{user_id}/groups.json * * @throws \Exception */ public function getRoute($name, array $params = []) { $lastChained = $this->getLatestChainedParameter([self::class]); if (empty($lastChained) || !in_array($name, ['findAll', 'find', 'create', 'delete'])) { return parent::getRoute($name, $params); } $chainedResourceId = reset($lastChained); $chainedResourceNames = array_keys($lastChained); $chainedResourceName = (new $chainedResourceNames[0]($this->client))->resourceName; if ($name === 'findAll') { if (in_array($chainedResourceName, ['users', 'organizations'])) { return "{$chainedResourceName}/{$chainedResourceId}/{$this->resourceName}.json"; } return "{$this->resourceName}.json"; } elseif (in_array($name, ['find', 'delete'])) { if ($chainedResourceName === 'users') { return "{$chainedResourceName}/{$chainedResourceId}/{$this->resourceName}/{$params['id']}.json"; } return "{$this->resourceName}/{$params['id']}.json"; } elseif ($name === 'create') { if ($chainedResourceName === 'users') { return "{$chainedResourceName}/{$chainedResourceId}/{$this->resourceName}.json"; } return "{$this->resourceName}.json"; } }
/** * Returns a route and replaces tokenized parts of the string with * the passed params * * @param $name * @param array $params * * @return mixed The default routes, or if $name is set to `findAll`, any of the following formats * based on the parent chain * GET /api/v2/groups.json * GET /api/v2/users/{user_id}/groups.json * * @throws \Exception */ public function getRoute($name, array $params = []) { $lastChained = $this->getLatestChainedParameter([self::class]); $chainableRoutes = ['findAll', 'find', 'create', 'delete', 'assignable']; if (empty($lastChained) || !in_array($name, $chainableRoutes)) { return parent::getRoute($name, $params); } $chainedResourceId = reset($lastChained); $chainedResourceNames = array_keys($lastChained); $chainedResourceName = (new $chainedResourceNames[0]($this->client))->resourceName; if ($name === 'assignable' && $chainedResourceName === 'groups') { return "{$chainedResourceName}/{$chainedResourceId}/memberships/assignable.json"; } if ($name === 'create' && $chainedResourceName === 'users') { return "{$chainedResourceName}/{$chainedResourceId}/{$this->resourceName}.json"; } if (in_array($name, ['find', 'delete']) && $chainedResourceName === 'users') { return "{$chainedResourceName}/{$chainedResourceId}/{$this->resourceName}/{$params['id']}.json"; } if ($name === 'findAll') { if ($chainedResourceName === 'groups') { return "{$chainedResourceName}/{$chainedResourceId}/memberships.json"; } elseif ($chainedResourceName === 'users') { return "{$chainedResourceName}/{$chainedResourceId}/group_memberships.json"; } } throw new RouteException('Route not found.'); }
/** * Returns a route and replaces tokenized parts of the string with * the passed params * * @param $name * @param array $params * * @return mixed The default routes, or if $name is set to `findAll`, any of the following formats * based on the parent chain * /api/v2/sessions.json * /api/v2/users/{userId}/sessions.json * * @throws \Exception */ public function getRoute($name, array $params = []) { $userId = $this->getChainedParameter(Users::class); if (in_array($name, ['delete', 'deleteUserSessionss', 'find', 'findAll']) && !is_null($userId)) { if ($name === 'findAll') { return "users/{$userId}/sessions.json"; } $params = $this->addChainedParametersToParams($params, ['userId' => Users::class]); } return parent::getRoute($name, $params); }
/** * Returns a route and replaces tokenized parts of the string with * the passed params * * @param $name * @param array $params * * @return mixed Any of the following formats based on the parent chain * tickets/{id}/tags.json * topics/{id}/tags.json * organizations/{id}/tags.json * users/{id}/tags.json * * @throws \Exception */ public function getRoute($name, array $params = []) { $allowedRoutes = ['update', 'find', 'create', 'delete']; if (!in_array($name, $allowedRoutes)) { return parent::getRoute($name, $params); } $lastChained = $this->getLatestChainedParameter(); if (empty($lastChained)) { throw new CustomException('The ' . $name . '() method needs to be called while chaining.'); } $id = reset($lastChained); $chainedResourceNames = array_keys($lastChained); $resource = (new $chainedResourceNames[0]($this->client))->resourceName; return "{$resource}/{$id}/tags.json"; }
/** * Returns a route and replaces tokenized parts of the string with * the passed params * * @param $name * @param array $params * * @return mixed The default routes, or if $name is set to `findAll`, any of the following formats * based on the parent chain * GET /api/v2/organizations.json * GET /api/v2/users/{user_id}/organizations.json * * @throws \Exception */ public function getRoute($name, array $params = []) { $lastChained = $this->getLatestChainedParameter(); $chainedResourceNames = array_keys($lastChained); if (empty($lastChained) || $name !== 'findAll') { return parent::getRoute($name, $params); } else { $id = reset($lastChained); $resource = (new $chainedResourceNames[0]($this->client))->resourceName; if ('users' === $resource) { return "users/{$id}/organizations.json"; } else { return 'organizations.json'; } } }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['requested' => 'users/{id}/tickets/requested.json', 'ccd' => 'users/{id}/tickets/ccd.json', 'assigned' => 'users/{id}/tickets/assigned.json']); }
/** * {@inheritdoc} */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['findAllActive' => 'views/active.json', 'findAllCompact' => 'views/compact.json', 'export' => 'views/{id}/export.json', 'preview' => 'views/preview.json', 'previewCount' => 'views/preview/count.json', 'execute' => 'views/{id}/execute.json', 'tickets' => 'views/{id}/tickets.json']); }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['findAllActive' => 'macros/active.json', 'apply' => 'macros/{id}/apply.json', 'applyToTicket' => 'tickets/{ticketId}/macros/{id}/apply.json']); }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoute('deleteMany', 'push_notification_devices/destroy_many.json'); }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['replace' => "{$this->resourceName}/{id}/replace.json", 'reorder' => "{$this->resourceName}/reorder.json", 'definitions' => "{$this->resourceName}/definitions.json"]); }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['create' => 'tickets/{ticket_id}/satisfaction_rating.json']); }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['findMany' => 'tickets/show_many.json', 'updateMany' => 'tickets/update_many.json', 'markAsSpam' => 'tickets/{id}/mark_as_spam.json', 'markManyAsSpam' => 'tickets/mark_many_as_spam.json', 'related' => 'tickets/{id}/related.json', 'deleteMany' => 'tickets/destroy_many.json', 'collaborators' => 'tickets/{id}/collaborators.json', 'incidents' => 'tickets/{id}/incidents.json', 'problems' => 'problems.json', 'export' => 'exports/tickets.json', 'problemAutoComplete' => 'problems/autocomplete.json']); }
/** * Declares routes to be used by this resource. */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['findAll' => 'tickets/{ticket_id}/audits.json', 'find' => 'tickets/{ticket_id}/audits/{id}.json']); }
/** * {@inheritdoc} */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['upload' => "{$this->resourceName}/uploads.json", 'jobStatus' => "{$this->resourceName}/job_statuses/{id}.json", 'create' => "{$this->resourceName}.json", 'update' => "{$this->resourceName}/{id}.json", 'findAllOwned' => "{$this->resourceName}/owned.json", 'install' => "{$this->resourceName}/installations.json", 'notify' => "{$this->resourceName}/notify.json"]); }
/** * {@inheritdoc} */ public function getRoute($name, array $params = []) { $params = $this->addChainedParametersToParams($params, ['item_id' => DynamicContentItems::class]); return parent::getRoute($name, $params); }
/** * Appends the channels/voice/ prefix to resource names * @return string */ protected function getResourceNameFromClass() { $resourceName = parent::getResourceNameFromClass(); return 'channels/voice/' . $resourceName; }
/** * Appends the help_center/ prefix to resource names * @return string */ protected function getResourceNameFromClass() { $resourceName = parent::getResourceNameFromClass(); return 'help_center/' . $resourceName; }
/** * */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoute('reorder', "{$this->resourceName}/reorder.json"); }
/** * {@inheritdoc} */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['related' => 'users/{id}/related.json', 'merge' => 'users/me/merge.json', 'search' => 'users/search.json', 'autocomplete' => 'users/autocomplete.json', 'setPassword' => 'users/{id}/password.json', 'changePassword' => 'users/{id}/password.json', 'updateMany' => 'users/update_many.json', 'createMany' => 'users/create_many.json', 'updateProfileImageFromFile' => 'users/{id}.json', 'updateProfileImageFromUrl' => 'users/{id}.json']); }
/** * {@inheritdoc} */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoute('reorder', 'organization_fields/reorder.json'); }
/** * {@inheritdoc} */ protected function setUpRoutes() { parent::setUpRoutes(); $this->setRoutes(['clone' => 'ticket_forms/{id}/clone.json', 'reorder' => 'ticket_forms/reorder.json']); }