em-smsified 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,7 +12,7 @@ Installation
12
12
 
13
13
  gem install em-smsified
14
14
 
15
- Example
15
+ Client Example
16
16
  -------
17
17
 
18
18
  All of the API methods take an anonymous block which is the method called when the server returns. It yields the response so you can access the result of executing the API operation. The examples below illustrates this. If you don't care about the result of the operation, don't pass a block.
@@ -20,10 +20,10 @@ All of the API methods take an anonymous block which is the method called when t
20
20
  Send an SMS:
21
21
 
22
22
  require 'rubygems'
23
- require 'em-smsified'
24
23
  require 'eventmachine'
24
+ require 'em-smsified'
25
25
 
26
- oneapi = Smsified::OneAPI.new(:username => 'user', :password => 'bug.fungus24')
26
+ oneapi = EventMachine::Smsified::OneAPI.new(:username => 'user', :password => 'bug.fungus24')
27
27
 
28
28
  EM.run do
29
29
  oneapi.send_sms :address => '14155551212', :message => 'Hi there!', :sender_address => '13035551212'
@@ -33,10 +33,10 @@ Send an SMS:
33
33
  Find a subscription:
34
34
 
35
35
  require 'rubygems'
36
- require 'smsified'
37
36
  require 'eventmachine'
37
+ require 'em-smsified'
38
38
 
39
- subscriptions = Smsified::Subscriptions.new(:username => 'user', :password => 'bug.fungus24')
39
+ subscriptions = EventMachine::Smsified::Subscriptions.new(:username => 'user', :password => 'bug.fungus24')
40
40
 
41
41
  EM.run do
42
42
  subscriptions.inbound_subscriptions('17177455076')
@@ -45,20 +45,51 @@ Find a subscription:
45
45
  Parse the JSON for a callback Incoming Message:
46
46
 
47
47
  require 'rubygems'
48
- require 'smsified'
48
+ require 'em-smsified'
49
49
 
50
50
  # Also require your favorite web framework such as Rails or Sinatra
51
- incoming_message = Smsified::IncomingMessage.new json_body
51
+ incoming_message = EventMachine::Smsified::IncomingMessage.new json_body
52
52
  puts incoming_message.date_time # Wed May 11 18:05:54 UTC 2011
53
53
  puts incoming_message.destination_address # '16575550100'
54
54
  puts incoming_message.message # 'Inbound test'
55
55
  puts incoming_message.message_id # 'ef795d3dac56a62fef3ff1852b0c123a'
56
56
  puts incoming_message.sender_address # '14075550100'
57
57
 
58
+ Or use the built in server (see below).
59
+
60
+ Server Example
61
+ -------
62
+
63
+ A simple server that just outputs whatever is passed to it from SMSified:
64
+
65
+ EM.run do
66
+ EM.start_server '0.0.0.0', 8080, EventMachine::Smsified::Server do |s|
67
+ s.on_unknown do |content|
68
+ puts "Unknown received (#{content})"
69
+ end
70
+
71
+ s.on_delivery_notification do |msg|
72
+ puts "Delivery Notification " + Time.now.to_s
73
+ puts msg.inspect
74
+ end
75
+
76
+ s.on_incoming_message do |msg|
77
+ puts "Message received " + Time.now.to_s
78
+ puts "#{msg.sender_address} says '#{msg.message}' to #{msg.destination_address}"
79
+ puts msg.inspect
80
+ end
81
+ end
82
+ end
83
+
84
+ Also see examples/pong_server.rb for another server example.
85
+
86
+ If you want to test out the server on your local machine and you're machine isn't publicly available you can use http://localtunnel.com
87
+
58
88
  Documentation
59
89
  -------------
60
90
 
61
- May be found at http://kristiankristensen.github.com/em-smsified & http://smsified.com.
91
+ May be found at http://kristiankristensen.github.com/em-smsified & http://smsified.com or by cloning the repository and running
92
+ rake yard
62
93
 
63
94
  License
64
95
  -------
