예제 #1
0
 /**
  * Creates multiple pricing component charges on the invoice
  * @param array[string => number] $namesToValues The map of pricing component names (or IDs) to quantities
  * Example:
  * array(
  * 	'Bandwidth' => 102,
  * 	'CPU' => 10
  * )
  * @param array $chargeOptions (Default: All keys set to their respective default values) Encapsulates the following optional parameters:
  *	* @param Boolean (Default: NULL) $..['dryRun'] [If null: do not override the `dryRun` value to which the nested requests default.] Whether to forego persisting the effected changes.
  *	* @param string_ENUM['Immediate', 'Aggregated'] (Default: NULL) $..['invoicingType'] Subscription-charge invoicing type
  *	*
  *	*	NULL
  *  *	Do not override the `invoicingType` value to which the nested requests default.
  *  *	
  *	*	<Immediate>
  *	*	Generate invoice straight away with this charge applied.
  *	*
  *	*	<Aggregated> (Default)
  *	*	Add this charge to next invoice.
  *	*
  * @return Bf_AddChargesResponse Response object containing result of adding batch of charges
  */
 public function chargeComponentsBatch(array $namesToValues, array $chargeOptions = array('invoicingType' => 'Aggregated', 'dryRun' => false))
 {
     $inputOptions = $chargeOptions;
     $invoiceID = Bf_Invoice::getIdentifier($this);
     $addChargeRequests = array_map(function ($key, $value) {
         $stateParams = array('pricingComponent' => $key, 'pricingComponentValue' => $value);
         $addChargeRequest = new Bf_AddChargeRequest($stateParams);
         return $addChargeRequest;
     }, array_keys($namesToValues), $namesToValues);
     $stateParams = static::mergeUserArgsOverNonNullDefaults(__METHOD__, array('requests' => $addChargeRequests), $inputOptions);
     $requestEntity = new Bf_AddChargesToInvoiceRequest($stateParams);
     $endpoint = sprintf("%s/charges/batch", rawurlencode($invoiceID));
     $responseEntity = Bf_AddChargesResponse::getClassName();
     $constructedEntity = static::postEntityAndGrabFirst($endpoint, $requestEntity, $responseEntity);
     return $constructedEntity;
 }
예제 #2
0
 /**
  * Gets Bf_CreditNotes for a given Bf_Invoice
  * @param union[string | Bf_Invoice] $invoice Reference to invoice <string>: $id of the Bf_Invoice. <Bf_Invoice>: The Bf_Invoice entity.
  * @return Bf_CreditNote[]
  */
 public static function getForInvoice($invoice, $options = NULL, $customClient = NULL)
 {
     $invoiceID = Bf_Invoice::getIdentifier($invoice);
     $endpoint = sprintf("invoice/%s", rawurlencode($invoiceID));
     return static::getCollection($endpoint, $options, $customClient);
 }