Class: Sipgate
- Inherits:
-
Object
- Object
- Sipgate
- Defined in:
- lib/sipgate.rb
Defined Under Namespace
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#fax(number, pdf_message) ⇒ Object
versendet ein Fax.
-
#initialize ⇒ Sipgate
constructor
A new instance of Sipgate.
-
#rubyized_hash(h) ⇒ Object
make server responses look more Ruby like (underscored Symbol as Hash keys) source: github.com/martinrehfeld/telefon/blob/7133964255eefb4679d8759f467ec2f749459aaa/app/models/sipgate.rb.
-
#status(session_id) ⇒ Object
fragt den Status eines Faxes ab.
Constructor Details
#initialize ⇒ Sipgate
Returns a new instance of Sipgate.
6 7 8 9 10 11 |
# File 'lib/sipgate.rb', line 6 def initialize @client = XMLRPC::Client.new2("https://#{self.class.user}:#{self.class.password}@samurai.sipgate.net/RPC2") http = @client.instance_variable_get(:@http) http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.ca_path = '/etc/ssl/certs' end |
Instance Method Details
#call(*args) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/sipgate.rb', line 29 def call(*args) response = Response.new(rubyized_hash(@client.call(*args))) unless response.success? raise Sipgate::Exception.new(response.status_string, response.status_code) end response end |
#fax(number, pdf_message) ⇒ Object
versendet ein Fax
14 15 16 17 18 19 20 21 |
# File 'lib/sipgate.rb', line 14 def fax(number, ) number = number.gsub(/^(\+)/, "").gsub(/\s+/, "") call "samurai.SessionInitiate", 'RemoteUri' => "sip:#{number}@sipgate.net", 'TOS' => 'fax', 'Content' => Base64.encode64() end |
#rubyized_hash(h) ⇒ Object
make server responses look more Ruby like (underscored Symbol as Hash keys) source: github.com/martinrehfeld/telefon/blob/7133964255eefb4679d8759f467ec2f749459aaa/app/models/sipgate.rb
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sipgate.rb', line 41 def rubyized_hash(h) returning new_hash = {} do h.each do |k,v| new_val = if v.is_a?(Hash) rubyized_hash(v) elsif v.is_a?(Array) v.map{|e| e.is_a?(Hash) ? rubyized_hash(e) : e} else v end new_hash[k.to_s.underscore.to_sym] = new_val end end end |
#status(session_id) ⇒ Object
fragt den Status eines Faxes ab
24 25 26 27 |
# File 'lib/sipgate.rb', line 24 def status(session_id) call "samurai.SessionStatusGet", 'SessionID' => session_id end |