sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function charge() { return !is_null($this->transactionRef) ? $this->getTransactionResource()->chargeAuthorization($this->_requestPayload()) : new PaystackInvalidTransactionException( json_decode( json_encode( [ 'message' => 'Transaction Reference Not Generated.', ] ), false ) ); }
Charge returning transaction. @return \Exception|mixed|PaystackInvalidTransactionException
entailment
public function _requestPayload() { $payload = [ 'authorization_code' => $this->authorization, 'amount' => $this->amount, 'reference' => $this->transactionRef, 'email' => $this->email, ]; if (!empty($this->plan)) { $payload['plan'] = $this->plan; } return $this->toJson($payload); }
Get returning transaction request body. @return string
entailment
private function filtersDefaultOperators(array $filters): array { foreach ($filters as $key => $filter) { // give the filter default operators, according to its type if ( (!array_key_exists('operators', $filter)) || (empty($filter['operators'])) ) { $builderType = $filter['type']; switch ($builderType) { case 'string': $filter['operators'] = [ 'equal', 'not_equal', 'is_null', 'is_not_null', 'begins_with', 'not_begins_with', 'contains', 'not_contains', 'ends_with', 'not_ends_with', 'is_empty', 'is_not_empty', // specific to strings ]; break; case 'integer': case 'double': case 'date': case 'time': case 'datetime': $filter['operators'] = [ 'equal', 'not_equal', 'is_null', 'is_not_null', 'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between', 'not_between', // specific to numbers and dates ]; break; case 'boolean': $filter['operators'] = [ 'equal', 'not_equal', 'is_null', 'is_not_null', ]; break; } } $filters[$key] = $filter; } return $filters; }
@param array $filters @return array
entailment
private function filtersOverrides(array $filters, string $builderId): array { foreach ($filters as $key => $filter) { $filterId = $filter['id']; $filterValueCollection = new FilterValueCollection(); $filterInput = new FilterInput(FilterInput::INPUT_TYPE_TEXT); $filterOperators = new FilterOperators(); foreach ($filter['operators'] as $operator) { $filterOperators->addOperator($operator); } $this->dispatcher->dispatch(FilterSetEvent::EVENT_NAME, new FilterSetEvent($filterInput, $filterOperators, $filterValueCollection, $filterId, $builderId)); $this->validateValueCollectionAgainstInput($filterValueCollection, $filterInput, $filterId, $builderId); $valuesArray = []; foreach ($filterValueCollection->getFilterValues() as $filterValue) { $valuesArray[$filterValue->getValue()] = $filterValue->getLabel(); } $filters[$key]['values'] = $valuesArray; $filters[$key]['input'] = $filterInput->getInputType(); $filters[$key]['operators'] = $filterOperators->getOperators(); } return $filters; }
@param array $filters @param string $builderId @return array @throws \LogicException
entailment
private function filtersBooleanOverride(array $filters): array { foreach ($filters as $key => $filter) { $builderType = $filter['type']; switch ($builderType) { case 'boolean': $filter['values'] = [ 1 => 'Yes', 0 => 'No', ]; $filter['input'] = 'radio'; $filter['colors'] = [ 1 => 'success', 0 => 'danger', ]; break; } $filters[$key] = $filter; } return $filters; }
@param array $filters @return array
entailment
private function filtersDateOverrides(array $filters): array { foreach ($filters as $key => $filter) { $builderType = $filter['type']; switch ($builderType) { case 'date': $filter['validation'] = [ 'format' => 'YYYY/MM/DD', ]; $filter['plugin'] = 'datetimepicker'; $filter['plugin_config'] = [ 'format' => 'YYYY/MM/DD', ]; break; case 'datetime': $filter['validation'] = [ 'format' => 'YYYY/MM/DD HH:mm', ]; $filter['plugin'] = 'datetimepicker'; $filter['plugin_config'] = [ 'format' => 'YYYY/MM/DD HH:mm', ]; break; case 'time': $filter['validation'] = [ 'format' => 'HH:mm', ]; $filter['plugin'] = 'datetimepicker'; $filter['plugin_config'] = [ 'format' => 'HH:mm', ]; break; } $filters[$key] = $filter; } return $filters; }
Use with @link https://eonasdan.github.io/bootstrap-datetimepicker/ Also make sure to account for @link https://github.com/mistic100/jQuery-QueryBuilder/issues/176. @param array $filters @return array
entailment
private function filtersOverrideValues(array $filters): array { foreach ($filters as $key => $filter) { // Php converts an array such as ["0" => "red", "1" => "green"] into [0 => "red", 1 => "green"] // Thus the json_encoding would be ["red", "green"] instead of {"0" : "red", "1" : "green"} // A way around this is casting the array as an object $filters[$key]['values'] = (object) $filters[$key]['values']; } return $filters; }
@param array $filters @return array
entailment
private function validateValueCollectionAgainstInput(FilterValueCollection $collection, FilterInput $input, string $filterId, string $builderId) { if ( in_array($input->getInputType(), FilterInput::INPUT_TYPES_REQUIRE_NO_VALUES) && 0 !== $collection->getFilterValues()->count() ) { throw new \LogicException(sprintf( 'Too many values found, While building, Builder with ID %s and Filter with ID %s.', $builderId, $filterId )); } if ( in_array($input->getInputType(), FilterInput::INPUT_TYPES_REQUIRE_MULTIPLE_VALUES) && 0 === $collection->getFilterValues()->count() ) { throw new \LogicException(sprintf( 'Not enough values found, While building, Builder with ID %s and Filter with ID %s.', $builderId, $filterId )); } }
@param FilterValueCollection $collection @param FilterInput $input @param string $filterId @param string $builderId @throws \LogicException
entailment
public function getBuilderById(string $builderId) { if (array_key_exists($builderId, $this->builders)) { return $this->builders[$builderId]; } return; }
@param string $builderId @return Builder|null
entailment
public static function getRealToken(Oauth_TokenModel $token) { $provider = craft()->oauth->getProvider($token->providerHandle); if($provider) { switch($provider->getOauthVersion()) { case 1: return $provider->createAccessToken([ 'identifier' => $token->accessToken, 'secret' => $token->secret, ]); case 2: return $provider->createAccessToken([ 'access_token' => $token->accessToken, 'refresh_token' => $token->refreshToken, 'secret' => $token->secret, 'expires' => $token->endOfLife, ]); } } }
Get real token
entailment
public static function realTokenToArray($token) { $class = get_class($token); $tokenArray = array( 'class' => $class, // 'extraParams' => $token->getExtraParams(), ); if(get_class($token) === 'League\OAuth1\Client\Credentials\TokenCredentials' || is_subclass_of($token, '\League\OAuth1\Client\Credentials\TokenCredentials')) { // OAuth 1.0 $tokenArray['identifier'] = $token->getIdentifier(); $tokenArray['secret'] = $token->getSecret(); } elseif(get_class($token) === 'League\OAuth2\Client\Token\AccessToken' || is_subclass_of($token, '\League\OAuth2\Client\Token\AccessToken')) { // OAuth 2.0 $tokenArray['accessToken'] = $token->getToken(); $tokenArray['refreshToken'] = $token->getRefreshToken(); $tokenArray['endOfLife'] = $token->getExpires(); } return $tokenArray; }
Real token to array
entailment
public function getProductEmails($product_model){ // Set method and action $method = 'email'; $action = 'GetProductEmails'; // Set data if(empty($product_model)) $data = array(); else $data = array('product_model' => $product_model); $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia email-urile fara raspuns despre produse (https://github.com/celdotro/marketplace/wiki/Preia-email-urile-despre-produse) [EN] Retrieve all unanswered emails about products (https://github.com/celdotro/marketplace/wiki/Retrieve-products-emails) @param $product_model @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function answerProductEmail($questionID, $answer){ // Sanity check if(empty($questionID)) throw new \Exception('Specificati un ID valid al intrebarii'); if(empty($answer) || strlen(trim($answer)) < 10) throw new \Exception('Specificati un raspuns valid mai mare de 10 caractere diferite de spatiu'); // Set method and action $method = 'email'; $action = 'AnswerProductEmail'; // Set data $data = array('questionID' => $questionID, 'answer' => $answer); $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Trimite un raspuns catre email-ul unui client referitor la un anumit produs (https://github.com/celdotro/marketplace/wiki/Raspunde-email-ului-unui-produs) [EN] Answer a specific email for a product (https://github.com/celdotro/marketplace/wiki/Answer-a-specific-email-for-a-product) @param $questionID @param $answer @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getServiceRequests($minDate = null, $maxDate = null, $product_model = null, $start = null){ // Set method and action $method = 'email'; $action = 'GetServiceRequests'; // Set data $data = array('dummy' => 1); if (!is_null($minDate)) $data['minDate'] = $minDate; if (!is_null($maxDate)) $data['maxDate'] = $maxDate; if (!is_null($product_model)) $data['product_model'] = $product_model; if (!is_null($start)) $data['start'] = $start; $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia cererile de service aferente afiliatului (https://github.com/celdotro/marketplace/wiki/Preia-cererile-de-retur) [EN] Get service requests for the current affiliate (https://github.com/celdotro/marketplace/wiki/Get-return-requests) @param null $minDate @param null $maxDate @param null $product_model @param null $start @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function answerServiceRequest($id, $answer, $images = null){ // Set method and action $method = 'email'; $action = 'AnswerServiceRequest'; // Set data $data = array( 'id' => $id, 'answer' => $answer ); $result = Dispatcher::send($method, $action, $data, $images); return $result; }
[RO] Raspunde unei cereri de service (https://github.com/celdotro/marketplace/wiki/Raspunde-unei-cereri-de-service) [EN] Send an answer to a service request (https://github.com/celdotro/marketplace/wiki/Answer-service-request) @param $id @param $answer @param null $images @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getOrderContact($orders_id){ // Set method and action $method = 'email'; $action = 'GetOrderContact'; // Set data $data = array('orders_id' => $orders_id); $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia intrebarile despre o comanda (https://github.com/celdotro/marketplace/wiki/Preia-intrebari-comanda) [EN] Get order's questions (https://github.com/celdotro/marketplace/wiki/Get-order-questions) @param $orders_id @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function answerOrderContact($id, $answer){ // Set method and action $method = 'email'; $action = 'AnswerOrderContact'; // Set data $data = array( 'id' => $id, 'answer' => $answer ); $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Trimite raspuns unei intrebari aferenta comenzii (https://github.com/celdotro/marketplace/wiki/Raspunde-intrebarii-comenzii) [EN] Give an answer to an order's question (https://github.com/celdotro/marketplace/wiki/Answer-order-question) @param $id @param $answer @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getServiceRequest($uniqueID){ // Set method and action $method = 'email'; $action = 'GetServiceRequest'; // Set data $data = array('uniqueID' => $uniqueID); $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia datele unei cereri de service (https://github.com/celdotro/marketplace/wiki/Preia-cerere-service) [EN] Get the data of a service request (https://github.com/celdotro/marketplace/wiki/Get-service-request) @param $uniqueID @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getReturnRequest($uniqueID){ // Set method and action $method = 'email'; $action = 'GetReturnRequest'; // Set data $data = array('uniqueID' => $uniqueID); $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia datele unei cereri de retur (https://github.com/celdotro/marketplace/wiki/Preia-cerere-retur) [EN] Get the data of a return request (https://github.com/celdotro/marketplace/wiki/Get-return-request) @param $uniqueID @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function get($attributes) { //get function args $argsAsArray = func_get_args(); //is attributes passed as args is an array and count greater than 1 if (!is_array($attributes) && count($argsAsArray) > 1) { //recalls itself to get attributes as array return call_user_func([get_class(), 'get'], $argsAsArray); } //if just args is not an array or comma separated list if (!is_array($attributes) && count($argsAsArray) == 1) { return isset($this->{$attributes}) ? $this->{$attributes} : null; } $attributesGet = []; foreach ($attributes as $attribute) { $attributesGet[$attribute] = isset($this->{$attribute}) ? $this->{$attribute} : null; } return $attributesGet; }
Get specific model attribute(s) Accepts array of attributes, comma separated attributes or individual attribute. @param $attributes @return mixed
entailment
public function _setAttributes($attributes) { if (is_array($attributes)) { foreach ($attributes as $attribute => $value) { $this->{$attribute} = $value; } return $this; } //@todo: put real exception here cos exception' gon be thrown either ways, so put one that makes sense //or something else that has more meaning throw new \InvalidArgumentException('Invalid argument Passed to set attributes on object'); }
Set attributes of the model. @param $attributes @throws \Exception @return $this
entailment
public function transform($transformMode = '') { switch ($transformMode) { case ModelInterface::TRANSFORM_TO_JSON_ARRAY: return json_encode($this->objectToArray($this)); default: return $this->objectToArray($this); } }
get Outward presentation of object. @param $transformMode @return mixed
entailment
public function isTranslable() { if ($this->getPath() === null) { $this->detectUrlDetails(); } foreach ($this->config->getExcludedUrls() as $regex) { $escapedRegex = Text::escapeForRegex(Text::fullTrim($regex)); $fullRegex = sprintf('/%s/', $escapedRegex); if (preg_match($fullRegex, $this->getPath()) === 1) { return false; } } return true; }
Check if we need to translate given URL @return bool
entailment
public function detectCurrentLanguage() { // parsing url to get only path & removing prefix if there is one $escapedPathPrefix = Text::escapeForRegex($this->config->getPathPrefix()); $uriPath = parse_url($this->config->getRaw(), PHP_URL_PATH); $uriPath = preg_replace('/^' . $escapedPathPrefix . '/s', '', $uriPath); $uriSegments = explode('/', $uriPath); if (isset($uriSegments[1]) && in_array($uriSegments[1], $this->translate->getLanguages())) { return $uriSegments[1]; } return $this->translate->getDefault(); }
Check current locale, based on URI segments from the given URL @return mixed
entailment
public function detectUrlDetails() { $escapedPathPrefix = Text::escapeForRegex($this->config->getPathPrefix()); $languages = implode('|', $this->translate->getLanguages()); $fullUrl = preg_replace('#' . $escapedPathPrefix . '\/(' . $languages . ')$#i', '', $this->getUrl()); $fullUrl = preg_replace('#' . $escapedPathPrefix . '\/(' . $languages . ')\/#i', '/', $fullUrl); $parsed = parse_url($fullUrl); $this->host = $parsed['scheme'] . '://' . $parsed['host'] . (isset($parsed['port']) ? ':'.$parsed['port'] : ''); $this->path = isset($parsed['path']) ? $parsed['path'] : '/'; $this->query = isset($parsed['query']) ? $parsed['query'] : null; if (preg_match('#^' .$this->config->getPathPrefix(). '#i', $this->path)) { $this->path = preg_replace('#^' .$this->config->getPathPrefix(). '#i', '', $this->path); } if ($this->path === "") { $this->path = '/'; } $url = $this->getHost() . $this->getPathPrefix() . $this->getPath(); if (!is_null($this->getQuery())) { $url .= '?'. $this->getQuery(); } return $url; }
Generate possible host & base URL then store it into internal variables @return string Host + path prefix + base URL
entailment
public function currentRequestAllUrls() { $urls = $this->allUrls; if ($urls === null) { if ($this->getPath() === null) { $this->detectUrlDetails(); } $urls = []; $current = $this->getHost() . $this->config->getPathPrefix() . $this->getPath(); if (!is_null($this->getQuery())) { $current .= '?'. $this->getQuery(); } $urls[$this->translate->getDefault()] = $current; foreach ($this->translate->getLanguages() as $language) { $current = $this->getHost() . $this->config->getPathPrefix() . '/' . $language . $this->getPath(); if (!is_null($this->getQuery())) { $current .= '?'. $this->getQuery(); } $urls[$language] = $current; } $this->allUrls = $urls; } return $urls; }
Returns array with all possible URL for current Request @return array
entailment
public function generateHrefLangsTags() { $render = ''; $urls = $this->currentRequestAllUrls(); foreach ($urls as $language => $url) { $render .= '<link rel="alternate" href="' .$url. '" hreflang="' .$language. '"/>'."\n"; } return $render; }
Render hreflang links for SEO @return string
entailment
public function addAddress($address = null, $id_curier = null, $accData = array()){ // Sanity check if(is_null($address) || $address === '') throw new \Exception('Specificati o adresa valida'); // Set method and action $method = 'admininfo'; $action = 'editAddress'; // Set data $data = array( 'address' => $address, 'accData' => $accData ); if(!is_null($id_curier)) $data['courier'] = $id_curier; // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Adauga o adresa pentru ridicarea coletelor de catre curieri (https://github.com/celdotro/marketplace_examples/blob/master/Admin/4.addAddress.php) [EN] Adds a new pick-up address that will be sent to couriers (https://github.com/celdotro/marketplace_examples/blob/master/Admin/4.addAddress.php) @param null $address @param null $id_curier @param array $accData @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function editAddress($id = null, $address = null, $courier){ // Sanity check if(is_null($address) || $address === '') throw new \Exception('Specificati o adresa valida'); if(is_null($id) || !is_numeric($id)) throw new \Exception('Specificati un ID valid'); // Set method and action $method = 'admininfo'; $action = 'editAddress'; // Set data $data = array('id' => $id, 'address' => $address, 'courier' => $courier); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Actualizeaza adresa unui punct de ridicare pentru curieri (https://github.com/celdotro/marketplace_examples/blob/master/Admin/5.editAddress.php) [EN] Updates address information of a pick-up point (https://github.com/celdotro/marketplace_examples/blob/master/Admin/5.editAddress.php) @param null $id @param null $address @param $courier @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function listAddresses(){ // Set method and action $method = 'admininfo'; $action = 'listAddresses'; // Set data $data = array('param' => 1); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Listeaza toate adresele punctelor de ridicare pentru curieri (https://github.com/celdotro/marketplace_examples/blob/master/Admin/6.listAddresses.php) [EN] Lists all pick-up points addresses (https://github.com/celdotro/marketplace_examples/blob/master/Admin/6.listAddresses.php) @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function deleteAddress($id = null, $address = null){ // Sanity check if(is_null($id) || !is_numeric($id)) throw new \Exception('Specificati un ID valid'); // Set method and action $method = 'admininfo'; $action = 'deleteAddress'; // Set data $data = array('id' => $id); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Stergerea adresei unui punct de ridicare pentru curieri (https://github.com/celdotro/marketplace_examples/blob/master/Admin/7.deleteAddress.php) [EN] Delete a pick-up point's address (https://github.com/celdotro/marketplace_examples/blob/master/Admin/7.deleteAddress.php) @param null $id @param null $address @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function addCourier($name){ // Set method and action $method = 'admininfo'; $action = 'addCourier'; // Set data $data = array('name' => $name); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Trimite email pentru adaugarea unui nou curier (https://github.com/celdotro/marketplace/wiki/Adauga-curier) [EN] Sends an email with a request to add a new courier (https://github.com/celdotro/marketplace/wiki/Add-courier) @param $name @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function savePage($pageID, $pageData){ // Sanity check if(!isset($pageID) || !is_int($pageID)) throw new \Exception('Specificati un ID al paginii'); if(!isset($pageData) || !is_array($pageData) || empty($pageData)) throw new \Exception('$pages trebuie sa contina un array cu datele paginii'); // Set method and action $method = 'settings'; $action = 'savePage'; $data = array( 'id' => $pageID ); foreach($pageData as $key => $value){ $data[$key] = $value; } // Set data // $data = array($data); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Salveaza datele paginii (https://github.com/celdotro/marketplace/wiki/Salvare-pagina) [EN] Save page data (https://github.com/celdotro/marketplace/wiki/Save-pages) @param $pageID @param $pageData @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function actionIndex() { $providers = craft()->oauth->getProviders(false); $allProviderInfos = []; foreach($providers as $provider) { $allProviderInfos[$provider->getHandle()] = craft()->oauth->getProviderInfos($provider->getHandle()); } $variables['providers'] = $providers; $variables['allProviderInfos'] = $allProviderInfos; $this->renderTemplate('oauth/providers/_index', $variables); }
Providers Index @return null
entailment
public function actionProviderInfos(array $variables = array()) { if(!empty($variables['handle'])) { $provider = craft()->oauth->getProvider($variables['handle'], false, true); if($provider) { $variables['infos'] = craft()->oauth->getProviderInfos($variables['handle']);; $variables['provider'] = $provider; $configInfos = craft()->config->get('providerInfos', 'oauth'); if(!empty($configInfos[$variables['handle']])) { $variables['configInfos'] = $configInfos[$variables['handle']]; } $this->renderTemplate('oauth/providers/_edit', $variables); } else { throw new HttpException(404); } } else { throw new HttpException(404); } }
Edit Provider @return null
entailment
public function actionProviderSave() { $handle = craft()->request->getParam('handle'); $attributes = craft()->request->getPost('provider'); $provider = craft()->oauth->getProvider($handle, false); $providerInfos = new Oauth_ProviderInfosModel($attributes); $providerInfos->id = craft()->request->getParam('providerId'); $providerInfos->class = $handle; if (craft()->oauth->providerSave($providerInfos)) { craft()->userSession->setNotice(Craft::t('Service saved.')); $redirect = craft()->request->getPost('redirect'); $this->redirect($redirect); } else { craft()->userSession->setError(Craft::t("Couldn't save service.")); craft()->urlManager->setRouteVariables(array('infos' => $providerInfos)); } }
Save provider @return null
entailment
public function updateAccountInformation ($cif = NULL, $iban = NULL, $telephone = NULL, $password = NULL, $bankName = NULL, $fullName = NULL, $hqAddress = NULL, $description = NULL, $apiLink = NULL, $contactPerson, $county, $city, $reg) { // Sanity check - skip it because it needs additional methods and packages which will just bloat this project // All proper checks for data integrity are done on our server // Set method and action $method = 'admininfo'; $action = 'updateAccountInformation'; // Set data $data = array(); if(!is_null($cif)) $data['cif'] = $cif; if(!is_null($iban)) $data['iban'] = $iban; if(!is_null($telephone)) $data['telephone'] = $telephone; if(!is_null($password)) $data['password'] = $password; if(!is_null($bankName)) $data['bankName'] = $bankName; if(!is_null($fullName)) $data['fullName'] = $fullName; if(!is_null($hqAddress)) $data['hqAddress'] = $hqAddress; if(!is_null($description)) $data['description'] = $description; if(!is_null($apiLink)) $data['apiLink'] = $apiLink; $data['person'] = $contactPerson; $data['county'] = $county; $data['city'] = $city; $data['reg'] = $reg; if(empty($data)) throw new \Exception('Specificati cel putin 1 camp'); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Actualizeaza urmatoarele date aferente afiliatului: CIF, IBAN, numar de telefon, parola, denumirea bancii, denumire completa, adresa sediu, api link si scurta descriere (https://github.com/celdotro/marketplace/wiki/Actualizare-informatii-cont) [EN] Updates the following data of an affiliate: CIF, IBAN, phone number, password, bank's name, full name, headquarter's address, api link, and short description (https://github.com/celdotro/marketplace/wiki/Actualizare-informatii-cont) @param null $cif @param null $iban @param null $telephone @param null $password @param null $bankName @param null $fullName @param null $hqAddress @param null $description @param null $apiLink @param $contactPerson @param $county @param $city @param $reg @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function markAsSeen($id){ // Set method and action $method = 'admininfo'; $action = 'markAsSeen'; // Send request and retrieve response $result = Dispatcher::send($method, $action, array('id' => $id)); return $result; }
[RO] Marcheaza o notificare drept citita (https://github.com/celdotro/marketplace/wiki/Marcheaza-drept-citita) [EN] Marks a notification as seen (https://github.com/celdotro/marketplace/wiki/Mark-as-seen) @param $id @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function safeUp() { $tokensTable = $this->dbConnection->schema->getTable('{{oauth_tokens}}'); if ($tokensTable) { if (($userMappingColumn = $tokensTable->getColumn('userMapping')) == null) { OauthPlugin::log('Adding `userMapping` column to the `oauth_tokens` table.', LogLevel::Info, true); $this->addColumnAfter('oauth_tokens', 'userMapping', array(AttributeType::String, 'required' => false), 'userId'); OauthPlugin::log('Added `userMapping` column to the `oauth_tokens` table.', LogLevel::Info, true); } else { OauthPlugin::log('Tried to add a `userMapping` column to the `oauth_tokens` table, but there is already one there.', LogLevel::Warning); } } else { OauthPlugin::log('Could not find an `oauth_tokens` table. Wut?', LogLevel::Error); } return true; }
Any migration code in here is wrapped inside of a transaction. @return bool
entailment
public function safeUp() { // unique index for 'userMapping' and 'provider' $tableName = 'oauth_tokens'; $providersTable = $this->dbConnection->schema->getTable('{{'.$tableName.'}}'); if ($providersTable) { $columns = 'userMapping, provider'; $unique = true; $this->createIndex($tableName, $columns, $unique); } else { OauthPlugin::log('Could not find an `'.$tableName.'` table. Wut?', LogLevel::Error); } // unique index for 'userId' and 'provider' $tableName = 'oauth_tokens'; $providersTable = $this->dbConnection->schema->getTable('{{'.$tableName.'}}'); if ($providersTable) { $columns = 'userId, provider'; $unique = true; $this->createIndex($tableName, $columns, $unique); } else { OauthPlugin::log('Could not find an `'.$tableName.'` table. Wut?', LogLevel::Error); } // unique index for 'namespace' and 'provider' $tableName = 'oauth_tokens'; $providersTable = $this->dbConnection->schema->getTable('{{'.$tableName.'}}'); if ($providersTable) { $columns = 'namespace, provider'; $unique = true; $this->createIndex($tableName, $columns, $unique); } else { OauthPlugin::log('Could not find an `'.$tableName.'` table. Wut?', LogLevel::Error); } return true; }
Any migration code in here is wrapped inside of a transaction. @return bool
entailment
protected function type(\DOMNode $node) { $type = null; switch ($node->localName) { case 'alt': $type = WordType::IMG_ALT; break; case 'src': $type = WordType::IMG_SRC; break; } return $type; }
{@inheritdoc}
entailment
public function createProvider() { $config = [ 'clientId' => $this->providerInfos->clientId, 'clientSecret' => $this->providerInfos->clientSecret, 'redirectUri' => $this->getRedirectUri(), ]; return new \Dukt\OAuth2\Client\Provider\Vimeo($config); }
Create Vimeo Provider @return Vimeo
entailment
public function createProvider() { $config = [ 'clientId' => $this->providerInfos->clientId, 'clientSecret' => $this->providerInfos->clientSecret, 'redirectUri' => $this->getRedirectUri(), ]; return new \League\OAuth2\Client\Provider\Instagram($config); }
Creates the provider. @return Instagram
entailment
public function getInvoicesData($paymentStatus, $numInvoice = NULL, $startDate_inv = NULL, $endDate_inv = NULL, $numOrder = NULL, $startDate_order = NULL, $endDate_order = NULL, $page = NULL){ // Sanity check if (!isset($paymentStatus) || is_null($paymentStatus) || !in_array($paymentStatus, array(1,2,3))) throw new \Exception('Specificati un status valid al platilor'); // Set method and action $method = 'admininfo'; $action = 'getInvoicesData'; // Set data $data = array('paymentStatus' => $paymentStatus); if(!is_null($numInvoice)) $data['nrFact'] = $numInvoice; if(!is_null($startDate_inv)) $data['startDate_fact'] = $startDate_inv; if(!is_null($endDate_inv)) $data['endDate_fact'] = $endDate_inv; if(!is_null($numOrder)) $data['nrCmd'] = $numOrder; if(!is_null($startDate_order)) $data['startDate_cmd'] = $startDate_order; if(!is_null($endDate_order)) $data['endDate_cmd'] = $endDate_order; if(!is_null($page)) $data['page'] = $page; // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Returneaza date despre platile efectuate catre afiliat pentru fiecare factura (https://github.com/celdotro/marketplace/wiki/Date-plati-facturi) [EN] Returns data about the payments done in an affiliate's account for each invoice (https://github.com/celdotro/marketplace/wiki/Invoices-payment-data) @param $paymentStatus @param null $numInvoice @param null $startDate_inv @param null $endDate_inv @param null $numOrder @param null $startDate_order @param null $endDate_order @param null $page @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function showPayments($numInvoice, $numOrder){ // Sanity check if (!isset($numInvoice) || is_null($numInvoice)) throw new \Exception ('Specificati numarul facturii'); if (!isset($numInvoice) || is_null($numOrder)) throw new \Exception ('Specificati numarul comenzii'); // Set method and action $method = 'admininfo'; $action = 'showPayments'; // Set data $data = array( 'numInvoice' => $numInvoice, 'numOrder' => $numOrder ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Returneaza date despre platile efectuate pe baza unei facturi (https://github.com/celdotro/marketplace/wiki/Date-plati-pentru-o-factura) [EN] Returns an invoice's payments and other relevant data (https://github.com/celdotro/marketplace/wiki/Detailed-payment-data-for-an-invoice) @param $numInvoice @param $numOrder @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
protected function defineAttributes() { $attributes = array( 'id' => AttributeType::Number, 'providerHandle' => AttributeType::String, 'pluginHandle' => AttributeType::String, 'accessToken' => AttributeType::String, 'secret' => AttributeType::String, 'endOfLife' => AttributeType::String, 'refreshToken' => AttributeType::String, ); return $attributes; }
Define Attributes
entailment
public function setClassName(string $className): self { if (!class_exists($className)) { throw new \InvalidArgumentException(sprintf( 'Class %s does not exist', $className )); } $this->className = $className; return $this; }
@param string $className @return Builder
entailment
public function addResultColumn(ResultColumn $resultColumn): self { // prevent columns with the same machine_name or human_readable_name to be added foreach ($this->resultColumns as $column) { /** @var ResultColumn $column */ if ( $column->getHumanReadableName() === $resultColumn->getHumanReadableName() || $column->getMachineName() === $resultColumn->getMachineName() ) { return $this; } } $this->resultColumns->attach($resultColumn); return $this; }
@param ResultColumn $resultColumn @return Builder
entailment
public function getHumanReadableWithMachineName(string $machineName) { /** @var ResultColumn $column */ foreach ($this->resultColumns as $column) { if ($column->getMachineName() === $machineName) { return $column->getHumanReadableName(); } } return; }
@param string $machineName @return string|null
entailment
public function sendBugReport($message, $debug){ // Sanity check if(is_null($message) || empty(trim($message)) || strlen(trim($message)) < 10) throw new \Exception('Specificati un mesaj valid de cel putin 10 caractere in afara de spatiu'); if(empty($debug) && !is_array($debug)) throw new \Exception('Specificati mesajul de debug sub forma unui array'); // Set method and action $method = 'email'; $action = 'sendBugReport'; // Set data $data = array('message' => $message, 'debug' => $debug); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Returneaza un graf cu conversatiile purtate prin intermediul email-ului cu clientii (hthttps://github.com/celdotro/marketplace/wiki/Trimitere-raport-bug) [EN] Returns a graph with the conversations made through the email with the client (https://github.com/celdotro/marketplace/wiki/Send-bug-report) @param $message @param $debug @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function defineAttributes() { return array( 'class' => array(AttributeType::String, 'required' => true), 'clientId' => array(AttributeType::String, 'required' => false), 'clientSecret' => array(AttributeType::String, 'required' => false) ); }
Define Attributes
entailment
public function addBonus($model, $bonus = array()){ // Sanity check if(!isset($model) || trim($model) === '') throw new \Exception('Specificati modelul'); if(!isset($bonus) || !is_array($bonus)) throw new \Exception('$bonus trebuie sa fie un array cu bonusuri'); // Set method and action $method = 'products'; $action = 'addBonus'; // Set data $data = array('model' => $model, 'bonus' => $bonus); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Adauga bonusul pentru un produs (https://github.com/celdotro/marketplace/wiki/Adauga-bonus) [EN] Adds bonuses for a product (https://github.com/celdotro/marketplace/wiki/Add-bonus) @param $model @param array $bonus @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getBonus($model){ // Sanity check if(!isset($model) || trim($model) === '') throw new \Exception('Specificati modelul'); // Set method and action $method = 'products'; $action = 'getBonus'; // Set data $data = array('model' => $model); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Listeaza bonusurile unui produs (https://github.com/celdotro/marketplace/wiki/Listeaza-bonus) [EN] Get a product's bonuses (https://github.com/celdotro/marketplace/wiki/List-bonus) @param $model @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public static function transformUrl($url, $id, $key = '') { return str_replace(!empty($key) ? $key : ':id', $id, $url); }
Transform url by replacing dummy data. @param $url @param $id @param string $key @return mixed
entailment
public function objectToArray($object) { if (!is_object($object) && !is_array($object)) { return $object; } if (is_object($object)) { $object = get_object_vars($object); } return array_map([get_class(), 'objectToArray'], $object); }
Converts a bowl of object to an array. @todo: replace with function that only shows accessible properties of the object @param $object @return array
entailment
public static function env($key, $default = null) { $value = getenv($key); if ($value === false) { return value($default); } switch (strtolower($value)) { case 'true': case '(true)': return true; case 'false': case '(false)': return false; case 'empty': case '(empty)': return ''; case 'null': case '(null)': return; } if (Str::startsWith($value, '"') && Str::endsWith($value, '"')) { return substr($value, 1, -1); } return $value; }
Gets the value of an environment variable. Supports boolean, empty and null. From Laravel/lumen-framework/src/helpers.php. @param string $key @param mixed $default @return mixed
entailment
public function getCustomer($customerId) { //retrieve customer, set customer attributes $customerModel = $this->customerResource->get($customerId); if ($customerModel instanceof \Exception) { throw $customerModel; } $this->_setAttributes($customerModel); $this->setDeletable(true); return $this; }
Get customer by ID. @param $customerId @throws \Exception|mixed @return $this
entailment
public function make($first_name, $last_name, $email, $phone, $otherAttributes = []) { $this->first_name = $first_name; $this->last_name = $last_name; $this->email = $email; $this->phone = $phone; $this->_setAttributes($otherAttributes); //set creatable $this->setCreatable(true); return $this; }
set up a new customer object. @param $first_name @param $last_name @param $email @param $phone @param array $otherAttributes @return $this
entailment
public function setUpdateData($updateAttributes) { if (empty($updateAttributes)) { throw new \InvalidArgumentException('Update Attributes Empty'); } $this->_setAttributes($updateAttributes); $this->setUpdateable(true); return $this; }
set update data on customer model. @param $updateAttributes @throws \Exception @return $this
entailment
public function save() { $resourceResponse = null; if ($this->isCreatable() && !$this->isUpdateable()) { //available for creation $resourceResponse = $this->customerResource->save( $this->transform(ModelInterface::TRANSFORM_TO_JSON_ARRAY) ); } if ($this->isUpdateable() && !$this->isCreatable()) { //available for update $resourceResponse = $this->customerResource->update( $this->customerId, $this->transform(ModelInterface::TRANSFORM_TO_JSON_ARRAY) ); } if ($resourceResponse == null) { throw new \InvalidArgumentException('You Cant Perform This Operation on an empty customer object'); } if ($resourceResponse instanceof \Exception) { throw $resourceResponse; } return $this->_setAttributes($resourceResponse); }
save/update customer model on paystack. @throws \Exception @throws \Exception|mixed @throws null @return $this
entailment
protected function xpath() { $selectors = []; foreach ($this->types as $type) { $selectors[] = '@type = \'' .$type. '\''; } return '//*[(self::input[' .implode(' or ', $selectors). '] or self::textarea) and not(ancestor-or-self::*[@' .Parser::ATTRIBUTE_NO_TRANSLATE. '])]/@placeholder'; }
{@inheritdoc}
entailment
public function addContent($content, $type = null) { if (preg_match('/(?<content><\!DOCTYPE(?:.*?)?>)/is', $content, $this->doctypeMatches)) { $this->hasDoctype = true; } parent::addContent($content, $type); }
{@inheritdoc}
entailment
public function addHtmlContent($content, $charset = 'UTF-8') { if (preg_match('/(?<before><html(?:.*?)?>)(?:.*?)(?<after><\/html>)/is', $content, $this->htmlMatches)) { $this->hasHtml = true; } if (preg_match('/<head(?:.*?)?>(?:.*?)<\/head>/i', $content)) { $this->hasHead = true; } if (preg_match('/<body(?:.*?)?>(?:.*?)<\/body>/i', $content)) { $this->hasBody = true; } parent::addHtmlContent($content, $charset); }
{@inheritdoc}
entailment
public function html() { $html = ''; foreach ($this->getNode(0)->childNodes as $child) { $html .= $child->ownerDocument->saveHTML($child); } return $this->cleaningHtml($html); }
{@inheritdoc}
entailment
protected function cleaningHtml($html) { $xml = false; $childrens = null; try { $xml = @simplexml_load_string($html); } catch (\Exception $e) { // ignore } if ($xml !== false) { if (!$this->hasHead && $xml->getName() === 'head') { $childrens = $xml->xpath('//head/child::*'); } if (!$this->hasBody && $xml->getName() === 'body') { $childrens = $xml->xpath('//body/child::*'); } if ($childrens !== null) { $temp = ''; foreach ($childrens as $children) { $temp .= $children->saveXML(); } $html = html_entity_decode($temp); } } if ($this->hasHtml) { $html = $this->htmlMatches['before'].$html.$this->htmlMatches['after']; } if ($this->hasDoctype) { $html = $this->doctypeMatches['content'].$html; } return $html; }
Cleaning HTML from parts it should not contains @param string $html @return string
entailment
public function getCardPayments($month){ // Sanity check // Set method and action $method = 'commissions'; $action = 'getCardOrdersByMonth'; // Set data $data = array('month' => $month); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia informatii aferente platilor lunare cu cardul (https://github.com/celdotro/marketplace/wiki/Plati-cu-cardul) [EN] Retrieve information about monthly card payments (https://github.com/celdotro/marketplace/wiki/Card-payments) @param $month @return mixed @throws \Exception
entailment
public function getCardPaymentMonths(){ // Sanity check // Set method and action $method = 'commissions'; $action = 'getCardPaymentMonths'; // Set data $data = array('dummy' => 1); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia lunile aferente platilor cu cardul (https://github.com/celdotro/marketplace/wiki/Preia-lunile-platilor-cu-cardul) [EN] Retrieve card payment months (https://github.com/celdotro/marketplace/wiki/Retrieve-card-payments-months) @return mixed @throws \Exception
entailment
public function getSummaryMonths(){ // Sanity check // Set method and action $method = 'commissions'; $action = 'getMonths'; // Set data $data = array('dummy' => 1); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia lunile in care s-au generat borderouri (https://github.com/celdotro/marketplace/wiki/Preia-lunile-borderourilor) [EN] Get months in which orders summary was generated (https://github.com/celdotro/marketplace/wiki/Get-summary-months) @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getUnbilledCommissions(){ // Sanity check // Set method and action $method = 'commissions'; $action = 'getComosioaneNefacturate'; // Set data $data = array('dummy' => 1); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia comisioanele nefacturate (https://github.com/celdotro/marketplace/wiki/Preia-comisioanele-nefacturate) [EN] Get unbilled commissions (https://github.com/celdotro/marketplace/wiki/Get-unbilled-commissions) @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function getBilledCommissions($month){ // Sanity check if(empty($month)) throw new \Exception('Nu ati specificat luna'); // Set method and action $method = 'commissions'; $action = 'getComisioaneFacturate'; // Set data $data = array('month' => $month); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia comisioanele facturate (https://github.com/celdotro/marketplace/wiki/Preia-comisioane-facturate) [EN] Retrieve billed commissions (https://github.com/celdotro/marketplace/wiki/Retrieve-billed-commissions) @param $month @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function approveOrder($oid, $borderou){ // Sanity check if(empty($oid)) throw new \Exception('Nu ati specificat id-ul comenzii'); if(empty($borderou)) throw new \Exception('Nu ati specificat borderoul'); // Set method and action $method = 'commissions'; $action = 'approveOrder'; // Set data $data = array( 'oid' => $oid, 'borderou' => $borderou ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Aproba comanda (https://github.com/celdotro/marketplace/wiki/Aproba-comanda) [EN] Approve order (https://github.com/celdotro/marketplace/wiki/Approve-order) @param $oid @param $borderou @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function rejectOrder($oid, $borderou, $reason){ // Sanity check if(empty($oid)) throw new \Exception('Nu ati specificat id-ul comenzii'); if(empty($borderou)) throw new \Exception('Nu ati specificat borderoul'); if(empty($reason)) throw new \Exception('Nu ati specificat problema'); // Set method and action $method = 'commissions'; $action = 'rejectOrder'; // Set data $data = array( 'oid' => $oid, 'borderou' => $borderou, 'reason' => $reason ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Respinge comanda (https://github.com/celdotro/marketplace/wiki/Respinge-comanda) [EN] Reject order (https://github.com/celdotro/marketplace/wiki/Reject-order) @param $oid @param $borderou @param $reason @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function downloadSummaryXlsx($borderou){ // Sanity check if(empty($borderou)) throw new \Exception('Nu ati specificat borderoul'); // Set method and action $method = 'commissions'; $action = 'downloadXLSBorderou'; // Set data $data = array( 'borderou' => $borderou, ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Descarca borderoul in format XLSX (https://github.com/celdotro/marketplace/wiki/Descarca-borderou-XLSX) [EN] Download XLSX format summary (https://github.com/celdotro/marketplace/wiki/Download-summary-XLSX) @param $borderou @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function printAwb($cmd){ // Sanity check if(!isset($cmd) || is_null($cmd) || $cmd === '' || !is_int($cmd)) throw new \Exception('Specificati comanda'); // Set method and action $method = 'orders'; $action = 'printAwb'; // Set data $data = array('cmd' => $cmd); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Printeaza AWB-ul unei comenzi (https://github.com/celdotro/marketplace/wiki/Listare-AWB) [EN] Prints the AWB of a specified order (https://github.com/celdotro/marketplace/wiki/AWB-Print) @param $cmd @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function setTitle($title) { $this->setAutoDiscoverTitle($title === null); $this->title = $title; return $this; }
If we put a null value into $title, we would force the auto discover for the Parser. @param null|string $title @return $this
entailment
public function asArray() { $data = [ 'request_url' => $this->getUrl(), 'bot' => $this->getBot() ]; if (!$this->getAutoDiscoverTitle()) { $data['title'] = $this->getTitle(); } return $data; }
{@inheritdoc}
entailment
final private static function validateClassHasProperty(string $className, string $classProperty, string $builderId) { $propertyInfo = new PropertyInfoExtractor([new ReflectionExtractor()]); $properties = $propertyInfo->getProperties($className); if (false === strpos($classProperty, '.')) { // not yet checking associations - Property Accessor can't do this if (!in_array($classProperty, $properties)) { throw new \InvalidArgumentException( sprintf( 'Builder %s Bad Column Declared. Property %s is not accessible in %s.', $builderId, $classProperty, $className ) ); } } }
@param string $className @param string $classProperty @param string $builderId @see http://symfony.com/doc/current/components/property_info.html#components-property-info-extractors @throws \InvalidArgumentException
entailment
public function getCustomers($page = '') { $customerObjects = []; $customers = $this->getCustomerResource()->getAll($page); if ($customers instanceof \Exception) { throw $customers; } foreach ($customers as $customer) { $customerObject = new Customer($this->getCustomerResource()); $customerObjects[] = $customerObject->_setAttributes($customer); } return $customerObjects; }
Get all customers. @param string $page @throws \Exception|mixed @return \Exception|mixed
entailment
public function createCustomer($first_name, $last_name, $email, $phone) { return $this->getCustomerModel()->make($first_name, $last_name, $email, $phone)->save(); }
Create new customer. @param $first_name @param $last_name @param $email @param $phone @throws \Exception|mixed @throws null @return mixed
entailment
public function updateCustomerData($customerId, $updateData) { return $this->getCustomerModel()->getCustomer($customerId) ->setUpdateData($updateData) ->save(); }
Update customer by customer id/code. @param $customerId @param array $updateData @throws \Exception|mixed @throws null @return mixed
entailment
public function getPlans($page = '') { $planObjects = []; $plans = $this->getPlanResource()->getAll($page); if ($plans instanceof \Exception) { throw $plans; } foreach ($plans as $plan) { $planObject = new Plan($this->getPlanResource()); $planObjects[] = $planObject->_setAttributes($plan); } return $planObjects; }
Get all plans. @param string $page @throws \Exception|mixed @return \Exception|mixed
entailment
public function createPlan($name, $description, $amount, $currency) { return $this->getPlanModel()->make($name, $description, $amount, $currency)->save(); }
Create new plan. @param $name @param $description @param $amount @param $currency @throws \Exception|mixed @throws null @return mixed
entailment
public function updatePlan($planCode, $updateData) { return $this->getPlanModel()->getPlan($planCode) ->setUpdateData($updateData) ->save(); }
Update plan. @param $planCode @param $updateData @throws \Exception|mixed @throws null @return mixed
entailment
public function startOneTimeTransaction($amount, $email, $plan = '') { $oneTimeTransaction = OneTimeTransaction::make( $amount, $email, $plan instanceof Plan ? $plan->get('plan_code') : $plan ); $oneTimeTransaction->setTransactionResource($this->getTransactionResource()); $transaction = $oneTimeTransaction->initialize(); if ($transaction instanceof \Exception) { throw $transaction; } return $transaction; }
Init a one time transaction to get payment page url. @param $amount @param $email @param string $plan @throws \Exception|mixed|Exceptions\PaystackInvalidTransactionException @return \Exception|mixed|Exceptions\PaystackInvalidTransactionException
entailment
public function chargeReturningTransaction($authorization, $amount, $email, $plan = '') { $returningTransaction = ReturningTransaction::make( $authorization, $amount, $email, $plan instanceof Plan ? $plan->get('plan_code') : $plan ); $returningTransaction->setTransactionResource($this->getTransactionResource()); $transaction = $returningTransaction->charge(); if ($transaction instanceof \Exception) { throw $transaction; } return $transaction; }
Charge a returning customer. @param $authorization @param $amount @param $email @param string $plan @throws \Exception|mixed|Exceptions\PaystackInvalidTransactionException @return \Exception|mixed|Exceptions\PaystackInvalidTransactionException
entailment
public function getSummary($nrDays = 0){ // Sanity check if(!isset($nrDays) || !is_int($nrDays)) throw new \Exception('$nrDays trebuie sa fie de tip integer'); // Set method and action $method = 'home'; $action = 'getOrders'; // Set data $data = array('nrDays' => $nrDays); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Returneaza un sumar pentru ultimele zile. (https://github.com/celdotro/marketplace/wiki/Sumar-comenzi) [EN] Get orders summary for the last days. (https://github.com/celdotro/marketplace/wiki/Orders-summary) @param int $nrDays @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function updateData($arrProducts){ // Sanity check if(!is_array($arrProducts) || empty($arrProducts)) throw new \Exception('Functia primeste ca parametru un array cu datele fiecarui produs grupate intr-un sub-array'); // Set method and action $method = 'products'; $action = 'saveProducts'; // Set data $data = array('products' => json_encode($arrProducts)); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Actualizeaza datele produselor deja existente (https://github.com/celdotro/marketplace/wiki/Actualizeaza-date-produs) [EN] Updates an already existing product's data (https://github.com/celdotro/marketplace/wiki/Update-product-data) @param $arrProducts @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function updateStatus($model, $status){ // Sanity check if(empty($model)) throw new \Exception('Specificati modelul produsului'); // Set method and action $method = 'products'; $action = 'updateStatus'; // Set data $data = array( 'model' => $model, 'status' => $status ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Actualizeaza statusul unui produs (https://github.com/celdotro/marketplace/wiki/Actualizare-status-produs) [EN] Update product's status (https://github.com/celdotro/marketplace/wiki/Update-product-status) @param $model @param $status @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function addProductToFamily($familyId, $model){ // Sanity check if(empty($model)) throw new \Exception('Specificati modelul produsului'); if(empty($familyId)) throw new \Exception('Specificati familia produsului'); // Set method and action $method = 'products'; $action = 'addProductToFamily'; // Set data $data = array( 'model' => $model, 'familyId' => $familyId ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Adauga un produs intr-o familie de produse (https://github.com/celdotro/marketplace/wiki/Adauga-produs-in-familie) [EN] Add a product to a product family (https://github.com/celdotro/marketplace/wiki/Add-product-to-family) @param $familyId @param $model @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function removeProductFromFamily($model){ // Sanity check if(empty($model)) throw new \Exception('Specificati modelul produsului'); // Set method and action $method = 'products'; $action = 'removeProductFromFamily'; // Set data $data = array( 'model' => $model ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Elimina produs din familie (https://github.com/celdotro/marketplace/wiki/Elimina-produs-din-familie) [EN] Remove product from family (https://github.com/celdotro/marketplace/wiki/Remove-product-from-family) @param $model @return mixed @throws \GuzzleHttp\Exception\GuzzleException
entailment
public function updatePromotion($model, $promotion){ // Sanity check if(empty($model)) throw new \Exception('Specificati modelul produsului'); if(!in_array($promotion, array(0, 1, 2))) throw new \Exception('Specificati o promotie valida'); // Set method and action $method = 'products'; $action = 'updatePromotion'; // Set data $data = array( 'model' => $model, 'promotion' => $promotion ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Actualizeaza promotia unui produs (https://github.com/celdotro/marketplace/wiki/Actualizare-promotie-produs) [EN] Update product's promotion (https://github.com/celdotro/marketplace/wiki/Update-product-promotion) @param $model @param $promotion @return mixed @throws \Exception
entailment
public function addProductsFamily($id, $name, $characts){ // Set method and action $method = 'products'; $action = 'addProductsFamily'; // Set data $data = array( 'id' => $id, 'name' => $name, 'characts' => $characts ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Adauga o familie de produse (https://github.com/celdotro/marketplace/wiki/Adauga-familie-de-produse) [EN] Add a products family (https://github.com/celdotro/marketplace/wiki/Add-products-family) @param $id @param $name @param $characts @return mixed @throws \Exception
entailment
protected function xpath() { $selectors = []; foreach ($this->attributes as $name => $values) { foreach ($values as $value) { $selectors[] = '@' .$name. ' = \'' .$value. '\''; } } return '//meta[(' .implode(' or ', $selectors). ') and not(ancestor-or-self::*[@' .Parser::ATTRIBUTE_NO_TRANSLATE. '])]/@content'; }
{@inheritdoc}
entailment
public function jsonSerialize() { $words = []; foreach ($this->collection as $entry) { $words[] = $entry->jsonSerialize(); } return $words; }
{@inheritdoc}
entailment
public function cardPayments($dateMin, $dateMax){ $method = 'reports'; $action = 'cardPayments'; // Set data $data = array( 'dateMin' => $dateMin, 'dateMax' => $dateMax, ); // Send request and retrieve response $result = Dispatcher::send($method, $action, $data); return $result; }
[RO] Preia datele agregate lunar ale platilor cu cardul (https://github.com/celdotro/marketplace/wiki/Plati-cu-cardul) [EN] Retrieves aggregate monthly reports of card payments (https://github.com/celdotro/marketplace/wiki/Card-payments) @param $dateMin @param $dateMax @return mixed @throws \Exception
entailment
public function defineAttributes() { return array( 'providerHandle' => array(AttributeType::String, 'required' => true), 'pluginHandle' => array(AttributeType::String, 'required' => true), 'accessToken' => array(AttributeType::String, 'column' => ColumnType::Text), 'secret' => array(AttributeType::String, 'column' => ColumnType::Text), 'endOfLife' => AttributeType::String, 'refreshToken' => array(AttributeType::String, 'column' => ColumnType::Text), ); }
Define Attributes
entailment
public function connect($variables) { if(!craft()->httpSession->get('oauth.response')) { // we don't have any response yet, get ready to connect // clean session $this->_sessionClean(); // get provider $provider = craft()->oauth->getProvider($variables['provider']); // referer if(!empty($variables['referer'])) { $referer = $variables['referer']; } else { $referer = craft()->request->getUrl(); } craft()->httpSession->add('oauth.referer', $referer); // scope if(!empty($variables['scope'])) { $scope = $variables['scope']; } else { $scope = []; } craft()->httpSession->add('oauth.scope', $scope); // authorizationOptions if(!empty($variables['authorizationOptions'])) { $authorizationOptions = $variables['authorizationOptions']; } else { $authorizationOptions = []; // $authorizationOptions = $provider->getauthorizationOptions(); } craft()->httpSession->add('oauth.authorizationOptions', $authorizationOptions); // redirect url $redirectUrl = UrlHelper::getActionUrl('oauth/connect/', array( 'provider' => $variables['provider'] )); OauthPlugin::log('Redirect to OAuth Connect'."\r\n". 'Redirect to: '.$redirectUrl."\r\n". 'Session Data: '.print_r([ 'oauth.referer' => $referer, 'oauth.scope' => $scope, 'oauth.authorizationOptions' => $authorizationOptions ], true)."\r\n" , LogLevel::Info); // redirect craft()->request->redirect($redirectUrl); } else { // populate token object from response $response = craft()->httpSession->get('oauth.response'); craft()->httpSession->remove('oauth.response'); OauthPlugin::log('OAuth Connect - Retrieve token from response'."\r\n". 'Session Data: '.print_r([ 'oauth.response' => $response, ], true)."\r\n" , LogLevel::Info); if($response['token']) { // response token to token model $token = new Oauth_TokenModel; $provider = $this->getProvider($variables['provider']); if($provider) { switch ($provider->getOauthVersion()) { case 1: if(!empty($response['token']['identifier'])) { $token->accessToken = $response['token']['identifier']; } if(!empty($response['token']['secret'])) { $token->secret = $response['token']['secret']; } break; case 2: if(!empty($response['token']['accessToken'])) { $token->accessToken = $response['token']['accessToken']; } if(!empty($response['token']['endOfLife'])) { $token->endOfLife = $response['token']['endOfLife']; } if(!empty($response['token']['refreshToken'])) { $token->refreshToken = $response['token']['refreshToken']; } break; } } $token->providerHandle = $variables['provider']; $token->pluginHandle = $variables['plugin']; OauthPlugin::log('OAuth Connect - Token'."\r\n".print_r([ "Token: \r\n". print_r($token->getAttributes(), true) ], true), LogLevel::Info); $response['token'] = $token; } $this->_sessionClean(); return $response; } }
Connect
entailment
public function getProvider($handle, $configuredOnly = true, $fromRecord = false) { $this->_loadProviders($fromRecord); $lcHandle = strtolower($handle); if($configuredOnly) { if(isset($this->_configuredProviders[$lcHandle])) { return $this->_configuredProviders[$lcHandle]; } } else { if(isset($this->_allProviders[$lcHandle])) { return $this->_allProviders[$lcHandle]; } } return null; }
Get provider
entailment
public function getProviders($configuredOnly = true) { $this->_loadProviders(); if($configuredOnly) { return $this->_configuredProviders; } else { return $this->_allProviders; } }
Get providers
entailment
public function providerSave(Oauth_ProviderInfosModel $model) { // save record $record = $this->_getProviderInfosRecordById($model->id); $record->class = $model->class; $record->clientId = $model->clientId; $record->clientSecret = $model->clientSecret; return $record->save(false); }
Save provider
entailment