@@ -0,0 +1,47 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__), '..', 'lib')
2
+ require 'rubygems'
3
+ require 'yaml'
4
+ require 'em-smsified'
5
+ require 'eventmachine'
6
+ require 'evma_httpserver'
7
+
8
+ config = YAML.load(File.open('examples/config.yml'))
9
+
10
+ smsified = EventMachine::Smsified::OneAPI.new(:username => config['smsified']['username'],
11
+ :password => config['smsified']['password'])
12
+
13
+ EM.run do
14
+ Signal.trap("INT") { EM.stop }
15
+
16
+ Signal.trap("TRAP") { EM.stop }
17
+
18
+ puts "Hit CTRL-C to stop"
19
+ puts "=================="
20
+ puts "Server started at " + Time.now.to_s
21
+
22
+ puts "Starting incoming SMSified callback server"
23
+
24
+ EM.start_server '0.0.0.0', 8080, EventMachine::Smsified::Server do |s|
25
+ s.on_unknown do |content|
26
+ puts "Unknown received (#{content})"
27
+ end
28
+
29
+ s.on_delivery_notification do |msg|
30
+ puts "Delivery Notification " + Time.now.to_s
31
+ puts msg.inspect
32
+ end
33
+
34
+ s.on_incoming_message do |msg|
35
+ puts "Message received " + Time.now.to_s
36
+ puts "#{msg.sender_address} says '#{msg.message}' to #{msg.destination_address}"
37
+ puts msg.inspect
38
+ smsified.send_sms( :message => 'Pong',
39
+ :address => msg.sender_address,
40
+ :notify_url => config['postbin'],
41
+ :sender_address => msg.destination_address) do |result|
42
+ puts "Pong sent " + Time.now.to_s
43
+ puts result.data.inspect
44
+ end
45
+ end
46
+ end
47
+ end
data/lib/em-smsified.rb CHANGED
@@ -2,12 +2,15 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  %w(
3
3
  cgi
4
4
  time
5
+ json
5
6
  eventmachine
6
7
  em-http-request
8
+ evma_httpserver
7
9
  yajl
8
10
  em-smsified/helpers
9
11
  em-smsified/response
10
12
  em-smsified/base
13
+ em-smsified/server
11
14
  em-smsified/subscriptions
12
15
  em-smsified/reporting
13
16
  em-smsified/oneapi
@@ -1,5 +1,42 @@
1
1
  module EventMachine
2
2
  module Smsified
3
+
4
+ class MessageError < StandardError; end
5
+
6
+ class DeliveryInfoNotification
7
+ attr_reader :delivery_status, :code, :message_id, :sender_address, :address, :created_date_time, :sent_date_time, :parts, :direction, :message
8
+
9
+ ##
10
+ # Intantiate a new object to provide convenience methods on a Delivery Info Notification.
11
+ # Note: This class only pulls the first delivery info object from the notification. There can be more as per the spec.
12
+ # http://smsified.com/sms-api-documentation/sending#checking_status
13
+ #
14
+ # @param [required, String] valid JSON for an Delivery Info Notifcation to be parsed
15
+ # @return [Object] the parsed delivery info notification
16
+ # @raise [ArgumentError] if json is not valid JSON or an Delivery Info Notifcation type
17
+ # @example
18
+ # del = DeliveryInfoNotification.new(json)
19
+ # puts del.message # foobar
20
+ def initialize(json)
21
+ begin
22
+ @json = JSON.parse json
23
+ contents = @json['deliveryInfoNotification']['deliveryInfo']
24
+
25
+ @delivery_status = contents['deliveryStatus']
26
+ @code = contents['code']
27
+ @message_id = contents['messageId']
28
+ @sender_address = contents['senderAddress']
29
+ @address = contents['address']
30
+ @created_date_time = Time.parse contents['createdDateTime']
31
+ @sent_date_time = Time.parse contents['sentDateTime']
32
+ @parts = contents['parts']
33
+ @direction = contents['direction']
34
+ @message = contents['message']
35
+ rescue => error
36
+ raise EventMachine::Smsified::MessageError, "Not valid JSON or DeliveryInfoNotification"
37
+ end
38
+ end
39
+ end
3
40
  class IncomingMessage
4
41
  attr_reader :date_time, :destination_address, :message, :message_id, :sender_address, :json
5
42
 
@@ -25,11 +62,9 @@ module EventMachine
25
62
  @message_id = contents['messageId']
26
63
  @sender_address = contents['senderAddress']
27
64
  rescue => error
28
- raise MessageError, "Not valid JSON or IncomingMessage"
65
+ raise EventMachine::Smsified::MessageError, "Not valid JSON or IncomingMessage"
29
66
  end
30
67
  end
31
-
32
- class MessageError < StandardError; end
33
68
  end
34
69
  end
35
70
  end
@@ -0,0 +1,126 @@
1
+ module EventMachine
2
+ module Smsified
3
+ ##
4
+ # Does the actual handling of the incoming notifications from SMSified. Factored out to ease in testing.
5
+ #
6
+ module ServerHandler
7
+ ##
8
+ # Sets the block to call when an incoming message arrives
9
+ #
10
+ def on_incoming_message(&blk)
11
+ @on_incoming_message = blk
12
+ end
13
+
14
+ ##
15
+ # Sets the block to call when a delivery notification arrives
16
+ #
17
+ def on_delivery_notification(&blk)
18
+ @on_delivery_notification = blk
19
+ end
20
+
21
+ ##
22
+ # Sets the block to call when an unknown message arrives
23
+ #
24
+ def on_unknown(&blk)
25
+ @on_unknown = blk
26
+ end
27
+
28
+ def trigger_on_incoming_message(msg)
29
+ @on_incoming_message.call(msg) if @on_incoming_message
30
+ end
31
+
32
+ def trigger_on_delivery_notification(msg)
33
+ @on_delivery_notification.call(msg) if @on_delivery_notification
34
+ end
35
+
36
+ def trigger_on_unknown(request)
37
+ @on_unknown.call(request) if @on_unknown
38
+ end
39
+
40
+
41
+ ##
42
+ # Inspects the method and contents of the incoming request and handles it.
43
+ # @param [required, String] the HTTP method of the request
44
+ # @param [optional, String] the POST'ed content of the request
45
+ # @return [bool] true if request was handled, false if not
46
+ def handle(method, content)
47
+ if is_post? method
48
+ return handle_incoming_message(content) || handle_delivery_notification(content) || handle_unknown(content)
49
+ end
50
+ return false
51
+ end
52
+
53
+ private
54
+
55
+ def is_post?(method)
56
+ return method == "POST"
57
+ end
58
+
59
+ def handle_unknown(content)
60
+ trigger_on_unknown(content)
61
+ return true
62
+ end
63
+
64
+ def handle_delivery_notification(content)
65
+ begin
66
+ msg = EventMachine::Smsified::DeliveryInfoNotification.new(content)
67
+ trigger_on_delivery_notification(msg)
68
+ return true
69
+ rescue
70
+ end
71
+ return false
72
+ end
73
+
74
+ def handle_incoming_message(content)
75
+ begin
76
+ msg = EventMachine::Smsified::IncomingMessage.new(content)
77
+ trigger_on_incoming_message(msg)
78
+ return true
79
+ rescue
80
+ end
81
+ return false
82
+ end
83
+
84
+ end
85
+
86
+ ##
87
+ # Allows you to set up a server for incoming SMSified callbacks.
88
+ # @example
89
+ # see examples/pong_server.rb
90
+ class Server < EM::Connection
91
+ include EM::HttpServer, ServerHandler
92
+
93
+ def post_init
94
+ super
95
+ no_environment_strings
96
+ end
97
+
98
+ ##
99
+ # Does processing of incoming HTTP requests.
100
+ #
101
+ def process_http_request
102
+ # the http request details are available via the following instance variables:
103
+ # @http_protocol
104
+ # @http_request_method
105
+ # @http_cookie
106
+ # @http_if_none_match
107
+ # @http_content_type
108
+ # @http_path_info
109
+ # @http_request_uri
110
+ # @http_query_string
111
+ # @http_post_content
112
+ # @http_headers
113
+ handle(@http_request_method, @http_post_content)
114
+
115
+ send_ok()
116
+ end
117
+
118
+ private
119
+ def send_ok
120
+ response = EM::DelegatedHttpResponse.new(self)
121
+ response.status = 200
122
+ response.send_response
123
+ end
124
+ end
125
+ end
126
+ end
@@ -59,8 +59,8 @@ module EventMachine
59
59
  # @return [Object] A Response Object with http and data instance methods
60
60
  # @example
61
61
  # subscriptions.delete_outbound_subscription('89edd71c1c7f3d349f9a3a4d5d2d410c')
62
- def delete_outbound_subscription(sender_address, &blk)
63
- delete("/smsmessaging/outbound/subscriptions/#{sender_address}", SMSIFIED_HTTP_HEADERS, &blk)
62
+ def delete_outbound_subscription(subscription_id, &blk)
63
+ delete("/smsmessaging/outbound/subscriptions/#{subscription_id}", SMSIFIED_HTTP_HEADERS, &blk)
64
64
  end
65
65
 
66
66
  ##
@@ -549,11 +549,47 @@ describe "Smsified" do
549
549
  end
550
550
 
551
551
  it "Should raise an error if JSON not passed" do
552
- lambda { EventMachine::Smsified::IncomingMessage.new 'foobar' }.should raise_error(EventMachine::Smsified::IncomingMessage::MessageError)
552
+ lambda { EventMachine::Smsified::IncomingMessage.new 'foobar' }.should raise_error(EventMachine::Smsified::MessageError)
553
553
  end
554
554
 
555
555
  it "Should raise an error if a different type than an IncomingMessage is passed" do
556
- lambda { EventMachine::Smsified::IncomingMessage.new "{ 'foo': 'bar'}" }.should raise_error(EventMachine::Smsified::IncomingMessage::MessageError)
556
+ lambda { EventMachine::Smsified::IncomingMessage.new "{ 'foo': 'bar'}" }.should raise_error(EventMachine::Smsified::MessageError)
557
+ end
558
+ end
559
+ describe 'DeliveryInfoNotifaction' do
560
+ it 'Should parse an incoming delivery info notification from SMSified' do
561
+ json = '{ "deliveryInfoNotification": {
562
+ "deliveryInfo": {
563
+ "deliveryStatus":"DeliveredToNetwork",
564
+ "code":"0",
565
+ "messageId":"2e0b8d79f1084190d50b1c8c1188ad0d",
566
+ "senderAddress":"tel:+12223334455",
567
+ "address":"tel:+11112223344",
568
+ "createdDateTime":"2011-11-22T18:19:51.584Z",
569
+ "sentDateTime":"2011-11-22T18:19:58.848Z",
570
+ "parts":"1",
571
+ "direction":"outbound",
572
+ "message":"Pong"
573
+ }
574
+ }
575
+ }'
576
+
577
+ del = EventMachine::Smsified::DeliveryInfoNotification.new json
578
+ del.message_id.should eql '2e0b8d79f1084190d50b1c8c1188ad0d'
579
+ del.message.should eql 'Pong'
580
+ del.direction.should eql 'outbound'
581
+ del.delivery_status.should eql 'DeliveredToNetwork'
582
+ del.sender_address.should eql 'tel:+12223334455'
583
+ del.address.should eql 'tel:+11112223344'
584
+ del.created_date_time.should eql Time.parse '2011-11-22T18:19:51.584Z'
585
+ end
586
+
587
+ it "Should raise an error if JSON not passed" do
588
+ lambda { EventMachine::Smsified::DeliveryInfoNotification.new 'foobar' }.should raise_error(EventMachine::Smsified::MessageError)
589
+ end
590
+
591
+ it "Should raise an error if a different type than a DeliveryInfoNotification is passed" do
592
+ lambda { EventMachine::Smsified::DeliveryInfoNotification.new "{ 'foo': 'bar'}" }.should raise_error(EventMachine::Smsified::MessageError)
593
+ end
557
594
  end
