Skip to content

Commit 61db54f

Browse files
author
Doug Crescenzi
committed
created MMS wrapper
1 parent b6d2a48 commit 61db54f

4 files changed

Lines changed: 47 additions & 3 deletions

File tree

lib/telapi/mms.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module Telapi
2+
# Wraps TelAPI MMS Message functionality
3+
class MMS < Resource
4+
class << self
5+
MAX_BODY_LENGTH = 160
6+
7+
# Creates an MMS Message, returning a Telapi::MMS object
8+
#
9+
# Required params:
10+
# +to+:: mobile phone number
11+
# +from+:: TelAPI or mobile phone number
12+
# +body+:: plain text up to 160 characters in length
13+
# +attachment+:: URL for MMS attachment
14+
#
15+
# Optional param:
16+
# +status_callback+:: valid URL
17+
18+
def create(from, to, body, attachment, status_callback=nil)
19+
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 }
21+
response = Network.post(['MMS', 'Messages'], opts)
22+
MMS.new(response)
23+
end
24+
25+
end
26+
end
27+
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.0"
2+
VERSION = "1.2.1"
33
end

spec/telapi/mms_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require 'spec_helper'
2+
3+
describe Telapi::Message do
4+
before do
5+
stub_telapi_request
6+
set_account_sid_and_auth_token
7+
end
8+
9+
it { should be_kind_of(Telapi::Resource) }
10+
11+
describe ".create" do
12+
it "calls api via http post and returns a MMS resource" do
13+
api_should_use(:post)
14+
klass.create('(111) 111-1111', '(999) 999-9999', 'My MMS message', 'https://si0.twimg.com/profile_images/2539396551/4jsroc6lvo800o81iw64.png').should be_a(klass)
15+
end
16+
end
17+
end

telapi-ruby.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ require 'telapi/version'
66
Gem::Specification.new do |gem|
77
gem.name = "telapi"
88
gem.version = Telapi::VERSION
9-
gem.authors = ["Phil Misiowiec", "Matt Meyer"]
10-
gem.email = ["phil@webficient.com", "mmeyer@telapi.com"]
9+
gem.authors = ["Phil Misiowiec", "Matt Meyer", "Doug Crescenzi"]
10+
gem.email = ["phil@webficient.com", "mmeyer@telapi.com", "doug@douglascrescenzi.com"]
1111
gem.description = %q{TelAPI wrapper. See www.telapi.com.}
1212
gem.summary = %q{TelAPI wrapper}
1313
gem.homepage = "http://github.com/telapi/telapi-ruby"

0 commit comments

Comments
 (0)