/** * Get Telephony account service properties * * @param string $service * @param Telephony $telephoneAccount * @return string Json * @throws Exception\VoiceConsumptionException * @throws BadMethodCallException */ public function getProperties($consumptionId, $telephoneAccount) { if (!$consumptionId) { throw new BadMethodCallException('Parameter $consumptionId is missing.'); } if (!$telephoneAccount) { throw new BadMethodCallException('Parameter $telephoneAccount is missing.'); } try { $r = $this->get('telephony/' . $telephoneAccount->getBillingAccount()->getBillingAccount() . '/service/' . $telephoneAccount->getService() . '/voiceConsumption/' . $consumptionId)->send(); } catch (\Exception $e) { throw new VoiceConsumptionException($e->getMessage(), $e->getCode(), $e); } return $r->getBody(true); }
/** * Get Telephony account service fax consumptions. * * @param string $service * @param Telephony $billingAccount * @return string Json * @throws Exception\TelephonyAccountServiceException * @throws BadMethodCallException */ public function getFaxConsumptions($service, $billingAccount, $params = null) { $paramsString = ""; if (!$service) { throw new BadMethodCallException('Parameter $service is missing.'); } if (!$billingAccount) { throw new BadMethodCallException('Parameter $billingAccount is missing.'); } if ($params != null && is_array($params) && count($params) > 0) { $paramsString = "?"; if (array_key_exists('creationDatetime.from', $params)) { $string = $params['creationDatetime.from']; if ($params['creationDatetime.from'] instanceof \Datetime) { $string = $params['creationDatetime.from']->format("Y-m-d\\TH:i:sP"); } $paramsString .= "creationDatetime.from=" . urlencode($string); } if (array_key_exists('creationDatetime.to', $params)) { $paramsString .= "&"; $string = $params['creationDatetime.to']; if ($params['creationDatetime.to'] instanceof \Datetime) { $string = $params['creationDatetime.to']->format("Y-m-d\\TH:i:sP"); } $paramsString .= "creationDatetime.to=" . urlencode($string); } if (array_key_exists('destinationType', $params) && in_array($params['destinationType'], array('landline', 'mobile', 'special'))) { $paramsString .= "&"; $paramsString .= "destinationType=" . $params['destinationType']; } if (array_key_exists('planType', $params) && in_array($params['planType'], array('outplan', 'priceplan'))) { $paramsString .= "&"; $paramsString .= "planType=" . $params['planType']; } if (array_key_exists('wayType', $params) && in_array($params['wayType'], array('incoming', 'outgoing', 'transfer'))) { $paramsString .= "&"; $paramsString .= "wayType=" . $params['wayType']; } } try { $r = $this->get('telephony/' . $billingAccount->getBillingAccount() . '/service/' . $service . '/faxConsumption' . $paramsString)->send(); } catch (\Exception $e) { throw new TelephonyAccountServiceException($e->getMessage(), $e->getCode(), $e); } return $r->getBody(true); }