558
595
  end
559
- end
@@ -0,0 +1,109 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ class TestServerHandler
4
+ include EventMachine::Smsified::ServerHandler
5
+ end
6
+
7
+ describe "Smsified Server" do
8
+ before (:each) do
9
+ @sut = TestServerHandler.new
10
+ end
11
+
12
+ it "should set the on_incoming callback block" do
13
+ @sut.on_incoming_message do |msg|
14
+ end
15
+
16
+ end
17
+
18
+ it "should set the on_delivery_notification block" do
19
+ @sut.on_delivery_notification do |msg|
20
+ end
21
+ end
22
+
23
+ it "should trigger the on_incoming_message callback block" do
24
+ called = false
25
+ @sut.on_incoming_message do |msg|
26
+ called = true
27
+ end
28
+ @sut.trigger_on_incoming_message(nil)
29
+ called.should be true
30
+ end
31
+
32
+ describe "handle" do
33
+ it "should never handle 'GET' requests" do
34
+ @sut.handle("GET", nil).should be false
35
+ end
36
+
37
+ it "should not handle invalid string" do
38
+ @sut.handle("GET", "foobar").should be false
39
+ end
40
+
41
+ it "should handle 'POST' request with invalid string" do
42
+ @sut.handle("POST", "foobar").should be true
43
+ end
44
+
45
+ describe "Incoming Message" do
46
+ before (:all) do
47
+ @json_msg = '{
48
+ "inboundSMSMessageNotification": {
49
+ "inboundSMSMessage": {
50
+ "dateTime": "2011-05-11T18:05:54.546Z",
51
+ "destinationAddress": "16575550100",
52
+ "message": "Inbound test",
53
+ "messageId": "ef795d3dac56a62fef3ff1852b0c123a",
54
+ "senderAddress": "14075550100"
55
+ }
56
+ }
57
+ }'
58
+ end
59
+
60
+ it "should handle POST with content" do
61
+ @sut.handle("POST", @json_msg).should be true
62
+ end
63
+
64
+ it "should call a set block with the parsed object" do
65
+ called = false
66
+ @sut.on_incoming_message do |msg|
67
+ msg.instance_of?(EventMachine::Smsified::IncomingMessage).should be true
68
+ called = true
69
+ end
70
+ @sut.handle("POST", @json_msg)
71
+ called.should be true
72
+ end
73
+ end
74
+ describe "Delivery Notification" do
75
+ before (:all) do
76
+ @json_msg = '{ "deliveryInfoNotification": {
77
+ "deliveryInfo": {
78
+ "deliveryStatus":"DeliveredToNetwork",
79
+ "code":"0",
80
+ "messageId":"2e0b8d79f1084190d50b1c8c1188ad0d",
81
+ "senderAddress":"tel:+12223334455",
82
+ "address":"tel:+11112223344",
83
+ "createdDateTime":"2011-11-22T18:19:51.584Z",
84
+ "sentDateTime":"2011-11-22T18:19:58.848Z",
85
+ "parts":"1",
86
+ "direction":"outbound",
87
+ "message":"Pong"
88
+ }
89
+ }
90
+ }'
91
+ end
92
+
93
+ it "should handle POST with content" do
94
+ @sut.handle("POST", @json_msg).should be true
95
+ end
96
+
97
+ it "should call a set block with the parsed object" do
98
+ called = false
99
+ @sut.on_delivery_notification do |msg|
100
+ msg.instance_of?(EventMachine::Smsified::DeliveryInfoNotification).should be true
101
+ called = true
102
+ end
103
+ @sut.handle("POST", @json_msg)
104
+ called.should be true
105
+ end
106
+ end
107
+
108
+ end
109
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-smsified
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-11-17 00:00:00.000000000Z
14
+ date: 2011-11-23 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec
18
- requirement: &81912970 !ruby/object:Gem::Requirement
18
+ requirement: &74738640 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 2.3.0
24
24
  type: :development
