Class: Telapi::MMS
- Defined in:
- lib/telapi/mms.rb
Overview
Wraps TelAPI MMS Message functionality
Constant Summary collapse
- MAX_BODY_LENGTH =
160
Class Method Summary collapse
-
.create(to, from, body, attachment, status_callback = nil) ⇒ Object
Creates an MMS Message, returning a Telapi::MMS object.
-
.get(id) ⇒ Object
Returns a specific Telapi::MMS object given its id.
-
.list(optional_params = {}) ⇒ Object
Returns a resource collection containing Telapi::MMS objects.
Methods inherited from Resource
Methods included from Network
api_uri, default_options, delete, post, response_format
Constructor Details
This class inherits a constructor from Telapi::Resource
Class Method Details
.create(to, from, body, attachment, status_callback = nil) ⇒ Object
Creates an MMS Message, returning a Telapi::MMS object
Required params:
to
-
mobile phone number
from
-
TelAPI or mobile phone number
body
-
plain text up to 160 characters in length
attachment
-
URL for MMS attachment
Optional param:
status_callback
-
valid URL
37 38 39 40 41 42 |
# File 'lib/telapi/mms.rb', line 37 def create(to, from, body, , status_callback=nil) raise RangeError, "Body must be between 0 and #{MAX_BODY_LENGTH} characters" if body.length>MAX_BODY_LENGTH || body.length==0 opts = { :To => to, :From => from, :Body => body, :Attachment => , :StatusCallback => status_callback } response = Network.post(['MMS', 'Messages'], opts) MMS.new(response) end |
.get(id) ⇒ Object
Returns a specific Telapi::MMS object given its id
21 22 23 24 |
# File 'lib/telapi/mms.rb', line 21 def get(id) response = Network.get(['MMS', 'Messages', id]) Message.new(response) end |
.list(optional_params = {}) ⇒ Object
Returns a resource collection containing Telapi::MMS objects
Optional params is a hash containing:
To
-
mobile phone number
From
-
TelAPI or mobile phone number
DateSent
-
date in the following format: YYYY-MM-DD
Page
-
integer greater than 0
PageSize
-
integer greater than 0
15 16 17 18 |
# File 'lib/telapi/mms.rb', line 15 def list(optional_params = {}) response = Network.get(['MMS', 'Messages'], optional_params) ResourceCollection.new(response, 'mms_messages', self) end |