Class: Hermes::PlivoProvider
- Defined in:
- lib/providers/plivo/plivo_provider.rb
Instance Attribute Summary
Attributes inherited from Provider
#credentials, #defaults, #deliverer, #weight
Instance Method Summary collapse
Methods inherited from Provider
#initialize, #message_failure, #message_success, #provider_name, required_credentials
Methods included from Extractors
#complex_extract, #extract_from, #extract_html, #extract_text, #extract_to
Constructor Details
This class inherits a constructor from Hermes::Provider
Instance Method Details
#client ⇒ Object
29 30 31 |
# File 'lib/providers/plivo/plivo_provider.rb', line 29 def client Plivo::RestAPI.new(self.credentials[:auth_id], self.credentials[:auth_token]) end |
#payload(rails_message) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/providers/plivo/plivo_provider.rb', line 19 def payload() { src: extract_from().full_number, dst: extract_to(), text: extract_text(), type: :sms, url: .plivo_url || self.defaults[:url] } end |
#send_message(rails_message) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/providers/plivo/plivo_provider.rb', line 5 def () payload = payload() if self.deliverer.should_deliver? result = self.client.(payload) [:message_id] = result["api_id"] else # rails message still needs a fake sid as if it succeeded [:message_id] = SecureRandom.uuid end self.() end |