sinch_sms 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sinch_sms.rb +29 -0
  3. metadata +44 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8769457e5deced63700bd4c87bdbb09f7a083fa0
4
+ data.tar.gz: 0c6a5611dee42a1f857af1dce9778f148ef1822c
5
+ SHA512:
6
+ metadata.gz: fd0c15cb7063861f53aa68a16404d3a2ae573b58200553096cf489a822426a18fad2ccccaad30439409013707441dd78db24216fa3219b7a38a612be82e4f3ac
7
+ data.tar.gz: 8ad5fee67e956b5ab304a2aac0095f816040c76a75eb5ce8f15319fed6739ecab7ad9784571454dfee322af4f52ee6c46141c51208a81ec02ff237daee77a725
@@ -0,0 +1,29 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+ require 'json'
4
+
5
+ class SinchSms
6
+ def self.send(key, secret, message, to, from=nil)
7
+ http = Net::HTTP.new("messagingApi.sinch.com",443)
8
+ req = Net::HTTP::Post.new("/v1/sms/" + to)
9
+ http.use_ssl = true
10
+ req.basic_auth "application:" + key, secret
11
+ req["Content-Type"] = "text/json"
12
+
13
+ if (from)
14
+ req.body = {"Message" => message, "From" => from}.to_json
15
+ else
16
+ req.body = {"Message" => message}.to_json
17
+ end
18
+
19
+ response = http.request(req)
20
+ if response.body["MessageId"]
21
+ puts "Message successfully sent!\n"
22
+ return true
23
+ else
24
+ puts "Error sending message!\n" + response.body
25
+ return false
26
+ end
27
+
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sinch_sms
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.1'
5
+ platform: ruby
6
+ authors:
7
+ - Jordan Hamel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Use Sinch to send SMS! Visit sinch.com/pricing for rates by country.
14
+ email: jordan@sinch.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/sinch_sms.rb
20
+ homepage: http://rubygems.org/gems/sinch_sms
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.4.2
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Use Sinch to send SMS!
44
+ test_files: []