Class: Bandwidth::Message
- Inherits:
-
Object
- Object
- Bandwidth::Message
- Extended by:
- ClientWrapper
- Defined in:
- lib/bandwidth/message.rb
Overview
The Messages resource lets you send SMS text messages and view messages that were previously sent or received.
Class Method Summary collapse
-
.create(client, data) ⇒ Hash
Send text messages.
-
.get(client, id) ⇒ Hash
Get information about a message that was sent or received.
-
.list(client, query = nil) ⇒ Array
Get a list of previous messages that were sent or received.
Methods included from ClientWrapper
Class Method Details
.create(client, data) ⇒ Hash
Send text messages
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/bandwidth/message.rb', line 36 def self.create(client, data) res = client.make_request(:post, client.concat_user_path(MESSAGE_PATH), data) if data.is_a? Array res[0].map do |i| if i[:result] == "error" {:error => StandardError.new(i[:error][:message])} else items = (i[:location] || '').split('/') if items.size < 2 then {:error => StandardError.new('Missing id in the location header')} else {:id => items.last} end end end else headers = res[1] id = Client.get_id_from_location_header(headers[:location]) self.get(client, id) end end |
.get(client, id) ⇒ Hash
Get information about a message that was sent or received
13 14 15 |
# File 'lib/bandwidth/message.rb', line 13 def self.get(client, id) client.make_request(:get, client.concat_user_path("#{MESSAGE_PATH}/#{id}"))[0] end |
.list(client, query = nil) ⇒ Array
Get a list of previous messages that were sent or received
24 25 26 |
# File 'lib/bandwidth/message.rb', line 24 def self.list(client, query = nil) client.make_request(:get, client.concat_user_path(MESSAGE_PATH), query)[0] end |