/** * Factory method to create the proper exception class depending on the error. * * @param ResponseException $re The response exception from the Edge API * * @return MintApiException MintApiException or a subclass of MintApiException */ public static function factory(ResponseException $re) { if (InsufficientFundsException::isInsufficientFundsException($re)) { return new InsufficientFundsException($re); } elseif (MintApiException::isMintExceptionCode($re)) { return new MintApiException($re); } else { throw new ParameterException('Not a registered mint exception.', $re); } }
public function forceSave() { $url = '/mint/organizations/' . rawurlencode($this->config->orgName) . '/developers/' . rawurlencode($this->developer_or_company_id) . '/developer-rateplans'; try { $obj = array('developer' => array('id' => $this->developer_or_company_id), 'startDate' => $this->startDate, 'endDate' => $this->endDate, 'ratePlan' => array('id' => $this->ratePlan->getId()), 'suppressWarning' => true); $this->setBaseUrl($url); $this->post(null, $obj); $this->restoreBaseUrl(); } catch (ResponseException $re) { if (MintApiException::isMintExceptionCode($re)) { throw new MintApiException($re); } throw $re; } }
/** * Get eligible Mint products for this developer. * * This function calls the /eligible-products API to find * out what products this developer is able to purchase. If the product * is associated to one or more packages, then the product is not displayed * unless the developer has purchased a plan that has that product * associated to it. * * @return array of * @throws \Apigee\Exceptions\ParameterException * @throws \Apigee\Mint\Exceptions\MintApiException * @throws \Exception */ public function getEligibleProducts() { if (!empty($this->email)) { $developer_id = $this->email; } else { throw new ParameterException("Developer id not specified"); } $products = array(); try { $url = rawurlencode($developer_id) . '/eligible-products'; $this->get($url); $data = $this->responseObj; foreach ($data['product'] as $product) { unset($product['organization']); $products[$product['name']] = $product; } } catch (\Exception $e) { if (MintApiException::isMintExceptionCode($e)) { throw new MintApiException($e); } else { throw $e; } } return $products; }
public function getPrepaidBalanceReport($month, $year, $developer_id, $currency_id) { try { $data = array('showTxDetail' => true, 'devCriteria' => array(array('id' => $developer_id, 'orgId' => $this->config->orgName)), 'currCriteria' => array(array('id' => strtolower($currency_id), 'orgId' => $this->config->orgName)), 'billingMonth' => strtoupper($month), 'billingYear' => $year); $url = '/mint/organizations/' . rawurlencode($this->config->orgName) . '/prepaid-balance-reports'; $content_type = 'application/json; charset=utf-8'; $accept_type = 'application/octet-stream; charset=utf-8'; $this->setBaseUrl($url); $this->post(null, $data, $content_type, $accept_type); $this->restoreBaseUrl(); $response = $this->responseText; } catch (ResponseException $re) { if (MintApiException::isMintExceptionCode($re)) { throw new MintApiException($re); } throw $re; } return $response; }
/** * @param $bill_doc_number * @param $developer_id * @return array * * @throws MintApiException */ public function searchBillingDoc($bill_doc_number, $developer_id) { $docs = array(); try { $url = '/mint/organizations/' . rawurlencode($this->config->orgName) . '/search-billing-documents'; $devCriteria = new \stdClass(); $devCriteria->id = $developer_id; $devCriteria->orgId = $this->config->orgName; $mintCriteria = array('devCriteria' => array($devCriteria), 'documentNumber' => $bill_doc_number); $this->setBaseUrl($url); $this->post(null, $mintCriteria); $this->restoreBaseUrl(); $response = $this->responseObj; foreach ($response[$this->wrapper_tag] as $doc) { $bill_doc = new BillingDocument($this->config); $bill_doc->loadFromRawData($doc); $docs[] = $bill_doc; } //return $this->responseObj; } catch (ResponseException $re) { if (MintApiException::isMintExceptionCode($re)) { throw new MintApiException($re); } } return $docs; }