Creates and fills a offer model

@param array $response
@return Offer
774961
private function _createOffer(array $response)
    {
        $model = new Offer();
        $model->setId($response['id']);
        $model->setName($response['name']);
        $model->setAmount($response['amount']);
        $model->setCurrency($response['currency']);
        $model->setInterval($response['interval']);
        $model->setTrialPeriodDays($response['trial_period_days']);
        $model->setCreatedAt($response['created_at']);
        $model->setUpdatedAt($response['updated_at']);
        $model->setSubscriptionCount($response['subscription_count']['active'], $response['subscription_count']['inactive']);
        $model->setAppId($response['app_id']);
        return $model;
    }
1071495
public static function fromString($response)
	{
		$code 	 = self::extractCode($response);
		$headers = self::extractHeaders($response);
		$body 	 = self::extractBody($response);
		$version = self::extractVersion($response);
		$message = self::extractMessage($response);
		
		# FIX FOR MULTIPLE HTTP RESPONSE CODE RETURNED BY SERVER 
		if ($code === 100 && count($headers) === 0 && self::extractCode($body)) {
			return self::fromString($body);
		}
		
		return new static($code, $headers, $body, $version, $message);
	}
567446
protected function buildSelfLink(array &$response)
    {
        $link = [];

        if (!empty($type = $response[Serializer::CLASS_IDENTIFIER_KEY])) {
            list($idValues, $idProperties) = RecursiveFormatterHelper::getIdPropertyAndValues(
                $this->mappings,
                $response,
                $type
            );

            $href = self::buildUrl(
                $this->mappings,
                $idProperties,
                $idValues,
                $this->mappings[$type]->getResourceUrl(),
                $type
            );

            if ($href != $this->mappings[$type]->getResourceUrl()) {
                $link[self::SELF_LINK] = $href;
            }
        }

        return $link;
    }
1063890
public function create(array $data)
  {
    $VoucherType = new VoucherType();
    $VoucherType->setConnection($this->databaseConnectionName);
    $VoucherType->fill($data)->save();

    return $VoucherType;
  }
387149
protected function populate(stdClass $response)
    {
        $entry = clone $this;

        $entry->data->id = $this->getIfSet('id', $response);
        $entry->data->status = $this->getIfSet('status', $response);
        $entry->data->operation = $this->getIfSet('operation', $response);

        if (isset($response->amount)) {
            $entry->data->amount->total = $this->getIfSet('total', $response->amount);
            $entry->data->amount->fee = $this->getIfSet('fee', $response->amount);
            $entry->data->amount->liquid = $this->getIfSet('liquid', $response->amount);
            $entry->data->amount->currency = $this->getIfSet('currency', $response->amount);
        }

        if (isset($response->details)) {
            $entry->data->details = $this->getIfSet('details', $response);
        }

        if (isset($response->{'parent'}) && isset($response->{'parent'}->payments)) {
            $payments = new Payment($entry->moip);
            $payments->populate($response->{'parent'}->payments);

            $entry->data->parentPayments = $payments;
        }

        return $entry;
    }
559497
private function _createPayment(array $response)
    {
        $model = new Payment();
        $model->setId($response['id']);
        $model->setType($response['type']);
        $model->setClient($this->_convertResponseToModel($response['client'], "client"));
        if ($response['type'] === "creditcard") {
            $model->setCardType($response['card_type']);
            $model->setCountry($response['country']);
            $model->setExpireMonth($response['expire_month']);
            $model->setExpireYear($response['expire_year']);
            $model->setCardHolder($response['card_holder']);
            $model->setLastFour($response['last4']);
        } elseif ($response['type'] === "debit") {
            $model->setHolder($response['holder']);
            $model->setCode($response['code']);
            $model->setAccount($response['account']);
            $model->setBic($response['bic']);
            $model->setIban($response['iban']);
        } elseif ($response['type'] === "paypal") {
            $model->setHolder($response['holder']);
            $model->setAccount($response['account']);
        }
        $model->setCreatedAt($response['created_at']);
        $model->setUpdatedAt($response['updated_at']);
        $model->setAppId($response['app_id']);
        return $model;
    }
