Skip to content

Commit 3d899b7

Browse files
author
Doug Crescenzi
committed
added list and get functions to MMS; both still require tests
1 parent b175d09 commit 3d899b7

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

lib/telapi/mms.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ class MMS < Resource
44
class << self
55
MAX_BODY_LENGTH = 160
66

7+
# Returns a resource collection containing Telapi::MMS objects
8+
#
9+
# Optional params is a hash containing:
10+
# +To+:: mobile phone number
11+
# +From+:: TelAPI or mobile phone number
12+
# +DateSent+:: date in the following format: YYYY-MM-DD
13+
# +Page+:: integer greater than 0
14+
# +PageSize+:: integer greater than 0
15+
def list(optional_params = {})
16+
response = Network.get(['MMS', 'Messages'], optional_params)
17+
ResourceCollection.new(response, 'mms_messages', self)
18+
end
19+
20+
# Returns a specific Telapi::Message object given its id
21+
def get(id)
22+
response = Network.get(['MMS', 'Messages', id])
23+
Message.new(response)
24+
end
25+
726
# Creates an MMS Message, returning a Telapi::MMS object
827
#
928
# Required params:
@@ -15,13 +34,13 @@ class << self
1534
# Optional param:
1635
# +status_callback+:: valid URL
1736

18-
def create(from, to, body, attachment, status_callback=nil)
37+
def create(to, from, body, attachment, status_callback=nil)
1938
raise RangeError, "Body must be between 0 and #{MAX_BODY_LENGTH} characters" if body.length>MAX_BODY_LENGTH || body.length==0
20-
opts = { :From => from, :To => to, :Body => body, :Attachment => attachment, :StatusCallback => status_callback }
39+
opts = { :To => to, :From => from, :Body => body, :Attachment => attachment, :StatusCallback => status_callback }
2140
response = Network.post(['MMS', 'Messages'], opts)
2241
MMS.new(response)
2342
end
2443

2544
end
2645
end
27-
end
46+
end

lib/telapi/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Telapi
2-
VERSION = "1.2.1"
2+
VERSION = "1.2.2"
33
end

0 commit comments

Comments
 (0)