smspromote 0.0.6 → 0.0.7

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.
@@ -49,7 +49,7 @@ module SmsPromote
49
49
 
50
50
  response = session do |http|
51
51
  request = Net::HTTP::Post.new("/")
52
- request.form_data = options
52
+ request.body = Gateway.encode_params(options)
53
53
  http.request(request)
54
54
  end
55
55
 
@@ -101,6 +101,15 @@ module SmsPromote
101
101
  URI.parse(secure? ? SECURE : INSECURE)
102
102
  end
103
103
 
104
+ # returns the encoded params str based on the passed hash
105
+ def self.encode_params(params = {})
106
+ data = []
107
+ params.each do |key, value|
108
+ data << "#{key}=#{URI.escape(value.to_s)}"
109
+ end
110
+ data.join("&")
111
+ end
112
+
104
113
  private
105
114
 
106
115
  def session # :yield: http
@@ -32,6 +32,17 @@ module SmsPromote
32
32
  @code == 100
33
33
  end
34
34
 
35
+ # encode the the content of the body according to the interface spec
36
+ def encode!(from = "UTF-8", to = "ISO-8859-1")
37
+ # ruby 1.9 and higher
38
+ if "".respond_to?(:encode) && "".respond_to?(:force_encoding)
39
+ @body = @body.force_encoding(from).encode(to)
40
+ else # ruby 1.8
41
+ require "iconv"
42
+ @body = Iconv.iconv(to, from, @body).first
43
+ end
44
+ end
45
+
35
46
  # sets the message information after the message has been send
36
47
  # code:: [Fixnum] the message code (e.g. 100)
37
48
  # message_id:: [String] the message id string
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smspromote
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
4
+ hash: 17
5
+ prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vincent Landgraf
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: "0"
47
47
  type: :development
48
48
  version_requirements: *id002
49
- description: ""
49
+ description: Library that provides access to the smspromote.de sms gateway service.
50
50
  email:
51
51
  - vilandgr@googlemail.com
52
52
  executables: []
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements: []
95
95
 
96
96
  rubyforge_project:
97
- rubygems_version: 1.4.1
97
+ rubygems_version: 1.3.7
98
98
  signing_key:
99
99
  specification_version: 3
100
100
  summary: this gem helps sending sms using the smspromote.de sms gateway