eztexting 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +0 -0
- data/Manifest +18 -0
- data/README.textile +62 -0
- data/RELEASE_NOTES +7 -0
- data/Rakefile +22 -0
- data/VERSION +1 -0
- data/examples/example_script.rb +19 -0
- data/eztexting.gemspec +33 -0
- data/lib/eztexting.rb +29 -0
- data/lib/eztexting/availablity.rb +38 -0
- data/lib/eztexting/base.rb +35 -0
- data/lib/eztexting/credits.rb +69 -0
- data/lib/eztexting/keywords.rb +46 -0
- data/lib/eztexting/lookup.rb +18 -0
- data/lib/eztexting/sms.rb +59 -0
- data/lib/eztexting/voice.rb +49 -0
- data/spec/eztexting/eztexting_spec.rb +24 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +19 -0
- metadata +96 -0
data/LICENSE
ADDED
File without changes
|
data/Manifest
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
LICENSE
|
2
|
+
Manifest
|
3
|
+
README.textile
|
4
|
+
RELEASE_NOTES
|
5
|
+
Rakefile
|
6
|
+
VERSION
|
7
|
+
examples/example_script.rb
|
8
|
+
lib/eztexting.rb
|
9
|
+
lib/eztexting/availablity.rb
|
10
|
+
lib/eztexting/base.rb
|
11
|
+
lib/eztexting/credits.rb
|
12
|
+
lib/eztexting/keywords.rb
|
13
|
+
lib/eztexting/lookup.rb
|
14
|
+
lib/eztexting/sms.rb
|
15
|
+
lib/eztexting/voice.rb
|
16
|
+
spec/eztexting/eztexting_spec.rb
|
17
|
+
spec/spec.opts
|
18
|
+
spec/spec_helper.rb
|
data/README.textile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
h1. Eztexting Gem
|
2
|
+
|
3
|
+
0.3.0
|
4
|
+
|
5
|
+
This is a gem built to make the eztexting api's as easy to use as possible. They allow for use of all of what the API offers in a
|
6
|
+
very easy and clear fashion.
|
7
|
+
|
8
|
+
h2. Dependencies
|
9
|
+
|
10
|
+
This gem relies on HTTParty for making its requests. That is the only runtime dependency. The testing uses rspec and the documentation
|
11
|
+
is written to be viewed with YARD.
|
12
|
+
|
13
|
+
h2. API Calls Available
|
14
|
+
These are the following calls available and their corresponding classes to use them
|
15
|
+
|
16
|
+
* SMS (Eztexting::Sms)
|
17
|
+
* Credit Purchase and Balance Check (Eztexting::Credits)
|
18
|
+
* Keyword Check and Configuration (Eztexting::Keyword)
|
19
|
+
* Carrier Lookups (Eztexting::Lookup)
|
20
|
+
* Voice Broadcast (Eztexting::Broadcast)
|
21
|
+
|
22
|
+
h2. How To Use / How The Gem Is Setup
|
23
|
+
|
24
|
+
Basically all you need to do is call the connect method on the Eztexting module. Once thats done then your credentials are cached and you
|
25
|
+
can use any of the classes to interact with the Eztexting service.
|
26
|
+
|
27
|
+
**All API calls require your user name and password** which is why you call
|
28
|
+
the connect method and cache them. By doing this you enter your credentials once and then they merged with the options for the api call you
|
29
|
+
want to make. This makes interacting with the Eztexting API far less irritating as there is no state or authentication and the credentials
|
30
|
+
must be passed along through every request.
|
31
|
+
|
32
|
+
|
33
|
+
h2. Examples
|
34
|
+
|
35
|
+
<notextile><pre>
|
36
|
+
|
37
|
+
# Setup the connection for making requests.
|
38
|
+
Eztexting.connect!('username','password')
|
39
|
+
# => "credentials cached"
|
40
|
+
|
41
|
+
# Make a hash with the required keys of subject, message and phonenumber
|
42
|
+
# and then send out the SMS. Its that simple. 3 lines, 2 if you condense the creation of the Hash into the Method call
|
43
|
+
# The response will be an array , the first element will be the response mapped from the code to the literal that the Eztexting
|
44
|
+
# documentation lists out. The second element will be the raw value. In some cases this bit is important , in the credit balance
|
45
|
+
# check this would be the number of credits.
|
46
|
+
options = {:subject => "testing out how awesome eztexting is", :phonenumber => "5165551234", :message => "Wow this is so simple and easy to use"}
|
47
|
+
Eztexting::Sms.single(options)
|
48
|
+
# => ["Message Sent",1]
|
49
|
+
|
50
|
+
# Check Your Credit Count
|
51
|
+
Eztexting::Credits.balance
|
52
|
+
# => ["The amount of plan and additional credits available", 54353]
|
53
|
+
|
54
|
+
# Check If A Keyword Is Available
|
55
|
+
Eztexting::Availablity.check("my_keyowrd_to_check")
|
56
|
+
# => ["The Keyword Is Available", 1]
|
57
|
+
|
58
|
+
# Make Voice Broadcast
|
59
|
+
options = {:phonenumbers => 51659232132, :soundsource => "http://mywebsite.com/dunder_mifflin_is_a_part_of_sabre.wav", :callerid => 4013210192}
|
60
|
+
Eztexting::Voice.broadcast(options)
|
61
|
+
# => ["Campaign Sent",1]
|
62
|
+
</pre></notextile>
|
data/RELEASE_NOTES
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
require 'yard'
|
5
|
+
|
6
|
+
Echoe.new('eztexting', '0.3.0') do |p|
|
7
|
+
p.description = "A Gem to make using eztexting simple and fun"
|
8
|
+
p.url = "http://github.com/EzTexting/eztexting"
|
9
|
+
p.author = "David Malin"
|
10
|
+
p.email = "dmalin@eztexting.com"
|
11
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
12
|
+
p.development_dependencies = []
|
13
|
+
p.runtime_dependencies = ["httparty >=0.6.0"]
|
14
|
+
end
|
15
|
+
|
16
|
+
YARD::Rake::YardocTask.new do |t|
|
17
|
+
t.files = ['lib/**/*.rb'] # optional
|
18
|
+
t.options = ['--any', '--extra', '--opts'] # optional
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'eztexting'
|
3
|
+
|
4
|
+
# Cache your credentials for all subsequent requests, this is required, you must do this so that all of
|
5
|
+
# your requests can have the right parameters. All requests to the api require the userame and password.
|
6
|
+
Eztexting.connect!(username,password)
|
7
|
+
|
8
|
+
# Now you ready to make full use of the api. The api calls are implemented as subclasses of a base class. This
|
9
|
+
# class has the posting method that merges in the username and password each time that you initialized in the
|
10
|
+
# connect method.
|
11
|
+
#
|
12
|
+
# All you have to do is pass in the call specific parameters, the username and password will be injected,
|
13
|
+
# here cheeck the availablity of the money keyword
|
14
|
+
Eztexting::Availability.check("money")
|
15
|
+
|
16
|
+
|
17
|
+
# Now lets make an acutal text message. Make a hash with the parameters for the api call
|
18
|
+
msg = {:phonenumber=>"5165551234", :message=>"My First Text MEssage", :subject=>"This is an awesome service. I love eztexting"}
|
19
|
+
Eztexting::Sms.single(msg)
|
data/eztexting.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{eztexting}
|
5
|
+
s.version = "0.3.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["David Malin"]
|
9
|
+
s.date = %q{2010-09-08}
|
10
|
+
s.description = %q{A Gem to make using eztexting simple and fun}
|
11
|
+
s.email = %q{dmalin@eztexting.com}
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "README.textile", "lib/eztexting.rb", "lib/eztexting/availablity.rb", "lib/eztexting/base.rb", "lib/eztexting/credits.rb", "lib/eztexting/keywords.rb", "lib/eztexting/lookup.rb", "lib/eztexting/sms.rb", "lib/eztexting/voice.rb"]
|
13
|
+
s.files = ["LICENSE", "Manifest", "README.textile", "RELEASE_NOTES", "Rakefile", "VERSION", "examples/example_script.rb", "lib/eztexting.rb", "lib/eztexting/availablity.rb", "lib/eztexting/base.rb", "lib/eztexting/credits.rb", "lib/eztexting/keywords.rb", "lib/eztexting/lookup.rb", "lib/eztexting/sms.rb", "lib/eztexting/voice.rb", "spec/eztexting/eztexting_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "eztexting.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/EzTexting/eztexting}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Eztexting", "--main", "README.textile"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{eztexting}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{A Gem to make using eztexting simple and fun}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0.6.0"])
|
27
|
+
else
|
28
|
+
s.add_dependency(%q<httparty>, [">= 0.6.0"])
|
29
|
+
end
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<httparty>, [">= 0.6.0"])
|
32
|
+
end
|
33
|
+
end
|
data/lib/eztexting.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'eztexting/base'
|
3
|
+
require 'eztexting/availablity'
|
4
|
+
require 'eztexting/credits'
|
5
|
+
require 'eztexting/keywords'
|
6
|
+
require 'eztexting/lookup'
|
7
|
+
require 'eztexting/sms'
|
8
|
+
require 'eztexting/voice'
|
9
|
+
|
10
|
+
module Eztexting
|
11
|
+
include HTTParty
|
12
|
+
|
13
|
+
# Sets up the connection that the other classes
|
14
|
+
# use to be able communicate with the api
|
15
|
+
def self.connect!(username,password)
|
16
|
+
# HTTParty Method to store base url
|
17
|
+
self.base_uri "https://app.eztexting.com/api"
|
18
|
+
|
19
|
+
# Catch the username and password for use in all calls
|
20
|
+
@username = username
|
21
|
+
@password = password
|
22
|
+
puts "credentials cached"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.credentials
|
26
|
+
{:user => @username, :pass => @password}
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Availability < Base
|
3
|
+
|
4
|
+
# Check the availablity of a keyword
|
5
|
+
# @param [String] This is the keyword that you would like to check the status of.
|
6
|
+
# @return [Array] The first element will be weather the keyword is free or a status message , the second element is the raw response
|
7
|
+
def self.check(keyword)
|
8
|
+
location = "/keyword/check/"
|
9
|
+
options = {:keyword => keyword}
|
10
|
+
|
11
|
+
response = self.do_post(location,options)
|
12
|
+
response_result = self.process(response)
|
13
|
+
|
14
|
+
return self.processed_reponse(response_result,response)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def self.process(response)
|
21
|
+
api_result = case response
|
22
|
+
when "1"
|
23
|
+
"The keyword is available"
|
24
|
+
when "0"
|
25
|
+
"The keyword is no available"
|
26
|
+
when "-1"
|
27
|
+
"Invalid user and/or password or API is not allowed for your account"
|
28
|
+
when "-10"
|
29
|
+
"error"
|
30
|
+
else
|
31
|
+
"error"
|
32
|
+
end
|
33
|
+
|
34
|
+
return api_result
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Base
|
3
|
+
|
4
|
+
# This method never is really called by itself it is called from the classses do the work of the actual
|
5
|
+
# interaction with the api itself.
|
6
|
+
def self.do_post(uri,options)
|
7
|
+
options = options || {}
|
8
|
+
options = options.merge!(Eztexting.credentials)
|
9
|
+
location = uri
|
10
|
+
|
11
|
+
response = Eztexting.post(location, :body => options)
|
12
|
+
return response.body
|
13
|
+
end
|
14
|
+
|
15
|
+
# This is a default result mapping. The response from the API is usually a coded number (except for the balance call which returns
|
16
|
+
# the acutal number of credits). Here we map over those values to a response. This is sometimes overidden by the subclasses as thses
|
17
|
+
# mappings to not apply the same way to all commands
|
18
|
+
def self.process(response)
|
19
|
+
api_result = case response
|
20
|
+
when "-1"
|
21
|
+
"Invalid user and/or password or API is not allowed for your account"
|
22
|
+
when "-10"
|
23
|
+
"Unknown error (please contact our support dept.)"
|
24
|
+
else
|
25
|
+
"successful"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# This just assembles the data to be returned from do_post in a nice clean way
|
30
|
+
def self.processed_reponse(response_result,response_body)
|
31
|
+
[response_result,response_body]
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Credits < Base
|
3
|
+
|
4
|
+
# Check the balance of credits left on your account
|
5
|
+
# @return [Array] The return is an array of two elements, if the call was sucessfull the you should get the success and the second element will be the number of credits available.
|
6
|
+
def self.balance
|
7
|
+
location = "/credits/check/"
|
8
|
+
|
9
|
+
response = self.do_post(location,{})
|
10
|
+
response_result = if response.to_i > 0
|
11
|
+
"The amount of plan and additional credits available"
|
12
|
+
elsif response == -1
|
13
|
+
"Invalid user and/or password or API is not allowed for your account"
|
14
|
+
else
|
15
|
+
"Unknown error (please contact our support dept.)"
|
16
|
+
end
|
17
|
+
|
18
|
+
return self.processed_reponse(response_result,response)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Purchase more credits for your account
|
22
|
+
# @param [Hash] This takes alot of keys that are all required, you need a full billing address and a full credit card
|
23
|
+
# @return [Array] The return is an array of two elements, the mapped error code according to the extexting and the raw response
|
24
|
+
def self.purchase(opts={})
|
25
|
+
location = "/credits/buy/"
|
26
|
+
options = {
|
27
|
+
:credits => opts[:credits],
|
28
|
+
:firstname => opts[:first_name],
|
29
|
+
:lastname => opts[:last_name],
|
30
|
+
:address => opts[:address],
|
31
|
+
:city => opts[:city],
|
32
|
+
:state => opts[:state],
|
33
|
+
:zip => opts[:zip],
|
34
|
+
:country => opts[:country],
|
35
|
+
:type => opts[:cc_type],
|
36
|
+
:ccnumber => opts[:cc_number],
|
37
|
+
:cccode => opts[:cc_verification_code],
|
38
|
+
:expm => opts[:cc_expiration_month],
|
39
|
+
:expy => opts[:cc_expiration_year]
|
40
|
+
}
|
41
|
+
|
42
|
+
response = self.do_post(location,options)
|
43
|
+
response_result = self.process(response)
|
44
|
+
|
45
|
+
return self.processed_reponse(response_result,response)
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
def self.process(response)
|
50
|
+
api_result = case response
|
51
|
+
when "1"
|
52
|
+
"Purchase Was Sucessful"
|
53
|
+
when "0"
|
54
|
+
"The Purchase Was Declined"
|
55
|
+
when "-1"
|
56
|
+
"Invalid user and/or password or API is not allowed for your account"
|
57
|
+
when "-2"
|
58
|
+
"Request declined because it is less than $5.00 minimum purchase."
|
59
|
+
when "-10"
|
60
|
+
"Unknown error (please contact our support dept.)"
|
61
|
+
else
|
62
|
+
"Unknown error (please contact our support dept.)"
|
63
|
+
end
|
64
|
+
|
65
|
+
return api_result
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Keywords < Base
|
3
|
+
|
4
|
+
# Rent a keyword
|
5
|
+
# @param [Hash] This requires alot of parameters in the hash you pass in. You need to pass in a full address, credit card with all the info and the keyword
|
6
|
+
# @return [Array] The return is an array of two elements, the mapped error code according to the extexting and the raw response
|
7
|
+
def self.rent(opts={})
|
8
|
+
location = "/keyword/rent/"
|
9
|
+
options = {
|
10
|
+
:keyword => opts[:keyword],
|
11
|
+
:firstname => opts[:first_name],
|
12
|
+
:lastname => opts[:last_name],
|
13
|
+
:address => opts[:address],
|
14
|
+
:city => opts[:city],
|
15
|
+
:state => opts[:state],
|
16
|
+
:zip => opts[:zip],
|
17
|
+
:country => opts[:country],
|
18
|
+
:type => opts[:cc_type],
|
19
|
+
:ccnumber => opts[:cc_number],
|
20
|
+
:cccode => opts[:cc_verification_code],
|
21
|
+
:expm => opts[:cc_expiration_month],
|
22
|
+
:expy => opts[:cc_expiration_year]
|
23
|
+
}
|
24
|
+
|
25
|
+
response = self.do_post(location,options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Configure A Keyword
|
29
|
+
# param [Hash] This requires only four keys, the keyword your targeting, its group, an autoreply and a url
|
30
|
+
# @return [Array] The return is an array of two elements, the mapped error code according to the extexting and the raw response
|
31
|
+
def self.configure
|
32
|
+
location = "/keyword/setup"
|
33
|
+
options = {
|
34
|
+
:keyword => opts[:keyword],
|
35
|
+
:group => opts[:group],
|
36
|
+
:autoreply => opts[:autoreply],
|
37
|
+
:url => opts[:url]
|
38
|
+
}
|
39
|
+
|
40
|
+
response = self.do_post(location,options)
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Lookup < Base
|
3
|
+
|
4
|
+
# Lookup the carrier for a telephone mobile number
|
5
|
+
# @param [String] phone_number is the number to be passed in to check the carrier
|
6
|
+
# @return [Array] the first element would be the carrier if the request was successful, the second will bethe raw data
|
7
|
+
def self.carrier(phone_number)
|
8
|
+
location = "/lookup"
|
9
|
+
options = {:phonenumber => phone_number}
|
10
|
+
|
11
|
+
response = self.do_post(location,options)
|
12
|
+
response_result = self.process(response)
|
13
|
+
|
14
|
+
return self.processed_reponse(response_result,response)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Sms < Base
|
3
|
+
|
4
|
+
# Send out a singular SMS
|
5
|
+
# @param [Hash] opts is a hash with keys/value pairs of subject, message and phone number. The phonenumber, subject and message are required by the API
|
6
|
+
# @return [Array] The return is an array of two elements, the mapped error code according to the extexting and the raw response
|
7
|
+
def self.single(opts={})
|
8
|
+
location = "/sending"
|
9
|
+
|
10
|
+
response = self.do_post(location,opts)
|
11
|
+
response_result = self.process(response)
|
12
|
+
|
13
|
+
return self.processed_reponse(response_result,response)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Send Out Multiple Messages
|
17
|
+
# @param [Array] messages is an array of hashes which are hashes that are identical to the hash passed into the single SMS method. This requires the same keys as the single method
|
18
|
+
# @return [Array] The return is an array of two elements, the mapped error code according to the extexting and the raw response
|
19
|
+
def self.multi(messages)
|
20
|
+
location = "/sending"
|
21
|
+
results = []
|
22
|
+
|
23
|
+
messages.each_with_index do |msg, i|
|
24
|
+
opts = msg
|
25
|
+
response = self.do_post(location,opts)
|
26
|
+
response_result = self.process(response)
|
27
|
+
results << {:message => i, :result => response_result}
|
28
|
+
end
|
29
|
+
|
30
|
+
return results
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def self.process(response)
|
36
|
+
api_result = case response
|
37
|
+
when "1"
|
38
|
+
"Message sent"
|
39
|
+
when "-1"
|
40
|
+
"Invalid user and/or password or API is not allowed for your account"
|
41
|
+
when "-2"
|
42
|
+
"Credit limit reached"
|
43
|
+
when "-5"
|
44
|
+
"Local opt out (the recipient/number is on your opt-out list.)"
|
45
|
+
when "-7"
|
46
|
+
"Invalid message or subject"
|
47
|
+
when "-104"
|
48
|
+
"Globally opted out phone number (the phone number has been opted out from all messages sent from our short code)"
|
49
|
+
when "-106"
|
50
|
+
"Incorrectly formatted phone number (number must be 10 digits)"
|
51
|
+
else
|
52
|
+
"Unknown error (please contact our support dept.)"
|
53
|
+
end
|
54
|
+
|
55
|
+
return api_result
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Eztexting
|
2
|
+
class Voice < Base
|
3
|
+
|
4
|
+
# Use the Voicebroadcast feature of the API
|
5
|
+
# @param [Hash] This has needs the following keys, phonenumbers to call, the recording src and the caller_id value
|
6
|
+
# @return [Array] The return is an array of two elements, the mapped error code according to the extexting and the raw response
|
7
|
+
def self.broadcast(opts={})
|
8
|
+
location = "/voicemessages/"
|
9
|
+
|
10
|
+
options = {
|
11
|
+
:phonenumbers => phone_numbers,
|
12
|
+
:soundsource => opts[:recording],
|
13
|
+
:callerid => opts[:called_id]
|
14
|
+
}
|
15
|
+
response = self.do_post(location,options)
|
16
|
+
response_result = self.process(response)
|
17
|
+
|
18
|
+
return self.processed_reponse(response_result,response)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.process(response)
|
25
|
+
api_result = case response
|
26
|
+
when "1"
|
27
|
+
"Campaign Sent"
|
28
|
+
when "-1"
|
29
|
+
"Invalid user and/or password or API is not allowed for your account"
|
30
|
+
when "-2"
|
31
|
+
"Credit limit reached"
|
32
|
+
when "-3"
|
33
|
+
"Invalid callerid"
|
34
|
+
when "-4"
|
35
|
+
"Invalid array of phone numbers"
|
36
|
+
when "-5"
|
37
|
+
"Invalid soundfile (make sure you provided the correct file name with the extension)"
|
38
|
+
when "-6"
|
39
|
+
"Invalid soundsource (make sure you provided the correct path to the file with the extension)"
|
40
|
+
when "-7"
|
41
|
+
"Invalid request (make sure you use the correct names of variables)"
|
42
|
+
else
|
43
|
+
"Unknown error (please contact our support dept.)"
|
44
|
+
end
|
45
|
+
|
46
|
+
return api_result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe "EzTexting" do
|
4
|
+
|
5
|
+
describe "sms" do
|
6
|
+
it "call do_http post with a URI of /sending" do
|
7
|
+
msg = {:phonenumber=>"5163177477", :message=>"Caprica", :subject=>"Cylons have destroyed the entire fleet"}
|
8
|
+
response = Eztexting::Sms.single(msg)
|
9
|
+
response.last
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "eztexting" do
|
14
|
+
it "should store the username and password as instance vars when the connect method is called" do
|
15
|
+
Eztexting.connect!("BillAdama","Pupser")
|
16
|
+
Eztexting.credentials[:user].should eql("BillAdama")
|
17
|
+
Eztexting.credentials[:pass].should eql("Pupser")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "does something" do
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/eztexting")
|
2
|
+
|
3
|
+
require 'spec'
|
4
|
+
|
5
|
+
Spec::Runner.configure do |config|
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
# Redefine the do_post method so that it does not actually make an outgoing post, we are not interested in testing
|
10
|
+
# httpary, just the parameters passed in and how the method is called from other parts of the application
|
11
|
+
module Eztexting
|
12
|
+
class Base
|
13
|
+
|
14
|
+
def self.do_post(uri,options)
|
15
|
+
return [uri,options]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eztexting
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Malin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-09-08 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httparty
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.6.0
|
24
|
+
version:
|
25
|
+
description: A Gem to make using eztexting simple and fun
|
26
|
+
email: dmalin@eztexting.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.textile
|
34
|
+
- lib/eztexting.rb
|
35
|
+
- lib/eztexting/availablity.rb
|
36
|
+
- lib/eztexting/base.rb
|
37
|
+
- lib/eztexting/credits.rb
|
38
|
+
- lib/eztexting/keywords.rb
|
39
|
+
- lib/eztexting/lookup.rb
|
40
|
+
- lib/eztexting/sms.rb
|
41
|
+
- lib/eztexting/voice.rb
|
42
|
+
files:
|
43
|
+
- LICENSE
|
44
|
+
- Manifest
|
45
|
+
- README.textile
|
46
|
+
- RELEASE_NOTES
|
47
|
+
- Rakefile
|
48
|
+
- VERSION
|
49
|
+
- examples/example_script.rb
|
50
|
+
- lib/eztexting.rb
|
51
|
+
- lib/eztexting/availablity.rb
|
52
|
+
- lib/eztexting/base.rb
|
53
|
+
- lib/eztexting/credits.rb
|
54
|
+
- lib/eztexting/keywords.rb
|
55
|
+
- lib/eztexting/lookup.rb
|
56
|
+
- lib/eztexting/sms.rb
|
57
|
+
- lib/eztexting/voice.rb
|
58
|
+
- spec/eztexting/eztexting_spec.rb
|
59
|
+
- spec/spec.opts
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
- eztexting.gemspec
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://github.com/EzTexting/eztexting
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --line-numbers
|
69
|
+
- --inline-source
|
70
|
+
- --title
|
71
|
+
- Eztexting
|
72
|
+
- --main
|
73
|
+
- README.textile
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
81
|
+
version:
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: "1.2"
|
87
|
+
version:
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
rubyforge_project: eztexting
|
91
|
+
rubygems_version: 1.3.5
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: A Gem to make using eztexting simple and fun
|
95
|
+
test_files: []
|
96
|
+
|