code
stringlengths
52
7.75k
docs
stringlengths
1
5.85k
public function getEvents($limit = null, $starting_after = null, $ending_before = null, $school = null, $record_type = null) { list($response) = $this->getEventsWithHttpInfo($limit, $starting_after, $ending_before, $school, $record_type); return $response; }
Operation getEvents @param int $limit limit (optional) @param string $starting_after starting_after (optional) @param string $ending_before ending_before (optional) @param string $school school (optional) @param string[] $record_type record_type (optional) @throws \Clever\ApiException on non-2xx response @throws \InvalidArgumentException @return \Clever\Model\EventsResponse
public function getEventsAsync($limit = null, $starting_after = null, $ending_before = null, $school = null, $record_type = null) { return $this->getEventsAsyncWithHttpInfo($limit, $starting_after, $ending_before, $school, $record_type) ->then( function ($response) { return $response[0]; } ); }
Operation getEventsAsync @param int $limit (optional) @param string $starting_after (optional) @param string $ending_before (optional) @param string $school (optional) @param string[] $record_type (optional) @throws \InvalidArgumentException @return \GuzzleHttp\Promise\PromiseInterface
private function generatePatterns() { foreach ($this->builders as $uri => $builder) { $pattern = '/' . ltrim($uri, '/'); if (preg_match_all('/{[\w]+}/i', $uri, $matches)) { foreach (array_unique($matches[0]) as $match) { $pattern = str_replace($match, '[\w\d\@_~\-\.]+', $pattern); } } $this->patterns['#^' . $pattern . '$#i'] = $uri; } // Sort patterns to ensure that longer more precisely pattern comes first krsort($this->patterns); }
Generate regex patterns for URI templates.
public function create($uri, $content) { $uri = '/' . trim($uri, '/'); foreach ($this->patterns as $pattern => $key) { if (preg_match($pattern, $uri)) { return call_user_func($this->builders[$key], (array) $content); } } throw new RuntimeException(sprintf('Cannot create resource by URI "%s"', $uri)); }
Create resource object by URI template and resource data. @param string $uri @param array $content @throws RuntimeException @return mixed|Collection|Entity|Entity[]
public function setTaxCategoryId($value) { if (!in_array($value, self::allowedTaxCategories(), true)) { throw new DomainException(sprintf( self::MSG_UNEXPECTED_TAX_CATEGORY, implode(', ', self::allowedTaxCategories()) )); } return $this->setAttribute('taxCategoryId', $value); }
@param string|null $value @return $this
public function setWebsites(array $value) { $websites = []; foreach ($value as $website) { if ($website instanceof Website) { $websites[] = $website->getId(); } elseif (is_string($website)) { $websites[] = $website; } else { throw new DomainException('Each website must be string identifier or Website entity object'); } } return $this->setAttribute('websites', $websites); }
@param array $value @throws DomainException @return $this
public function setPaymentCardSchemes($value) { $allowedPaymentCardSchemes = self::allowedPaymentCardSchemes(); foreach ($value as $paymentCardScheme) { if (!in_array($paymentCardScheme, $allowedPaymentCardSchemes, true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_PAYMENT_CARD_SCHEME, implode(', ', $allowedPaymentCardSchemes))); } } return $this->setAttribute('paymentCardSchemes', $value); }
@param array $value @return $this
public function setMethod($value) { $allowedMethods = self::allowedMethods(); if (!in_array($value, $allowedMethods, true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_METHOD, implode(', ', $allowedMethods))); } return $this->setAttribute('method', $value); }
@param string $value @return $this
public static function config($configName, $config = null) { $_this = Purifier::getInstance(); if (empty($config)) { if (!isset($_this->_configs[$configName])) { throw new \InvalidArgumentException(sprintf('Purifier configuration `%s` does not exist!', $configName)); } return $_this->_configs[$configName]; } if (is_array($config)) { $purifierConfig = \HTMLPurifier_Config::createDefault(); foreach ($config as $key => $value) { $purifierConfig->set($key, $value); } return $_this->_configs[$configName] = $purifierConfig; } elseif (is_object($config) && is_a($config, 'HTMLPurifier_Config')) { return $_this->_configs[$configName] = $config; } else { throw new \InvalidArgumentException('Invalid purifier config passed!'); } }
Gets and sets purifier configuration sets. @param string $configName @param string $config @throws \InvalidArgumentException @return \HTMLPurifier
public static function getPurifierInstance($configName = 'default') { $_this = Purifier::getInstance(); if (!isset($_this->_instances[$configName])) { if (!isset($_this->_configs[$configName])) { throw new \InvalidArgumentException(sprintf('Configuration and instance `%s` does not exist!', $configName)); } $_this->_instances[$configName] = new \HTMLPurifier($_this->_configs[$configName]); } return $_this->_instances[$configName]; }
Gets an instance of the purifier lib only when needed, lazy loading it @param string $configName @return HTMLPurifier
public static function clean($markup, $configName = 'default') { $_this = Purifier::getInstance(); if (!isset($_this->_configs[$configName])) { throw new \InvalidArgumentException(sprintf('Invalid HtmlPurifier configuration "%s"!', $configName)); } return $_this->getPurifierInstance($configName)->purify($markup); }
Cleans Markup using a given config @param string $markup @param string $configName
public function setPermissions($value) { $allowedResources = self::allowedResources(); $allowedMethods = self::allowedMethods(); if ($value !== null && !is_array($value)) { throw new DomainException(self::MSG_INVALID_FORMAT); } foreach ($value as $rule) { if (!is_array($rule)) { throw new DomainException(self::MSG_INVALID_FORMAT); } if (!empty($rule['resourceName']) && !in_array($rule['resourceName'], $allowedResources, true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_RESOURCE, implode(', ', $allowedResources))); } if (!empty($rule['resourceIds']) && !is_array($rule['resourceIds'])) { throw new DomainException(self::MSG_INVALID_RESOURCE_IDS); } if (!empty($rule['methods']) && !is_array($rule['methods'])) { throw new DomainException(self::MSG_INVALID_METHODS); } if (!empty($rule['methods'])) { foreach ($rule['methods'] as $method) { if (!in_array($method, $allowedMethods, true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_METHOD, implode(', ', $allowedMethods))); } } } } return $this->setAttribute('permissions', $value); }
@param array $value @return $this
public function valid() { $allowedValues = $this->getStateAllowableValues(); if (!in_array($this->container['state'], $allowedValues)) { return false; } return true; }
Validate all the properties in the model return true if all passed @return bool True if all properties are valid
public function create($payment, $paymentId = null) { if (isset($paymentId)) { return $this->client()->put($payment, 'payments/{paymentId}', ['paymentId' => $paymentId]); } return $this->client()->post($payment, 'payments'); }
@param array|JsonSerializable|Entities\Payment $payment @param string|null $paymentId @throws UnprocessableEntityException The input data does not valid @return Entities\Payment|Entities\ScheduledPayment
public function createRestrictions(array $data) { return array_map( function ($restriction) { if ($restriction instanceof Restriction) { return $restriction; } if (!is_array($restriction)) { throw new DomainException('Incorrect restriction - it must be an array or instance of Restriction.'); } return Restriction::createFromData($restriction); }, $data ); }
@param array $data @return array
public function create($data, $blacklistId = null) { if (isset($blacklistId)) { return $this->client()->put($data, 'blacklists/{blacklistId}', ['blacklistId' => $blacklistId]); } return $this->client()->post($data, 'blacklists'); }
@param array|JsonSerializable|Blacklist $data @param string $blacklistId @throws UnprocessableEntityException The input data does not valid @return Blacklist
public function createAttachments(array $value): array { return array_map(function ($data) { if ($data instanceof ResourceAttachment) { return $data; } return new ResourceAttachment((array) $data); }, $value); }
@param ResourceAttachment[]|array $value @return ResourceAttachment[]|array
protected function execute(array $options = []) { $session = $this->createSession(); $result = []; try { if ($session->open() === false) { throw new RuntimeException('Cannot initialize a cURL session'); } $session->setOptions($options + $this->options); $result = $session->execute(); if ($result === false) { throw new TransferException($session->getErrorMessage(), $session->getErrorCode()); } $headerSize = $session->getInfo(CURLINFO_HEADER_SIZE); if (strlen($result) < $headerSize) { throw new TransferException( 'Header size(' . $headerSize . ') does not match result: ' . $result ); } $result = [ substr($result, $headerSize) ?: null, substr($result, 0, $headerSize) ?: null, ]; } finally { $session->close(); } return $result; }
Execute cURL session. @param array $options @throws RuntimeException @throws TransferException @return array
public function load($gatewayAccountId, $downtimeId, $params = []) { return $this->client()->get( 'gateway-accounts/{gatewayAccountId}/downtime-schedules/{downtimeId}', ['downtimeId' => $downtimeId, 'gatewayAccountId' => $gatewayAccountId] + (array) $params ); }
@param string $gatewayAccountId @param string $downtimeId @param array|ArrayObject $params @return GatewayAccountDowntime
public function update($gatewayAccountId, $downtimeId, $data) { return $this->client()->put( $data, 'gateway-accounts/{gatewayAccountId}/downtime-schedules/{downtimeId}', ['downtimeId' => $downtimeId, 'gatewayAccountId' => $gatewayAccountId] ); }
@param string $gatewayAccountId @param string $downtimeId @param array|JsonSerializable|GatewayAccountDowntime $data @throws UnprocessableEntityException The input data is not valid @return GatewayAccountDowntime
public static function createFromData(array $data) { if (!isset($data['type'])) { throw new DomainException(self::MSG_REQUIRED_TYPE); } switch ($data['type']) { case self::TYPE_DISCOUNTS_PER_REDEMPTION: $restriction = new Restrictions\DiscountsPerRedemption($data); break; case self::TYPE_REDEMPTIONS_PER_CUSTOMER: $restriction = new Restrictions\RedemptionsPerCustomer($data); break; case self::TYPE_RESTRICT_TO_INVOICES: $restriction = new Restrictions\RestrictToInvoices($data); break; case self::TYPE_RESTRICT_TO_PLANS: $restriction = new Restrictions\RestrictToPlans($data); break; case self::TYPE_RESTRICT_TO_SUBSCRIPTIONS: $restriction = new Restrictions\RestrictToSubscriptions($data); break; case self::TYPE_TOTAL_REDEMPTIONS: $restriction = new Restrictions\TotalRedemptions($data); break; case self::TYPE_MINIMUM_ORDER_AMOUNT: $restriction = new Restrictions\MinimumOrderAmount($data); break; default: throw new DomainException( sprintf(self::MSG_UNSUPPORTED_TYPE, implode(',', self::$supportedTypes)) ); } return $restriction; }
@param array $data @return Restriction
public function create($data, $planId = null) { if (isset($planId)) { return $this->client()->put($data, 'plans/{planId}', ['planId' => $planId]); } return $this->client()->post($data, 'plans'); }
@param array|JsonSerializable|Plan $data @param string $planId @throws UnprocessableEntityException The input data does not valid @return Plan
protected function _getTable() { $table = TableRegistry::get($this->args[0]); $connection = $table->connection(); $tables = $connection->schemaCollection()->listTables(); if (!in_array($table->table(), $tables)) { $this->abort(__d('Burzum/HtmlPurifier', 'Table `{0}` does not exist in connection `{1}`!', $table->table(), $connection->configName())); } return $table; }
Gets the table from the shell args. @return \Cake\ORM\Table;
protected function _getFields(Table $table) { $fields = explode(',', $this->args[1]); foreach ($fields as $field) { if (!$table->hasField($field)) { $this->abort(sprintf('Table `%s` is missing the field `%s`.', $table->table(), $field)); } } return $fields; }
Gets the field(s) from the args and checks if they're present in the table. @param \Cake\ORM\Table $table Table object. @return array Set of of fields explode()'ed from the args
protected function _loadBehavior(Table $table, $fields) { if (!in_array('HtmlPurifier', $table->behaviors()->loaded())) { $table->addBehavior('Burzum/HtmlPurifier.HtmlPurifier', [ 'fields' => $fields, 'purifierConfig' => $this->param('config') ]); } }
Loads the purifier behavior for the given table if not already attached. @param \Cake\ORM\Table $table Table object. @param array Set of fields to sanitize @return void
public function purify() { $table = $this->_getTable(); $fields = $this->_getFields($table); $this->_loadBehavior($table, $fields); $query = $table->find(); if ($table->hasFinder('purifier')) { $query->find('purifier'); } $total = $query->all()->count(); $this->info(__d('Burzum/HtmlPurifier', 'Sanitizing fields `{0}` in table `{1}`', implode(',', $fields), $table->table())); $this->helper('progress')->output([ 'total' => $total, 'callback' => function ($progress) use ($total, $table, $fields) { $chunkSize = 25; $chunkCount = 0; while ($chunkCount <= $total) { $this->_process($table, $chunkCount, $chunkSize, $fields); $chunkCount = $chunkCount + $chunkSize; $progress->increment($chunkSize); $progress->draw(); } return; } ]); }
Purifies data base content. @return void
protected function _process(Table $table, $chunkCount, $chunkSize, $fields) { $query = $table->find(); if ($table->hasFinder('purifier')) { $query->find('purifier'); } $fields[] = $table->primaryKey(); $results = $query ->select($fields) ->offset($chunkCount) ->limit($chunkSize) ->orderDesc($table->aliasField($table->primaryKey())) ->all(); if (empty($results)) { return; } foreach ($results as $result) { try { $table->save($result); $chunkCount++; } catch (\Exception $e) { $this->abort($e->getMessage()); } } }
Processes the records. @param \Cake\ORM\Table $table @param int $chunkCount @param int $chunkSize @return void
public function getOptionParser() { $parser = parent::getOptionParser(); $parser->description([ __d('Burzum/HtmlPurifier', 'This shell allows you to clean database content with the HTML Purifier.'), ]); $parser->addArguments([ 'table' => [ 'help' => __d('Burzum/HtmlPurifier', 'The table to sanitize'), 'required' => true, ], 'fields' => [ 'help' => __d('Burzum/HtmlPurifier', 'The field(s) to purify, comma separated'), 'required' => true, ], ]); $parser->addOption('config', [ 'short' => 'c', 'help' => __d('Burzum/HtmlPurifier', 'The purifier config you want to use'), 'default' => 'default' ]); return $parser; }
{@inheritDoc}
public function create($data, $credentialId = null) { if (isset($credentialId)) { return $this->client()->put($data, 'credentials/{credentialId}', ['credentialId' => $credentialId]); } return $this->client()->post($data, 'credentials'); }
@param array|JsonSerializable|CustomerCredential $data @param string $credentialId @throws UnprocessableEntityException The input data does not valid @return CustomerCredential
public function getPhoneTypeAllowableValues() { return [ self::PHONE_TYPE_CELL, self::PHONE_TYPE_HOME, self::PHONE_TYPE_WORK, self::PHONE_TYPE_OTHER, self::PHONE_TYPE_EMPTY, ]; }
Gets allowable values of the enum @return string[]
public function getRelationshipAllowableValues() { return [ self::RELATIONSHIP_PARENT, self::RELATIONSHIP_GRANDPARENT, self::RELATIONSHIP_SELF, self::RELATIONSHIP_AUNTUNCLE, self::RELATIONSHIP_SIBLING, self::RELATIONSHIP_OTHER, self::RELATIONSHIP_EMPTY, ]; }
Gets allowable values of the enum @return string[]
public function getTypeAllowableValues() { return [ self::TYPE_PARENTGUARDIAN, self::TYPE_EMERGENCY, self::TYPE_PRIMARY, self::TYPE_SECONDARY, self::TYPE_FAMILY, self::TYPE_OTHER, self::TYPE_EMPTY, ]; }
Gets allowable values of the enum @return string[]
public function listInvalidProperties() { $invalidProperties = []; $allowedValues = $this->getPhoneTypeAllowableValues(); if (!in_array($this->container['phone_type'], $allowedValues)) { $invalidProperties[] = sprintf( "invalid value for 'phone_type', must be one of '%s'", implode("', '", $allowedValues) ); } $allowedValues = $this->getRelationshipAllowableValues(); if (!in_array($this->container['relationship'], $allowedValues)) { $invalidProperties[] = sprintf( "invalid value for 'relationship', must be one of '%s'", implode("', '", $allowedValues) ); } $allowedValues = $this->getTypeAllowableValues(); if (!in_array($this->container['type'], $allowedValues)) { $invalidProperties[] = sprintf( "invalid value for 'type', must be one of '%s'", implode("', '", $allowedValues) ); } return $invalidProperties; }
Show all the invalid properties with reasons. @return array invalid properties with reasons
public function valid() { $allowedValues = $this->getPhoneTypeAllowableValues(); if (!in_array($this->container['phone_type'], $allowedValues)) { return false; } $allowedValues = $this->getRelationshipAllowableValues(); if (!in_array($this->container['relationship'], $allowedValues)) { return false; } $allowedValues = $this->getTypeAllowableValues(); if (!in_array($this->container['type'], $allowedValues)) { return false; } return true; }
Validate all the properties in the model return true if all passed @return bool True if all properties are valid
public function setPhoneType($phone_type) { $allowedValues = $this->getPhoneTypeAllowableValues(); if (!is_null($phone_type) && !in_array($phone_type, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'phone_type', must be one of '%s'", implode("', '", $allowedValues) ) ); } $this->container['phone_type'] = $phone_type; return $this; }
Sets phone_type @param string $phone_type phone_type @return $this
public function setRelationship($relationship) { $allowedValues = $this->getRelationshipAllowableValues(); if (!is_null($relationship) && !in_array($relationship, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'relationship', must be one of '%s'", implode("', '", $allowedValues) ) ); } $this->container['relationship'] = $relationship; return $this; }
Sets relationship @param string $relationship relationship @return $this
public function setRenewalPolicy($value) { if (!in_array($value, self::renewalPolicies(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_RENEWAL_POLICY, implode(', ', self::renewalPolicies()))); } $this->setAttribute('renewalPolicy', $value); }
@param $value @throws DomainException
public function clean($markup, $config = null) { if (empty($config) && !empty($this->_config['config'])) { $config = $this->config('config'); } return Purifier::clean($markup, $config); }
Clean markup @param string $markup @param string $config @return string
public function create($data, $userId = null) { if (isset($userId)) { return $this->client()->put($data, 'users/{userId}', ['userId' => $userId]); } return $this->client()->post($data, 'users'); }
@param array|JsonSerializable|User $data @param string $userId @throws UnprocessableEntityException The input data does not valid @return User
public function create($data, $checkoutPageId = null) { if (isset($checkoutPageId)) { return $this->client()->put($data, 'checkout-pages/{checkoutPageId}', ['checkoutPageId' => $checkoutPageId]); } return $this->client()->post($data, 'checkout-pages'); }
@param array|JsonSerializable|CheckoutPage $data @param string $checkoutPageId @throws UnprocessableEntityException The input data does not valid @return CheckoutPage
public function getHighGradeAllowableValues() { return [ self::HIGH_GRADE__1, self::HIGH_GRADE__2, self::HIGH_GRADE__3, self::HIGH_GRADE__4, self::HIGH_GRADE__5, self::HIGH_GRADE__6, self::HIGH_GRADE__7, self::HIGH_GRADE__8, self::HIGH_GRADE__9, self::HIGH_GRADE__10, self::HIGH_GRADE__11, self::HIGH_GRADE__12, self::HIGH_GRADE_PRE_KINDERGARTEN, self::HIGH_GRADE_KINDERGARTEN, self::HIGH_GRADE_POST_GRADUATE, self::HIGH_GRADE_OTHER, ]; }
Gets allowable values of the enum @return string[]
public function getLowGradeAllowableValues() { return [ self::LOW_GRADE__1, self::LOW_GRADE__2, self::LOW_GRADE__3, self::LOW_GRADE__4, self::LOW_GRADE__5, self::LOW_GRADE__6, self::LOW_GRADE__7, self::LOW_GRADE__8, self::LOW_GRADE__9, self::LOW_GRADE__10, self::LOW_GRADE__11, self::LOW_GRADE__12, self::LOW_GRADE_PRE_KINDERGARTEN, self::LOW_GRADE_KINDERGARTEN, self::LOW_GRADE_POST_GRADUATE, self::LOW_GRADE_OTHER, ]; }
Gets allowable values of the enum @return string[]
public function listInvalidProperties() { $invalidProperties = []; $allowedValues = $this->getHighGradeAllowableValues(); if (!in_array($this->container['high_grade'], $allowedValues)) { $invalidProperties[] = sprintf( "invalid value for 'high_grade', must be one of '%s'", implode("', '", $allowedValues) ); } $allowedValues = $this->getLowGradeAllowableValues(); if (!in_array($this->container['low_grade'], $allowedValues)) { $invalidProperties[] = sprintf( "invalid value for 'low_grade', must be one of '%s'", implode("', '", $allowedValues) ); } return $invalidProperties; }
Show all the invalid properties with reasons. @return array invalid properties with reasons
public function valid() { $allowedValues = $this->getHighGradeAllowableValues(); if (!in_array($this->container['high_grade'], $allowedValues)) { return false; } $allowedValues = $this->getLowGradeAllowableValues(); if (!in_array($this->container['low_grade'], $allowedValues)) { return false; } return true; }
Validate all the properties in the model return true if all passed @return bool True if all properties are valid
public function setHighGrade($high_grade) { $allowedValues = $this->getHighGradeAllowableValues(); if (!is_null($high_grade) && !in_array($high_grade, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'high_grade', must be one of '%s'", implode("', '", $allowedValues) ) ); } $this->container['high_grade'] = $high_grade; return $this; }
Sets high_grade @param string $high_grade high_grade @return $this
public function setLowGrade($low_grade) { $allowedValues = $this->getLowGradeAllowableValues(); if (!is_null($low_grade) && !in_array($low_grade, $allowedValues)) { throw new \InvalidArgumentException( sprintf( "Invalid value for 'low_grade', must be one of '%s'", implode("', '", $allowedValues) ) ); } $this->container['low_grade'] = $low_grade; return $this; }
Sets low_grade @param string $low_grade low_grade @return $this
public function create($data, $tokenId = null) { if (isset($tokenId)) { return $this->client()->put($data, 'sessions/{tokenId}', ['tokenId' => $tokenId]); } return $this->client()->post($data, 'sessions'); }
@param array|JsonSerializable|Session $data @param string $tokenId @throws UnprocessableEntityException The input data does not valid @return Session
public function load($invoiceId, $invoiceItemId, $params = []) { return $this->client()->get( 'invoices/{invoiceId}/items/{invoiceItemId}', ['invoiceId' => $invoiceId, 'invoiceItemId' => $invoiceItemId] + (array) $params ); }
@param string $invoiceId @param string $invoiceItemId @param array|ArrayObject $params @throws NotFoundException The resource data does not exist @return InvoiceItem
public function create($data, $invoiceId, $invoiceItemId = null) { if (isset($invoiceItemId)) { return $this->client()->put( $data, 'invoices/{invoiceId}/items/{invoiceItemId}', ['invoiceId' => $invoiceId, 'invoiceItemId' => $invoiceItemId] ); } return $this->client()->post( $data, 'invoices/{invoiceId}/items', ['invoiceId' => $invoiceId] ); }
@param array|JsonSerializable|InvoiceItem $data @param string $invoiceId @param string $invoiceItemId @throws UnprocessableEntityException The input data does not valid @return InvoiceItem
public static function createFromData(array $data): self { if (!isset($data['method'])) { throw new DomainException(self::REQUIRED_METHOD); } switch ($data['method']) { case self::NONE: $paymentInstruction = new NoneType($data); break; case self::PARTIAL: $paymentInstruction = new PartialType($data); break; case self::DISCOUNT: $paymentInstruction = new DiscountType($data); break; default: throw new DomainException( sprintf(self::UNSUPPORTED_METHOD, implode(',', self::$availableMethods)) ); } return $paymentInstruction; }
@param array $data @return PaymentInstruction
protected function allowedTypes() { return [ self::TYPE_DEFAULT_MESSAGE, self::TYPE_REGISTRATION_MESSAGE, self::TYPE_RESET_PASSWORD_MESSAGE, self::TYPE_LOGIN_MESSAGE, self::TYPE_NOTIFICATION_MESSAGE, ]; }
Allowed message types @return array
public function send($numbers, $message, $type = self::TYPE_DEFAULT_MESSAGE) { if (!in_array($type, $this->allowedTypes())) { throw new NotSupportedException("Message type \"$type\" doesn't support."); } if (empty($numbers) || (is_array($numbers) && count($numbers) === 0) || empty($message)) { throw new \InvalidArgumentException('For sending sms, please, set phone number and message'); } $response = $this->_client->sendMessage([ 'phones' => $numbers, 'message' => $message, 'id' => $this->smsIdGenerator(), ]); if ($this->_logger instanceof LoggerInterface) { if (is_array($numbers)) { foreach ($numbers as $number) { $this->_logger->setRecord([ 'sms_id' => isset($response['id']) ? $response['id'] : '', 'phone' => $number, 'message' => $message, 'error' => isset($response['error']) ? $response['error'] : 0, ]); } } else { $this->_logger->setRecord([ 'sms_id' => isset($response['id']) ? $response['id'] : '', 'phone' => $numbers, 'message' => $message, 'error' => isset($response['error']) ? $response['error'] : 0, ]); } } return isset($response['id']) ? $response['id'] : false; }
Send sms message @param string|array $numbers @param string $message @param int $type @return bool|string @throws NotSupportedException|\InvalidArgumentException
public function getStatus($id, $phone, $all = 2) { if (empty($id) || empty($phone)) { throw new \InvalidArgumentException('For getting sms status, please, set id and phone'); } $data = $this->_client->getMessageStatus($id, $phone, $all); if ($this->_logger instanceof LoggerInterface) { $this->_logger->updateRecordBySmsIdAndPhone($id, $phone, $data); } return $data; }
Get sms status by id and phone @param string $id @param string $phone @param int $all @return array|bool @throws \InvalidArgumentException
public function createBinds(array $data): array { return array_map(function ($data) { if ($data instanceof Bind) { return $data; } return Bind::createFromData((array) $data); }, $data); }
@param array $data @return Bind[]|array
public function createRules(array $data): array { return array_map(function ($data) { if ($data instanceof Rule) { return $data; } return Rule::createFromData((array) $data); }, $data); }
@param array $data @return Rule[]|array
public function setExtension($value) { if (!in_array($value, self::allowedTypes(), true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_EXTENSION, implode(', ', self::allowedTypes()))); } return $this->setAttribute('extension', $value); }
@param mixed $value @return $this
public function frontControllerPath($sitePath) { $_SERVER['SCRIPT_FILENAME'] = $this->sitePath($sitePath); $_SERVER['SCRIPT_NAME'] = $this->directoryIndex(); return $_SERVER['SCRIPT_FILENAME']; }
Get the fully resolved path to the application's front controller. @param string $sitePath @return string
public function setValues(array $values) { $listValues = []; if (empty($values)) { throw new DomainException('Values cannot be empty'); } foreach ($values as $value) { if (is_scalar($value)) { $listValues[] = $value; } else { throw new DomainException('Each value must be a scalar element'); } } return $this->setAttribute('values', $listValues); }
@param array $values @throws DomainException @return $this
public function addValue($value) { if (!is_string($value)) { throw new DomainException('List value must be string identifier'); } $listValues = $this->getAttribute('values') ?: []; $listValues[] = $value; return $this->setAttribute('values', $listValues); }
@param string $value @throws DomainException @return $this
public static function createFromData(array $data) { if (!isset($data['type'])) { throw new DomainException(self::MSG_REQUIRED_TYPE); } switch ($data['type']) { case self::TYPE_FIXED: $discount = new Discounts\Fixed($data); break; case self::TYPE_PERCENT: $discount = new Discounts\Percent($data); break; default: throw new DomainException( sprintf(self::MSG_UNSUPPORTED_TYPE, implode(',', self::$supportedTypes)) ); } return $discount; }
@param array $data @return Discount
public static function createFromData(array $data): self { if (!isset($data['method'])) { throw new DomainException(self::REQUIRED_METHOD); } switch ($data['method']) { case self::METHOD_ACCOUNT_WEIGHTS: $instruction = new AccountWeights($data); break; case self::METHOD_ACQUIRER_WEIGHTS: $instruction = new AcquirerWeights($data); break; default: throw new DomainException( sprintf(self::UNEXPECTED_METHOD, implode(', ', self::methods())) ); } return $instruction; }
@param array $data @return Instruction
public function create($data, $disputeId = null) { if (isset($disputeId)) { return $this->client()->put($data, 'disputes/{disputeId}', ['disputeId' => $disputeId]); } return $this->client()->post($data, 'disputes'); }
@param array|JsonSerializable|Dispute $data @param string $disputeId @throws UnprocessableEntityException The input data does not valid @return Dispute
public static function createFromData(array $data) { if (!isset($data['method'])) { throw new DomainException('Method is required'); } switch ($data['method']) { case PaymentMethod::METHOD_PAYMENT_CARD: $paymentInstrumentValidation = new PaymentCardValidation($data); break; default: throw new DomainException( sprintf('Unexpected method. Only %s methods support', implode(',', self::$supportMethods)) ); } return $paymentInstrumentValidation; }
@param array $data @return PaymentCardValidation
public function create($data, $organizationId = null) { if (isset($organizationId)) { return $this->client()->put($data, 'organizations/{organizationId}', ['organizationId' => $organizationId]); } return $this->client()->post($data, 'organizations'); }
@param array|JsonSerializable|Organization $data @param string $organizationId @throws UnprocessableEntityException The input data does not valid @return Organization
public function setType($value): self { if (!in_array($value, self::types(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_TYPE, implode(', ', self::types()))); } return $this->setAttribute('type', $value); }
@param string $value @return $this
final protected function getAttribute($name) { if (isset($this->internalCache[$name])) { return $this->internalCache[$name]; } if (isset($this->data[$name])) { return $this->data[$name]; } return null; }
@param string $name @return mixed
final protected function setAttribute($name, $value) { if ($value !== null && $this->hasAttributeValueFactory($name)) { $this->internalCache[$name] = $this->createAttributeValue($name, $value); if ($this->internalCache[$name] instanceof JsonSerializable) { $value = $this->internalCache[$name]->jsonSerialize(); } elseif (is_array($this->internalCache[$name])) { $value = array_map( function ($value) { if ($value instanceof JsonSerializable) { $value = $value->jsonSerialize(); } return $value; }, $this->internalCache[$name] ); } else { $value = $this->internalCache[$name]; } } $this->data[$name] = $value; return $this; }
@param string $name @param mixed $value @return $this
private function createAttributeValue($name, $value) { $factory = "create{$name}"; if ($value instanceof JsonSerializable) { $value = $value->jsonSerialize(); } $value = $this->{$factory}($value); if (!($value instanceof JsonSerializable || is_array($value))) { throw new DomainException('Invalid value factory'); } return $value; }
@param string $name @param mixed $value @return JsonSerializable
final protected function getMetadata($name) { return isset($this->metadata[$name]) ? $this->metadata[$name] : null; }
@param string $name @return mixed
public function offsetGet($offset) { if (method_exists($this, 'get' . $offset)) { return call_user_func([$this, 'get' . $offset]); } if (method_exists($this, 'set' . $offset)) { throw new DomainException( sprintf('Trying to get the write-only property "%s::%s"', get_class($this), $offset) ); } throw new OutOfRangeException( sprintf('The property "%s::%s" does not exist', get_class($this), $offset) ); }
{@inheritdoc}
public function offsetSet($offset, $value) { if (method_exists($this, 'set' . $offset)) { return call_user_func([$this, 'set' . $offset], $value); } if (method_exists($this, 'get' . $offset)) { throw new DomainException( sprintf('Trying to set the read-only property "%s::%s"', get_class($this), $offset) ); } throw new OutOfRangeException( sprintf('The property "%s::%s" does not exist', get_class($this), $offset) ); }
{@inheritdoc}
public function setPolicy($value) { if (!in_array($value, self::policies(), true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_POLICY, implode(', ', self::policies()))); } return $this->setAttribute('policy', $value); }
@param string $value @throws DomainException @return SubscriptionCancel
public function setCancelCategory($value) { if (!in_array($value, self::cancelCategories(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_CATEGORY, implode(', ', self::cancelCategories()))); } return $this->setAttribute('cancelCategory', $value); }
@param string $value @throws DomainException @return SubscriptionCancel
public function setCanceledBy($value) { if (!in_array($value, self::canceledBySources(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_CATEGORY, implode(', ', self::canceledBySources()))); } return $this->setAttribute('canceledBy', $value); }
@param string $value @throws DomainException @return SubscriptionCancel
public function setExcludePolicy($value): self { if (!in_array($value, self::excludePolicies(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_POLICY, implode(', ', self::excludePolicies()))); } return $this->setAttribute('excludePolicy', $value); }
@param string $value @return $this
public function setPromptPolicy($value): self { if (!in_array($value, self::promptPolicies(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_POLICY, implode(', ', self::promptPolicies()))); } return $this->setAttribute('promptPolicy', $value); }
@param string $value @return $this
public function setRejectedBeforeTransactionProcessPolicy($value): self { if (!in_array($value, self::rejectedBeforeTransactionProcessPolicies(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_POLICY, implode(', ', self::rejectedBeforeTransactionProcessPolicies()))); } return $this->setAttribute('rejectedBeforeTransactionProcessPolicy', $value); }
@param string $value @return $this
public function setRejectedAfterTransactionProcessPolicy($value): self { if (!in_array($value, self::rejectedAfterTransactionProcessPolicies(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_POLICY, implode(', ', self::rejectedAfterTransactionProcessPolicies()))); } return $this->setAttribute('rejectedAfterTransactionProcessPolicy', $value); }
@param string $value @return $this
public function setOptionalPolicy($value): self { if (!in_array($value, self::optionalPolicies(), true)) { throw new DomainException(sprintf(self::UNEXPECTED_POLICY, implode(', ', self::optionalPolicies()))); } return $this->setAttribute('optionalPolicy', $value); }
@param string $value @return $this
public static function createFromData(array $data): self { if (!isset($data['name'])) { throw new DomainException(self::REQUIRED_NAME); } switch ($data['name']) { case self::NAME_BLACKLIST: $action = new Actions\Blacklist($data); break; case self::NAME_CANCEL_SCHEDULED_PAYMENTS: $action = new Actions\CancelScheduledPayments($data); break; case self::NAME_GUESS_PAYMENT_CARD_EXPIRATION: $action = new Actions\GuessPaymentCardExpiration($data); break; case self::NAME_PICK_GATEWAY_ACCOUNT: $action = new Actions\PickGatewayAccount($data); break; case self::NAME_SCHEDULE_PAYMENT_RETRY: $action = new Actions\SchedulePaymentRetry($data); break; case self::NAME_SCHEDULE_PAYMENT: $action = new Actions\SchedulePayment($data); break; case self::NAME_SCHEDULE_INVOICE_RETRY: $action = new Actions\ScheduleInvoiceRetry($data); break; case self::NAME_SEND_EMAIL: $action = new Actions\SendEmail($data); break; case self::NAME_TRIGGER_WEBHOOK: $action = new Actions\TriggerWebhook($data); break; case self::NAME_STOP_SUBSCRIPTIONS: $action = new Actions\StopSubscriptions($data); break; case self::NAME_ADD_RISK_SCORE: $action = new Actions\AddRiskScore($data); break; case self::NAME_REQUEST_KYC: $action = new Actions\RequestKyc($data); break; case self::NAME_TAG_OR_UNTAG_CUSTOMER: $action = new Actions\TagOrUntagCustomer($data); break; default: throw new DomainException( sprintf(self::UNEXPECTED_NAME, implode(', ', self::names())) ); } return $action; }
@param array $data @return RuleAction
public function filter($attribute, $value) { $filter = $attribute . ':' . (is_array($value) ? implode(',', $value) : $value); if ($this->offsetExists('filter')) { $filter = $this->offsetGet('filter') . ';' . $filter; } $this->offsetSet('filter', $filter); return $this; }
@param string $attribute @param mixed $value @return $this
public function filterRange($attribute, $startValue, $endValue) { $filter = $startValue . '..' . $endValue; return $this->filter($attribute, $filter); }
@param string $attribute @param mixed $startValue @param mixed $endValue @return $this
public function sort($attribute, $direction = SORT_ASC) { if ($direction === SORT_DESC) { $attribute = '-' . $attribute; } if ($this->offsetExists('sort')) { $attribute = $this->offsetGet('sort') . ',' . $attribute; } $this->offsetSet('sort', $attribute); return $this; }
@param string $attribute @param int $direction @return $this
public function setAccountType($value) { $allowedAccountTypes = self::allowedAccountTypes(); if (!in_array($value, $allowedAccountTypes, true)) { throw new DomainException(sprintf(self::MSG_UNEXPECTED_ACCOUNT_TYPE, implode(', ', $allowedAccountTypes))); } return $this->setAttribute('accountType', $value); }
@param string $value @return $this
public function create($data, $cardId = null) { if (isset($cardId)) { return $this->client()->put($data, 'payment-cards/{cardId}', ['cardId' => $cardId]); } return $this->client()->post($data, 'payment-cards'); }
@param array|JsonSerializable|PaymentCard $data @param string $cardId @throws UnprocessableEntityException The input data does not valid @return PaymentCard
public function createFromToken($token, $data, $cardId = null) { if ($data instanceof JsonSerializable) { $data = $data->jsonSerialize(); } if (is_string($token)) { $data['token'] = $token; } else { $data['token'] = $token['token']; } return $this->create($data, $cardId); }
@param string|array|JsonSerializable|PaymentCardToken $token @param array|JsonSerializable|PaymentCard $data @param string $cardId @throws UnprocessableEntityException The input data does not valid @return PaymentCard
public function open($url = null) { $this->handle = curl_init($url); return $this->handle !== false; }
@param string|null $url @return bool
public function setPaymentInstrument(PaymentInstrument $value) { $this->setAttribute('method', $value->name()); $this->setAttribute('paymentInstrument', $value->jsonSerialize()); return $this; }
@todo Rewrite ApiTest, which requires this method before deprecated methods. @param PaymentInstrument $value @return $this
private function setDefaultPaymentInstrumentValue($attribute, $value) { $data = (array) $this->getAttribute('paymentInstrument'); $data[$attribute] = $value; $this->setAttribute('method', PaymentMethod::METHOD_PAYMENT_CARD); $this->setAttribute('paymentInstrument', $data); return $this; }
@param $attribute @param $value @return $this
public function create($data, $websiteId = null) { if (isset($websiteId)) { return $this->client()->put($data, 'websites/{websiteId}', ['websiteId' => $websiteId]); } return $this->client()->post($data, 'websites'); }
@param array|JsonSerializable|Website $data @param string $websiteId @throws UnprocessableEntityException The input data does not valid @return Website
public function create($data, $customerId = null) { if (isset($customerId)) { return $this->client()->put($data, 'customers/{customerId}', ['customerId' => $customerId]); } return $this->client()->post($data, 'customers'); }
@param array|JsonSerializable|Customer $data @param string $customerId @throws UnprocessableEntityException The input data does not valid @return Customer
public static function createFromData(array $data) { if (!isset($data['formula'])) { throw new DomainException(self::REQUIRED_FORMULA); } switch ($data['formula']) { case self::FLAT_RATE: return new Pricing\FlatRate($data); case self::FIXED_FEE: return new Pricing\FixedFee($data); case self::STAIRSTEP: return new Pricing\Stairstep($data); case self::TIERED: return new Pricing\Tiered($data); case self::VOLUME: return new Pricing\Volume($data); default: throw new DomainException(sprintf(self::UNSUPPORTED_FORMULA, implode(',', self::getAvailableFormulas()))); } }
@param array $data @return Pricing\FlatRate|Pricing\FixedFee|Pricing\Stairstep|Pricing\Tiered|Pricing\Volume
public function getContacts($limit = null, $starting_after = null, $ending_before = null) { list($response) = $this->getContactsWithHttpInfo($limit, $starting_after, $ending_before); return $response; }
Operation getContacts @param int $limit limit (optional) @param string $starting_after starting_after (optional) @param string $ending_before ending_before (optional) @throws \Clever\ApiException on non-2xx response @throws \InvalidArgumentException @return \Clever\Model\ContactsResponse
public function getContactsAsync($limit = null, $starting_after = null, $ending_before = null) { return $this->getContactsAsyncWithHttpInfo($limit, $starting_after, $ending_before) ->then( function ($response) { return $response[0]; } ); }
Operation getContactsAsync @param int $limit (optional) @param string $starting_after (optional) @param string $ending_before (optional) @throws \InvalidArgumentException @return \GuzzleHttp\Promise\PromiseInterface
public function getContactsForStudent($id, $limit = null, $starting_after = null, $ending_before = null) { list($response) = $this->getContactsForStudentWithHttpInfo($id, $limit, $starting_after, $ending_before); return $response; }
Operation getContactsForStudent @param string $id id (required) @param int $limit limit (optional) @param string $starting_after starting_after (optional) @param string $ending_before ending_before (optional) @throws \Clever\ApiException on non-2xx response @throws \InvalidArgumentException @return \Clever\Model\ContactsResponse
public function getContactsForStudentAsync($id, $limit = null, $starting_after = null, $ending_before = null) { return $this->getContactsForStudentAsyncWithHttpInfo($id, $limit, $starting_after, $ending_before) ->then( function ($response) { return $response[0]; } ); }
Operation getContactsForStudentAsync @param string $id (required) @param int $limit (optional) @param string $starting_after (optional) @param string $ending_before (optional) @throws \InvalidArgumentException @return \GuzzleHttp\Promise\PromiseInterface
public function getCourses($limit = null, $starting_after = null, $ending_before = null) { list($response) = $this->getCoursesWithHttpInfo($limit, $starting_after, $ending_before); return $response; }
Operation getCourses @param int $limit limit (optional) @param string $starting_after starting_after (optional) @param string $ending_before ending_before (optional) @throws \Clever\ApiException on non-2xx response @throws \InvalidArgumentException @return \Clever\Model\CoursesResponse
public function getCoursesAsync($limit = null, $starting_after = null, $ending_before = null) { return $this->getCoursesAsyncWithHttpInfo($limit, $starting_after, $ending_before) ->then( function ($response) { return $response[0]; } ); }
Operation getCoursesAsync @param int $limit (optional) @param string $starting_after (optional) @param string $ending_before (optional) @throws \InvalidArgumentException @return \GuzzleHttp\Promise\PromiseInterface
public function getDistrictAdmins($limit = null, $starting_after = null, $ending_before = null) { list($response) = $this->getDistrictAdminsWithHttpInfo($limit, $starting_after, $ending_before); return $response; }
Operation getDistrictAdmins @param int $limit limit (optional) @param string $starting_after starting_after (optional) @param string $ending_before ending_before (optional) @throws \Clever\ApiException on non-2xx response @throws \InvalidArgumentException @return \Clever\Model\DistrictAdminsResponse
public function getDistrictAdminsAsync($limit = null, $starting_after = null, $ending_before = null) { return $this->getDistrictAdminsAsyncWithHttpInfo($limit, $starting_after, $ending_before) ->then( function ($response) { return $response[0]; } ); }
Operation getDistrictAdminsAsync @param int $limit (optional) @param string $starting_after (optional) @param string $ending_before (optional) @throws \InvalidArgumentException @return \GuzzleHttp\Promise\PromiseInterface