|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Nexmo\Account; |
| 4 | + |
| 5 | +use ArrayAccess; |
| 6 | +use Nexmo\Client\Exception\Exception; |
| 7 | +use Nexmo\Entity\JsonSerializableInterface; |
| 8 | +use Nexmo\Entity\JsonUnserializableInterface; |
| 9 | + |
| 10 | +class Config implements JsonSerializableInterface, JsonUnserializableInterface, ArrayAccess { |
| 11 | + public function __construct($sms_callback_url = null, $dr_callback_url = null, $max_outbound_request = null, $max_inbound_request = null, $max_calls_per_second = null) |
| 12 | + { |
| 13 | + if(!is_null($sms_callback_url)) { |
| 14 | + $this->data['sms_callback_url'] = $sms_callback_url; |
| 15 | + } |
| 16 | + if(!is_null($dr_callback_url)) { |
| 17 | + $this->data['dr_callback_url'] = $dr_callback_url; |
| 18 | + } |
| 19 | + if(!is_null($max_outbound_request)) { |
| 20 | + $this->data['max_outbound_request'] = $max_outbound_request; |
| 21 | + } |
| 22 | + if(!is_null($max_inbound_request)) { |
| 23 | + $this->data['max_inbound_request'] = $max_inbound_request; |
| 24 | + } |
| 25 | + if(!is_null($max_calls_per_second)) { |
| 26 | + $this->data['max_calls_per_second'] = $max_calls_per_second; |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + public function getSmsCallbackUrl() |
| 31 | + { |
| 32 | + return $this['sms_callback_url']; |
| 33 | + } |
| 34 | + |
| 35 | + public function getDrCallbackUrl() |
| 36 | + { |
| 37 | + return $this['dr_callback_url']; |
| 38 | + } |
| 39 | + |
| 40 | + public function getMaxOutboundRequest() |
| 41 | + { |
| 42 | + return $this['max_outbound_request']; |
| 43 | + } |
| 44 | + |
| 45 | + public function getMaxInboundRequest() |
| 46 | + { |
| 47 | + return $this['max_inbound_request']; |
| 48 | + } |
| 49 | + |
| 50 | + public function getMaxCallsPerSecond() |
| 51 | + { |
| 52 | + return $this['max_calls_per_second']; |
| 53 | + } |
| 54 | + |
| 55 | + public function jsonUnserialize(array $json) |
| 56 | + { |
| 57 | + $this->data = [ |
| 58 | + 'sms_callback_url' => $json['sms_callback_url'], |
| 59 | + 'dr_callback_url' => $json['dr_callback_url'], |
| 60 | + 'max_outbound_request' => $json['max_outbound_request'], |
| 61 | + 'max_inbound_request' => $json['max_inbound_request'], |
| 62 | + 'max_calls_per_second' => $json['max_calls_per_second'], |
| 63 | + ]; |
| 64 | + } |
| 65 | + |
| 66 | + function jsonSerialize() |
| 67 | + { |
| 68 | + return $this->data; |
| 69 | + } |
| 70 | + |
| 71 | + public function offsetExists($offset) |
| 72 | + { |
| 73 | + return isset($this->data[$offset]); |
| 74 | + } |
| 75 | + |
| 76 | + public function offsetGet($offset) |
| 77 | + { |
| 78 | + return $this->data[$offset]; |
| 79 | + } |
| 80 | + |
| 81 | + public function offsetSet($offset, $value) |
| 82 | + { |
| 83 | + throw new Exception('Balance is read only'); |
| 84 | + } |
| 85 | + |
| 86 | + public function offsetUnset($offset) |
| 87 | + { |
| 88 | + throw new Exception('Balance is read only'); |
| 89 | + } |
| 90 | +} |
| 91 | + |
0 commit comments