1163520
protected function createResponse(Response $response)
    {
        $contentType = $response->getHeader('Content-Type');

        if (!$contentType) {
            $contentType = 'text/html';
        }

        if (strpos($contentType, 'charset=') === false) {
            $body = $response->getBody(true);
            if (preg_match('/\<meta[^\>]+charset *= *["\']?([a-zA-Z\-0-9]+)/i', $body, $matches)) {
                $contentType .= ';charset=' . $matches[1];
            }
            $response->setHeader('Content-Type', $contentType);
        }

        $headers = $response->getHeaders();
        $status = $response->getStatusCode();
        if ($status < 300 || $status >= 400) {
            $matches = [];

            $matchesMeta = preg_match(
                '/\<meta[^\>]+http-equiv="refresh" content="\s*(\d*)\s*;\s*url=(.*?)"/i',
                $response->getBody(true),
                $matches
            );

            if (!$matchesMeta) {
                // match by header
                preg_match(
                    '/^\s*(\d*)\s*;\s*url=(.*)/i',
                    (string)$response->getHeader('Refresh'),
                    $matches
                );
            }

            if ((!empty($matches)) && (empty($matches[1]) || $matches[1] < $this->refreshMaxInterval)) {
                $uri = $this->getAbsoluteUri($matches[2]);
                $partsUri = parse_url($uri);
                $partsCur = parse_url($this->getHistory()->current()->getUri());
                foreach ($partsCur as $key => $part) {
                    if ($key === 'fragment') {
                        continue;
                    }
                    if (!isset($partsUri[$key]) || $partsUri[$key] !== $part) {
                        $status = 302;
                        $headers['Location'] = $matchesMeta ? htmlspecialchars_decode($uri) : $uri;
                        break;
                    }
                }
            }
        }

        return new BrowserKitResponse($response->getBody(), $status, $headers);
    }
1146743
public function makeModelFromResponse(DropboxResponse $response)
    {
        //Get the Decoded Body
        $body = $response->getDecodedBody();

        if (is_null($body)) {
            $body = [];
        }

        //Make and Return the Model
        return ModelFactory::make($body);
    }
20331
protected function populate(stdClass $response)
    {
        $transfers = clone $this;

        $transfers->data->id = $this->getIfSet('id', $response);
        $transfers->data->ownId = $this->getIfSet('ownId', $response);
        $transfers->data->amount = $this->getIfSet('amount', $response);

        $transfer_instrument = $this->getIfSet('transferInstrument', $response);
        $transfers->data->transferInstrument = new stdClass();
        $transfers->data->transferInstrument->method = $this->getIfSet('method', $transfer_instrument);

        $bank_account = $this->getIfSet('bankAccount', $transfer_instrument);
        $transfers->data->transferInstrument->bankAccount = new stdClass();
        $transfers->data->transferInstrument->bankAccount->id = $this->getIfSet('id', $bank_account);
        $transfers->data->transferInstrument->bankAccount->type = $this->getIfSet('type', $bank_account);
        $transfers->data->transferInstrument->bankAccount->bankNumber = $this->getIfSet('bankNumber', $bank_account);
        $transfers->data->transferInstrument->bankAccount->agencyNumber = $this->getIfSet('agencyNumber', $bank_account);
        $transfers->data->transferInstrument->bankAccount->agencyCheckNumber = $this->getIfSet('agencyCheckNumber', $bank_account);
        $transfers->data->transferInstrument->bankAccount->accountNumber = $this->getIfSet('accountNumber', $bank_account);
        $transfers->data->transferInstrument->bankAccount->accountCheckNumber = $this->getIfSet('accountCheckNumber', $bank_account);

        $holder = $this->getIfSet('holder', $bank_account);
        $transfers->data->transferInstrument->bankAccount->holder = new stdClass();
        $transfers->data->transferInstrument->bankAccount->holder->fullname = $this->getIfSet('fullname', $holder);

        $tax_document = $this->getIfSet('taxDocument', $holder);
        $this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass();
        $this->data->transferInstrument->bankAccount->holder->taxDocument->type = $this->getIfSet('type', $tax_document);
        $this->data->transferInstrument->bankAccount->holder->taxDocument->number = $this->getIfSet('number', $tax_document);

        return $transfers;
    }