25
25
  prerelease: false
26
- version_requirements: *81912970
26
+ version_requirements: *74738640
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: yard
29
- requirement: &81912730 !ruby/object:Gem::Requirement
29
+ requirement: &74738360 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.6.0
35
35
  type: :development
36
36
  prerelease: false
37
- version_requirements: *81912730
37
+ version_requirements: *74738360
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: bundler
40
- requirement: &81912410 !ruby/object:Gem::Requirement
40
+ requirement: &74738080 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: 1.0.0
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *81912410
48
+ version_requirements: *74738080
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: jeweler
51
- requirement: &81912120 !ruby/object:Gem::Requirement
51
+ requirement: &74737820 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 1.5.2
57
57
  type: :development
58
58
  prerelease: false
59
- version_requirements: *81912120
59
+ version_requirements: *74737820
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rcov
62
- requirement: &81911850 !ruby/object:Gem::Requirement
62
+ requirement: &74737510 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: '0'
68
68
  type: :development
69
69
  prerelease: false
70
- version_requirements: *81911850
70
+ version_requirements: *74737510
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: awesome_print
73
- requirement: &81911530 !ruby/object:Gem::Requirement
73
+ requirement: &74737230 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
- version_requirements: *81911530
81
+ version_requirements: *74737230
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: json
84
- requirement: &81911290 !ruby/object:Gem::Requirement
84
+ requirement: &74736930 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
- version_requirements: *81911290
92
+ version_requirements: *74736930
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: webmock
95
- requirement: &81911000 !ruby/object:Gem::Requirement
95
+ requirement: &74736660 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :development
102
102
  prerelease: false
