Class: VoipfoneClient::GlobalDivert
- Defined in:
- lib/voipfone_client/global_divert.rb
Overview
Set up a global (whole-account) divert on your account. You need to specify the type of divert and the number to which the divert will go to. There are 4 supported situations which can be diverted for, namely:
- all calls (i.e. no calls will reach the pbx / phones - immediate divert)
- when there is a failure in the phone system
- when the phone(s) are busy
- when there's no answer
Constant Summary collapse
- VOIPFONE_DIVERT_NAMES =
A hash of voipfone divert names vs our divert names. Note that when we query voipfone the returned value of the divert type is UPPERCASE.
{ "all" => "all", "chanunavail" => "fail", "busy" => "busy", "noanswer" => "no_answer" }
Instance Attribute Summary collapse
-
#number ⇒ Object
Returns the value of attribute number.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Client
Class Method Summary collapse
-
.all ⇒ Array
Get current diverts.
Instance Method Summary collapse
-
#clear! ⇒ Boolean
Clear all diverts.
-
#initialize(divert_list_item = nil) ⇒ GlobalDivert
constructor
Constructor for ‘GlobalDivert` which allows you to pass in a `DivertListItem` to be used as the receiving number.
-
#save ⇒ Boolean
Save the divert on your account.
Methods inherited from Client
#account_balance, #account_details, #parse_response, #phone_numbers, #voicemail
Constructor Details
#initialize(divert_list_item = nil) ⇒ GlobalDivert
Constructor for ‘GlobalDivert` which allows you to pass in a `DivertListItem` to be used as the receiving number. You still need to specify the divert type.
16 17 18 19 20 21 |
# File 'lib/voipfone_client/global_divert.rb', line 16 def initialize(divert_list_item = nil) if divert_list_item.is_a?(DivertListItem) @number = divert_list_item.number end super() end |
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
11 12 13 |
# File 'lib/voipfone_client/global_divert.rb', line 11 def number @number end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/voipfone_client/global_divert.rb', line 11 def type @type end |
Class Method Details
.all ⇒ Array
Get current diverts
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/voipfone_client/global_divert.rb', line 49 def all g = self.new request = g.browser.get("#{VoipfoneClient::API_GET_URL}?divertsMain") g.parse_response(request)["divertsMain"].collect do |d| divert = GlobalDivert.new divert.number = d[1] divert.type = VOIPFONE_DIVERT_NAMES[d[2].downcase].to_sym divert end end |
Instance Method Details
#clear! ⇒ Boolean
Clear all diverts
43 44 45 |
# File 'lib/voipfone_client/global_divert.rb', line 43 def clear! set_diverts() end |
#save ⇒ Boolean
Save the divert on your account
34 35 36 37 38 39 |
# File 'lib/voipfone_client/global_divert.rb', line 34 def save if @type.nil? || @number.nil? raise ArgumentError, "You need to set a divert type and divert number before you can save the divert." end set_diverts(@type => @number) end |