50690
public function handleResponse($response)
    {
        // recursion for batch
        if (is_array($response)) {
            $response_arr = array();
            foreach ($response as $res) {
                $response_arr[$res->id] = $this->handleResponse($res);
            }
            return $response_arr;
        }

        // return error response
        if (property_exists($response, 'error')) {
            return new Response(null, $response->id, $response->error->code, $response->error->message);
        }

        // return successful response
        return new Response($response->result, $response->id);
    }
935061
protected function createPayment($response)
    {
        $payment = oxNew(\OxidEsales\PayPalModule\Model\OrderPayment::class);
        $payment->setDate($this->getDate());
        $payment->setTransactionId($response->getTransactionId());
        $payment->setCorrelationId($response->getCorrelationId());
        $payment->setAction('capture');
        $payment->setStatus($response->getPaymentStatus());
        $payment->setAmount($response->getCapturedAmount());
        $payment->setCurrency($response->getCurrency());

        return $payment;
    }
871004
public function applyToResponse($response)
    {
        $headers = $this->generateHeadersFor($response);
        foreach ($headers as $name => $value) {
            if (!$response->getHeader($name)) {
                $response->addHeader($name, $value);
            }
        }
        return $this;
    }
748808
protected function _modifyAfterCreate($response, $request) {
        if (!$this->_methodFailed($response)) {
            // figure out model name (request.method)
            $methodParts = explode('.', $request['method']);
            $modelClass  = Garp_Content_Api::modelAliasToClass(array_shift($methodParts));
            $model = new $modelClass();
            // combine primary keys to query params
            $primaryKey = array_values((array)$model->info(Zend_Db_Table::PRIMARY));
            $primaryKeyValues = array_values((array)$response['result']);
            $query = array();
            foreach ($primaryKey as $i => $key) {
                $query[$key] = $primaryKeyValues[$i];
            }
            // find the newly inserted rows
            $man = new Garp_Content_Manager(get_class($model));
            $rows = $man->fetch(array('query' => $query));
            $response['result'] = array(
                'rows' => $rows
            );
        }
        return $response;
    }
1090383
public static function toAssoc(array $response)
    {
        $out = [];
        $count = count($response);

        for ($i = 1; $i < $count; $i += 2) {
            $out[$response[$i - 1]] = $response[$i];
        }

        return $out;
    }
340597
public static function create(array $json)
    {
        $createTargetedMessageResponse = new CreateTargetedMessageResponse();
        $createTargetedMessageResponse->setStatusCode($json['status_code']);
        $createTargetedMessageResponse->setStatusMessage($json['status_message']);
    
        // If a 'response' is provided
        if (array_key_exists('response', $json) && isset($json['response'])) {
            $createTargetedMessageResponseResponse = new CreateTargetedMessageResponseResponse();
    
            // If 'messageCode' is provided
            if (array_key_exists('messageCode', $json['response'])) {
                $createTargetedMessageResponseResponse->setMessageCode($json['response']['messageCode']);
            }
    
            $createTargetedMessageResponse->setResponse($createTargetedMessageResponseResponse);
        }
    
        return $createTargetedMessageResponse;
    }
1079551
protected function populate(stdClass $response)
    {
        $escrow = clone $this;

        $escrow->data->id = $this->getIfSet('id', $response);
        $escrow->data->status = $this->getIfSet('status', $response);
        $escrow->data->description = $this->getIfSet('description', $response);
        $escrow->data->amount = $this->getIfSet('amount', $response);
        $escrow->data->_links = $this->getIfSet('_links', $response);
        $escrow->data->createdAt = $this->getIfSetDateTime('createdAt', $response);
        $escrow->data->updatedAt = $this->getIfSetDateTime('updatedAt', $response);

        return $escrow;
    }
223342
protected function populate(stdClass $response)
    {
        $balances = clone $this;
        $balances->data->unavailable = $this->getIfSet('unavailable', $response) ?: [];
        $balances->data->future = $this->getIfSet('future', $response) ?: [];
        $balances->data->current = $this->getIfSet('current', $response) ?: [];

        return $balances;
    }