103
- version_requirements: *81911000
103
+ version_requirements: *74736660
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: bluecloth
106
- requirement: &81910720 !ruby/object:Gem::Requirement
106
+ requirement: &74736380 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: '0'
112
112
  type: :development
113
113
  prerelease: false
114
- version_requirements: *81910720
114
+ version_requirements: *74736380
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: eventmachine
117
- requirement: &81910440 !ruby/object:Gem::Requirement
117
+ requirement: &74736090 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
@@ -122,7 +122,18 @@ dependencies:
122
122
  version: '0'
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *81910440
125
+ version_requirements: *74736090
126
+ - !ruby/object:Gem::Dependency
127
+ name: eventmachine_httpserver
128
+ requirement: &74735840 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: *74735840
126
137
  description: Gem for consuming the SMSified OneAPI w EventMachine
127
138
  email:
128
139
  - jsgoecke@voxeo.com
@@ -142,11 +153,13 @@ files:
142
153
  - lib/em-smsified/oneapi.rb
143
154
  - lib/em-smsified/reporting.rb
144
155
  - lib/em-smsified/response.rb
156
+ - lib/em-smsified/server.rb
145
157
  - lib/em-smsified/subscriptions.rb
146
158
  - LICENSE.txt
147
- - examples/local_test.rb
159
+ - examples/pong_server.rb
148
160
  - examples/sending_and_subscribing.rb
