public static function construct($status, $attribute_id) { $element = new self(); $element->setStatus($status); $element->setAttributeId($attribute_id); return $element; }
public static function constructFailure($attribute_id, $status) { $record = new self(); $record->setAttributeId($attribute_id); $record->setStatus($status); return $record; }
public static function constructFailure($status, $nwk_addr_of_interest) { $frame = new self(); $frame->setStatus($status); $frame->setNwkAddrOfInterest($nwk_addr_of_interest); return $frame; }
/** * Creates a new instance of Feedback using Smark.io supplierId+externalId as lead key * * @param $api_token string your API token * @param $supplierId string|int the identifier of the supplier in Smark.io * @param $externalId string|int the identifier of the lead for the supplier. * @param $status string the status of the lead * @return Feedback */ public static function createWithSupplierExternalId($api_token, $supplierId, $externalId, $status) { $feedback = new self($api_token); $feedback->setSupplierId($supplierId); $feedback->setExternalId($externalId); $feedback->setStatus($status); return $feedback; }
/** * If there is an error code, we do not need the full AttributeReportingConfigurationRecord * * @param $status * @param $direction * @param $attribute_id * @return AttributeReportingConfigurationStatusRecord */ public static function constructWithError($status, $direction, $attribute_id) { $element = new self(); $element->setStatus($status); $element->setDirection($direction); $element->setAttributeId($attribute_id); return $element; }
public static function createFromArray(array $row) { $order = new self(); if (array_key_exists('id', $row)) { $order->setId($row['id']); } $order->setStatus($row['status']); return $order; }
/** * Factory - create the response * * @param $data * * @return self|boolean */ public function create($data) { $parent = parent::create($data); $data = $parent->getData(); $response = new self(); $response->setStatus($parent->getStatus()); $response->setErrorMessage($parent->getErrorMessage()); $response->setUserExists((int) $data > 0); return $response; }
/** * Factory - create the response * * @param $data * * @return self|boolean */ public function create($data) { $response = new self(); // Parse XML try { $response->setStatus($data['response']['status']); if (isset($data['response']['errormessage'])) { $response->setErrormessage($data['response']['errormessage']); } if (isset($data['response']['data'])) { $response->setData($data['response']['data']); } return $response; } catch (\Exception $e) { $response->setStatus(self::ERROR); $response->setErrorMessage($e->getMessage()); return false; } }
public static function constructFailure($status, $nwk_addr_of_interest, $endpoint, $app_input_cluster_count, $app_output_cluster_count, $start_index) { $frame = new self(); $frame->setStatus($status); $frame->setNwkAddrOfInterest($nwk_addr_of_interest); $frame->setEndpoint($endpoint); $frame->setAppInputClusterCount($app_input_cluster_count); $frame->setAppOutputClusterCount($app_output_cluster_count); $frame->setStartIndex($start_index); return $frame; }
public static function construct($network_address, $status, $memory_constrained, $many_to_one, $route_record_required, $next_hop_address) { $frame = new self(); $frame->setDestinationAddress($network_address); $frame->setStatus($status); $frame->setMemoryConstrained($memory_constrained); $frame->setManyToOne($many_to_one); $frame->setRouteRecordRequired($route_record_required); $frame->setNextHopAddress($next_hop_address); return $frame; }
/** * Factory - create the response * * @param $data * * @return self|boolean */ public function create($data) { $parent = parent::create($data); $data = $parent->getData(); $response = new self(); $response->setStatus($parent->getStatus()); $response->setErrorMessage($parent->getErrorMessage()); if (isset($data['count'])) { $response->setCount($data['count']); if ($response->getCount() > 0) { $response->setSubscribers($data['subscriberlist']['item']); } } return $response; }
/** * Build a payment entity based on a json-decoded payment stdClass * * @param stdClass $response The payment data * @return Syspay_Merchant_Entity_Payment The payment object */ public static function buildFromResponse(stdClass $response) { $chargeback = new self(); $chargeback->setId(isset($response->id) ? $response->id : null); $chargeback->setStatus(isset($response->status) ? $response->status : null); $chargeback->setAmount(isset($response->amount) ? $response->amount : null); $chargeback->setCurrency(isset($response->currency) ? $response->currency : null); $chargeback->setReasonCode(isset($response->reason_code) ? $response->reason_code : null); if (isset($response->processing_time) && !is_null($response->processing_time)) { $chargeback->setProcessingTime(Syspay_Merchant_Utils::tsToDateTime($response->processing_time)); } if (isset($response->payment)) { $chargeback->setPayment(Syspay_Merchant_Entity_Payment::buildFromResponse($response->payment)); } return $chargeback; }
/** * @param \Guzzle\Http\Message\Response $guzzleResponse * @param ActionsInterface $action * @return Response */ public static function parseGuzzleResponse(\Guzzle\Http\Message\Response $guzzleResponse, ActionsInterface $action) { $response = new self(); if ($guzzleResponse->getStatusCode() != 200) { $response->setStatus(false); $response->setError($response::ERROR_REQUEST_ERROR); return $response; } $responseArray = json_decode($guzzleResponse->getBody(true), true); $response->setStatus($responseArray['ok']); if ($response->getStatus() === false) { $response->setError($responseArray['error']); return $response; } $response->setData($action->parseResponse($responseArray)); return $response; }
/** * Build a payment entity based on a json-decoded payment stdClass * * @param stdClass $response The payment data * @return Syspay_Merchant_Entity_Payment The payment object */ public static function buildFromResponse(stdClass $response) { $refund = new self(); $refund->setId(isset($response->id) ? $response->id : null); $refund->setReference(isset($response->reference) ? $response->reference : null); $refund->setAmount(isset($response->amount) ? $response->amount : null); $refund->setCurrency(isset($response->currency) ? $response->currency : null); $refund->setStatus(isset($response->status) ? $response->status : null); $refund->setExtra(isset($response->extra) ? $response->extra : null); $refund->setDescription(isset($response->description) ? $response->description : null); if (isset($response->processing_time) && !is_null($response->processing_time)) { $refund->setProcessingTime(Syspay_Merchant_Utils::tsToDateTime($response->processing_time)); } if (isset($response->payment)) { $refund->setPayment(Syspay_Merchant_Entity_Payment::buildFromResponse($response->payment)); } return $refund; }
/** * @return Request */ public static function fromInput() { global $module; $model = new self(); $model->setMethod(self::getMethodFromInput()); if (isset($module)) { $model->setPath($module); $input = explode('/', $module); $model->setSegments($input); } $model->setBody(InputStream::getInput()); $model->setHeaders(self::getHeadersFromInput()); $model->setParameters($_GET); $model->setCookies($_COOKIE); $model->setPost($_POST); $model->setEnvironment($_SERVER); $model->setStatus(http_response_code()); $model->setUrl(self::getCurrentUri()); $model->parseData(); return $model; }
/** * return all tickets of a specific user. * an array of all tickets created by a specific user are returned by this function. * @param $author the id of the user of whom we want all tickets from. * @return an array containing all ticket objects related to a user. */ public static function getTicketsOf($author) { $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket INNER JOIN ticket_user ON ticket.Author = ticket_user.TUserId and ticket_user.ExternId=:id", array('id' => $author)); $row = $statement->fetchAll(); $result = array(); foreach ($row as $ticket) { $instance = new self(); $instance->setTId($ticket['TId']); $instance->setTimestamp($ticket['Timestamp']); $instance->setTitle($ticket['Title']); $instance->setStatus($ticket['Status']); $instance->setQueue($ticket['Queue']); $instance->setTicket_Category($ticket['Ticket_Category']); $instance->setAuthor($ticket['Author']); $result[] = $instance; } return $result; }
public function translate() { // Initialize the response with the current state $request = new self(array(), $this->url, $this->status); // Attempt to translate the url until no more translations are found do { // If this flag is set to true, then translation will continue another round $translated = false; // Routes is formatted as `array(url-pattern-to-match => rewrite-instructions, ...)`. // Step through each route and try to match the base URL pattern with the current URL foreach ($this->routes as $route) { // A match with the current URL was found if (preg_match($route->pattern, $request->url)) { // Rewrite the URL $request->setUrl(preg_replace($route->pattern, $route->rewrite, $request->url)); $translated = true; // Optional: If a new status was provided, set it if ($route->status !== false) { $request->setStatus($route->status); } // If the `last` flag is set or a redirect is required, then stop all translations if (!empty($route->is_last) || $request->isStatusRedirect()) { $translated = false; break; } } } } while ($translated); // Make sure that the URL is set strictly as a path $url_parts = parse_url($request->getUrl(false)); $request->setUrl($url_parts['path']); // Inject rewritten URL params into _GET if (!empty($url_parts['query'])) { $params = array(); parse_str($url_parts['query'], $params); $_GET = array_merge($_GET, $params); } // If the new status is a redirect if ((int) ($request->status / 100) == 3) { // Clean up the query string before creeating the new request unset($_GET[GOBE_QUERY_PATH]); unset($_GET[GOBE_QUERY_STATUS]); header("Location: " . $url_parts['path'] . '?' . http_build_query($_GET), true, $request->status); die; } // Set the new status in the HTTP header // header("gobe-status", true, $request->status); return $request; }
/** * Parses a cron line into a Cron instance * * TODO: this deserves a serious regex * * @static * @param $cron string The cron line * @return Cron */ public static function parse($cron) { $parts = \explode(' ', $cron); $command = \implode(' ', \array_slice($parts, 5)); // extract comment if (\strpos($command, '#')) { list($command, $comment) = \explode('#', $command); $comment = \trim($comment); } // extract error file if (\strpos($command, '2>')) { list($command, $errorFile) = \explode('2>', $command); $errorFile = \trim($errorFile); } // extract log file if (\strpos($command, '>')) { list($command, $logFile) = \explode('>', $command); $logFile = \trim($logFile); } // compute last run time, and file size $lastRunTime = null; $logSize = null; $errorSize = null; if (isset($logFile) && \file_exists($logFile)) { $lastRunTime = \filemtime($logFile); $logSize = \filesize($logFile); } if (isset($errorFile) && \file_exists($errorFile)) { $lastRunTime = \max($lastRunTime ?: 0, \filemtime($errorFile)); $errorSize = \filesize($errorFile); } // compute status $status = 'error'; if ($logSize === null && $errorSize === null) { $status = 'unknown'; } else { if ($errorSize === null || $errorSize == 0) { $status = 'success'; } } // create cron instance $cron = new self(); $cron->setMinute($parts[0]); $cron->setHour($parts[1]); $cron->setDayOfMonth($parts[2]); $cron->setMonth($parts[3]); $cron->setDayOfWeek($parts[4]); $cron->setCommand(\trim($command)); $cron->setLastRunTime($lastRunTime); $cron->setLogSize($logSize); $cron->setErrorSize($errorSize); $cron->setStatus($status); if (isset($comment)) { $cron->setComment($comment); } if (isset($logFile)) { $cron->setLogFile($logFile); } if (isset($errorFile)) { $cron->setErrorFile($errorFile); } return $cron; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['status' => null, 'items' => [], 'player_currencies' => [], 'unknown4' => null], $values); $message->setStatus($values['status']); $message->setUnknown4($values['unknown4']); foreach ($values['items'] as $item) { $message->addItems($item); } foreach ($values['player_currencies'] as $item) { $message->addPlayerCurrencies($item); } return $message; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['start_time_ms' => null, 'unknown_status' => null, 'walking' => null, 'running' => null, 'stationary' => null, 'automotive' => null, 'tilting' => null, 'cycling' => null, 'status' => null], $values); $message->setStartTimeMs($values['start_time_ms']); $message->setUnknownStatus($values['unknown_status']); $message->setWalking($values['walking']); $message->setRunning($values['running']); $message->setStationary($values['stationary']); $message->setAutomotive($values['automotive']); $message->setTilting($values['tilting']); $message->setCycling($values['cycling']); $message->setStatus($values['status']); return $message; }
public static function createFromRawEvent(RawEvent $rawEvent) { $event = new self(); $event->setStatus($rawEvent->getStatus()); $event->setMessage($rawEvent->getMessage()); $event->setUnique($rawEvent->isUnique()); $event->setUrl($rawEvent->getUrl()); $event->setValue($rawEvent->getValue()); $event->setComponentId($rawEvent->getComponentId()); return $event; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['map_cells' => [], 'status' => null], $values); $message->setStatus($values['status']); foreach ($values['map_cells'] as $item) { $message->addMapCells($item); } return $message; }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['codename' => null, 'user_message' => null, 'is_assignable' => null, 'status' => null], $values); $message->setCodename($values['codename']); $message->setUserMessage($values['user_message']); $message->setIsAssignable($values['is_assignable']); $message->setStatus($values['status']); return $message; }
public static function constructFailure($status) { $frame = new self(); $frame->setStatus($status); return $frame; }
/** * Build a payment entity based on a json-decoded payment stdClass * * @param stdClass $response The payment data * @return Syspay_Merchant_Entity_Payment The payment object */ public static function buildFromResponse(stdClass $response) { $payment = new self(); $payment->setId(isset($response->id) ? $response->id : null); $payment->setReference(isset($response->reference) ? $response->reference : null); $payment->setAmount(isset($response->amount) ? $response->amount : null); $payment->setCurrency(isset($response->currency) ? $response->currency : null); $payment->setStatus(isset($response->status) ? $response->status : null); $payment->setExtra(isset($response->extra) ? $response->extra : null); $payment->setDescription(isset($response->description) ? $response->description : null); $payment->setWebsite(isset($response->website) ? $response->website : null); $payment->setFailureCategory(isset($response->failure_category) ? $response->failure_category : null); $payment->setChipAndPinStatus(isset($response->chip_and_pin_status) ? $response->chip_and_pin_status : null); $payment->setPaymentType(isset($response->payment_type) ? $response->payment_type : null); $payment->setWebsiteUrl(isset($response->website_url) ? $response->website_url : null); $payment->setContract(isset($response->contract) ? $response->contract : null); $payment->setDescriptor(isset($response->descriptor) ? $response->descriptor : null); $payment->setAccountId(isset($response->account_id) ? $response->account_id : null); $payment->setMerchantLogin(isset($response->merchant_login) ? $response->merchant_login : null); $payment->setMerchantId(isset($response->merchant_id) ? $response->merchant_id : null); if (isset($response->settlement_date) && !is_null($response->settlement_date)) { $payment->setSettlementDate(Syspay_Merchant_Utils::tsToDateTime($response->settlement_date)); } if (isset($response->processing_time) && !is_null($response->processing_time)) { $payment->setProcessingTime(Syspay_Merchant_Utils::tsToDateTime($response->processing_time)); } if (isset($response->billing_agreement) && $response->billing_agreement instanceof stdClass) { $billingAgreement = Syspay_Merchant_Entity_BillingAgreement::buildFromResponse($response->billing_agreement); $payment->setBillingAgreement($billingAgreement); } if (isset($response->subscription) && $response->subscription instanceof stdClass) { $subscription = Syspay_Merchant_Entity_Subscription::buildFromResponse($response->subscription); $payment->setSubscription($subscription); } if (isset($response->payment_method) && $response->payment_method instanceof stdClass) { $paymentMethod = Syspay_Merchant_Entity_PaymentMethod::buildFromResponse($response->payment_method); $payment->setPaymentMethod($paymentMethod); } $payment->raw = $response; return $payment; }
/** * Creates an instance with data * * @param array $data * @return self */ public static function create(array $data = array()) { $defaults = array('id' => null, 'folder_id' => null, 'profile' => null, 'name' => null, 'date_created' => new DateTime(), 'status' => null, 'resource' => null, 'uuid' => null, 'data' => new IdentifiableDataContainer(array())); $data = array_merge($defaults, $data); $obj = new self(); $obj->setId($data['id']); $obj->setFolderId($data['folder_id']); $obj->setProfile($data['profile']); $obj->setName($data['name']); $obj->setDateCreated($data['date_created']); $obj->setStatus($data['status']); $obj->setResource($data['resource']); $obj->setUuid($data['uuid']); $obj->setData($data['data']); return $obj; }
/** * Build a subscription entity based on a json-decoded subscription stdClass * * @param stdClass $response The subscription data * @return Syspay_Merchant_Entity_Subscription The subscription object */ public static function buildFromResponse(stdClass $response) { $subscription = new self(); $subscription->setId(isset($response->id) ? $response->id : null); $subscription->setPlanId(isset($response->plan_id) ? $response->plan_id : null); $subscription->setPlanType(isset($response->plan_type) ? $response->plan_type : null); $subscription->setReference(isset($response->reference) ? $response->reference : null); $subscription->setStatus(isset($response->status) ? $response->status : null); $subscription->setPhase(isset($response->phase) ? $response->phase : null); $subscription->setExtra(isset($response->extra) ? $response->extra : null); $subscription->setEmsUrl(isset($response->ems_url) ? $response->ems_url : null); $subscription->setWebsiteId(isset($response->website_id) ? $response->website_id : null); $subscription->setCreated(isset($response->created) ? Syspay_Merchant_Utils::tsToDateTime($response->created) : null); $subscription->setStartDate(isset($response->start_date) ? Syspay_Merchant_Utils::tsToDateTime($response->start_date) : null); $subscription->setEndDate(isset($response->end_date) ? Syspay_Merchant_Utils::tsToDateTime($response->end_date) : null); $subscription->setEndReason(isset($response->end_reason) ? $response->end_reason : null); if (isset($response->payment_method) && $response->payment_method instanceof stdClass) { $paymentMethod = Syspay_Merchant_Entity_PaymentMethod::buildFromResponse($response->payment_method); $subscription->setPaymentMethod($paymentMethod); } if (isset($response->customer) && $response->customer instanceof stdClass) { $customer = Syspay_Merchant_Entity_Customer::buildFromResponse($response->customer); $subscription->setCustomer($customer); } if (isset($response->plan) && $response->plan instanceof stdClass) { $plan = Syspay_Merchant_Entity_Plan::buildFromResponse($response->plan); $subscription->setPlan($plan); } if (isset($response->next_event) && $response->next_event instanceof stdClass) { $nextEvent = Syspay_Merchant_Entity_SubscriptionEvent::buildFromResponse($response->next_event); $subscription->setNextEvent($nextEvent); } $subscription->raw = $response; return $subscription; }
protected function closeOpenQueues($jobCode) { $collection = $this->getCollection()->addFieldToFilter('job_code', array('eq' => $jobCode))->addFieldToFilter('status', array('eq' => 1))->addFieldToFilter('store_id', array('eq' => $this->_storeId)); foreach ($collection as $queue) { $obj = new self(); $obj->load($queue->getId()); $obj->setStatus(0); $obj->save(); } }
/** * {@inheritdoc} */ public static function fromArray(array $values) { $message = new self(); $values = array_merge(['status' => null, 'player_data' => null], $values); $message->setStatus($values['status']); $message->setPlayerData($values['player_data']); return $message; }
/** * Build a billing agreement entity based on a json-decoded billing agreement stdClass * * @param stdClass $response The billing agreement data * @return Syspay_Merchant_Entity_BillingAgreement The billing agreement object */ public static function buildFromResponse(stdClass $response) { $billingAgreement = new self(); $billingAgreement->setId(isset($response->id) ? $response->id : null); $billingAgreement->setStatus(isset($response->status) ? $response->status : null); $billingAgreement->setCurrency(isset($response->currency) ? $response->currency : null); $billingAgreement->setExtra(isset($response->extra) ? $response->extra : null); $billingAgreement->setEndReason(isset($response->end_reason) ? $response->end_reason : null); if (isset($response->expiration_date) && !is_null($response->expiration_date)) { $billingAgreement->setExpirationDate(Syspay_Merchant_Utils::tsToDateTime($response->expiration_date)); } if (isset($response->payment_method) && $response->payment_method instanceof stdClass) { $paymentMethod = Syspay_Merchant_Entity_PaymentMethod::buildFromResponse($response->payment_method); $billingAgreement->setPaymentMethod($paymentMethod); } if (isset($response->customer) && $response->customer instanceof stdClass) { $customer = Syspay_Merchant_Entity_Customer::buildFromResponse($response->customer); $billingAgreement->setCustomer($customer); } return $billingAgreement; }