pswincom 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -0,0 +1,20 @@
1
+ Copyright (C) 2011 by PSWinCom AS
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
data/README.md CHANGED
@@ -0,0 +1,40 @@
1
+ PSWinCom Ruby Gem
2
+ =================
3
+
4
+ A Ruby interface to the [PSWinCom SMS Gateway API](http://pswin.com/english/products/gateway).
5
+
6
+ Installation
7
+ ------------
8
+ The PSWinCom Ruby API comes as a gem. Install it with gem install. Other than the ruby default libraries the only dependency is the builder gem.
9
+
10
+ gem install pswincom
11
+
12
+ Basic Usage
13
+ -----------
14
+ To use this gem, you will need sign up for a Gateway account with PSWinCom. Demo account are available.
15
+
16
+ This piece of code demonstrates how to send a simple SMS message:
17
+
18
+ require 'rubygems'
19
+ require 'pswincom'
20
+
21
+ api = PSWinCom::API.new 'username', 'password'
22
+ api.send_sms '4712345678', 'This is a test SMS'
23
+
24
+ Advanced Usage
25
+ --------------
26
+ Receiver and message text are the two mandatory properties when sending a message. You may specify additional properties by using a hash as the last argument to `send_sms`.
27
+
28
+ For instance this is how you would specify a sender:
29
+
30
+ api.send_sms '4712345678', 'This is a test', :sender => 'Ruby'
31
+
32
+ Properties currently supported are:
33
+
34
+ * :sender
35
+ * :TTL - time to live in seconds
36
+ * :deliverytime - a Time object specifying when to send the message
37
+
38
+ License
39
+ -------
40
+ This code is free to use under the terms of the MIT license.
data/lib/pswincom/api.rb CHANGED
@@ -9,7 +9,7 @@ module PSWinCom
9
9
  class << self
10
10
  attr_accessor :test_mode
11
11
  attr_accessor :debug_mode
12
- attr_accessor :api_host, :api_port
12
+ attr_accessor :api_host
13
13
  end
14
14
 
15
15
  self.test_mode = false;
@@ -1,25 +1,21 @@
1
1
  require 'uri'
2
- require 'socket'
2
+ require 'net/http'
3
3
 
4
4
  module PSWinCom
5
5
  class HttpSender
6
- API_HOST = 'gw2-fro.pswin.com'
7
- API_PORT = 1111
6
+ API_HOST = 'http://gw2-fro.pswin.com:81/'
8
7
 
9
8
  def initialize
10
9
  @host = PSWinCom::API.api_host.nil? ? API_HOST : PSWinCom::API.api_host
11
- @port = PSWinCom::API.api_port.nil? ? API_PORT : PSWinCom::API.api_port
12
-
13
10
  PSWinCom.debug "Host", @host
14
- PSWinCom.debug "Port", @port
15
11
  end
16
12
 
17
13
  def send request
18
- session = TCPSocket.new(@host, @port)
19
- session.write request.xml
20
- result = session.read
21
- session.close
22
- result
14
+ url = URI.parse @host
15
+ post = Net::HTTP::Post.new(url.path)
16
+ post.body = request.xml
17
+ post.content_type = 'text/xml'
18
+ Net::HTTP.start(url.host, url.port) {|http| http.request(post)}
23
19
  end
24
20
  end
25
21
  end
metadata CHANGED
@@ -1,26 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pswincom
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
- authors: []
13
-
12
+ authors:
13
+ - PSWinCom AS
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
18
  date: 2011-02-07 00:00:00 +01:00
19
19
  default_executable:
20
- dependencies: []
21
-
22
- description:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: builder
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 0
34
+ version: 3.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: An easy to use API for the PSWinCom SMS Gateway, allowing you to send SMS messages.
23
38
  email:
39
+ - support@pswin.com
24
40
  executables: []
25
41
 
26
42
  extensions: []
@@ -35,7 +51,7 @@ files:
35
51
  - LICENSE
36
52
  - README.md
37
53
  has_rdoc: true
38
- homepage:
54
+ homepage: http://github.com/tormaroe/pswincomgem
39
55
  licenses: []
40
56
 
41
57
  post_install_message:
@@ -67,6 +83,6 @@ rubyforge_project:
67
83
  rubygems_version: 1.5.0
68
84
  signing_key:
69
85
  specification_version: 3
70
- summary: An easy to use API for the PSWinCom SMS Gateway
86
+ summary: API for the PSWinCom SMS Gateway.
71
87
  test_files: []
72
88