Class: Trumpet::Listener
Class Method Summary collapse
Instance Method Summary collapse
- #delete(options = {}) ⇒ Object
- #delivery_address ⇒ Object
- #delivery_method ⇒ Object
- #receiver(options = {}) ⇒ Object
Class Method Details
.create(options) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/trumpet/listener.rb', line 4 def self.create() if [:parameters][:receiver_id] Listener.new(Trumpet::Request.post("/receivers/#{[:parameters][:receiver_id]}/listeners", )) else raise Trumpet::BadRequest, "Must specify a receiver id when creating a listener" end end |
Instance Method Details
#delete(options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/trumpet/listener.rb', line 16 def delete(={}) [:credentials] ||= @credentials [:parse_response] = false !!Trumpet::Request.delete("/listeners/#{@id}", ) end |
#delivery_address ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/trumpet/listener.rb', line 39 def delivery_address case URI.parse(uri).scheme when 'mailto' then URI.parse(uri).to when 'tel' then URI.parse(uri).opaque when 'twitter' then URI.parse(uri).opaque when 'irc' url = URI.parse(uri) "#{url.host}##{url.fragment}" when 'im' url = URI.parse(uri) "#{url.user}@#{url.host}" end end |
#delivery_method ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/trumpet/listener.rb', line 29 def delivery_method case URI.parse(uri).scheme when 'mailto' then 'Email' when 'tel' then 'SMS' when 'twitter' then 'Twitter' when 'irc' then 'IRC' when 'im' then 'IM' end end |