149
161
  - spec/em-smsified_spec.rb
162
+ - spec/server_spec.rb
150
163
  - spec/spec_helper.rb
151
164
  homepage: http://github.com/kristiankristensen/em-smsified
152
165
  licenses:
@@ -163,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
176
  version: '0'
164
177
  segments:
165
178
  - 0
166
- hash: -874026291
179
+ hash: 57821651
167
180
  required_rubygems_version: !ruby/object:Gem::Requirement
168
181
  none: false
169
182
  requirements:
@@ -177,7 +190,8 @@ signing_key:
177
190
  specification_version: 3
178
191
  summary: Gem for consuming the SMSified OneAPI w EventMachine
179
192
  test_files:
180
- - examples/local_test.rb
193
+ - examples/pong_server.rb
181
194
  - examples/sending_and_subscribing.rb
182
195
  - spec/em-smsified_spec.rb
196
+ - spec/server_spec.rb
183
197
  - spec/spec_helper.rb
@@ -1,40 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__), '..', 'lib')
2
- require 'rubygems'
3
- require 'smsified'
4
- require 'yaml'
5
- require 'eventmachine'
6
-
7
- config = YAML.load(File.open('examples/config.yml'))
8
-
9
-
10
- EM.run do
11
- Signal.trap("INT") { EM.stop}
12
- Signal.trap("TRAP") { EM.stop}
13
-
14
- puts "Hit CTRL-C to stop"
15
- puts "=================="
16
- puts "Server started at " + Time.now.to_s
17
-
18
- smsified = Smsified::OneAPI.new( :username => config['smsified']['username'],
19
- :password => config['smsified']['password'],
20
- :sender_address => '12892050134'
21
- )
22
-
23
-
24
- puts "Send SMS started " + Time.now.to_s
25
-
26
- # smsified.send_sms(:message => 'Hello there!',
27
- # :address => '19179712649',
28
- #:notify_url => config['postbin'],
29
- # :sender_address => '12892050134') do |http|
30
- # puts "Response returned " + Time.now.to_s
31
- # puts http.data
32
- # puts http.http
33
- # end
34
-
35
- puts "Reporting Request started " + Time.now.to_s
36
- smsified.delivery_status(:request_id => 'e7e12f5d6870447a8599bb420e5e9a0d') do |resp|
37
- puts "Response returned " + Time.now.to_s
38
- puts resp.data
39
- end
40
- end