telstra-sms 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/README.md +8 -1
- data/Rakefile +5 -0
- data/lib/telstra/sms.rb +31 -7
- data/lib/telstra/sms/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/telstra/sms_spec.rb +13 -0
- data/telstra-sms.gemspec +1 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 019256ff8183ac685b46ce271a047f8aaab33fb3
|
4
|
+
data.tar.gz: f7727e4569af9915d7e145e971f2479ecea8d862
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 540bbd6770905786a089cad43dce0c0bb4dd83d67ba54bebeed62760d164de69d3702c7547578fea9510224a3a1df5a5c6f5bb366c87703397c6c44bb55255e8
|
7
|
+
data.tar.gz: cf4e1cf91158d08c76abce8e2e42050621bae92250a71e6cec8c132e7ffac73c7e6b210e69a2335d318760306acaa86bed9c3fb0bba14d93ca450b900bebcb4d
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
*This gem is currently in development and only has SMS send / status functionality right now*
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/soccerbrain/telstra-sms/badges/gpa.svg)](https://codeclimate.com/github/soccerbrain/telstra-sms)
|
4
|
+
[![Build Status](https://travis-ci.org/soccerbrain/telstra-sms.svg)](https://travis-ci.org/soccerbrain/telstra-sms)
|
5
|
+
|
1
6
|
# Telstra::Sms
|
2
7
|
|
3
8
|
Ruby gem for the Telstra SMS API at https://dev.telstra.com
|
@@ -22,7 +27,9 @@ Or install it yourself as:
|
|
22
27
|
|
23
28
|
```ruby
|
24
29
|
t = Telstra::SMS.new(consumer_key, consumer_secret)
|
25
|
-
t.
|
30
|
+
t.send_sms("SMS Body", "04XX XXX XXXX")
|
31
|
+
t.get_message_status(message_id)
|
32
|
+
t.get_message_response(message_id)
|
26
33
|
```
|
27
34
|
|
28
35
|
## Contributing
|
data/Rakefile
CHANGED
data/lib/telstra/sms.rb
CHANGED
@@ -13,24 +13,48 @@ module Telstra
|
|
13
13
|
@consumer_secret = consumer_secret
|
14
14
|
end
|
15
15
|
|
16
|
-
#
|
17
|
-
#params = JSON.generate(params)
|
18
|
-
#curl "https://api.telstra.com/v1/oauth/token?client_id=#{@consumer_key}&client_secret=#{@consumer_secret}&grant_type=client_credentials&scope=SMS"
|
19
|
-
#end
|
20
|
-
|
16
|
+
# OAuth 2.0 Token. This will expire every hour.
|
21
17
|
def generate_token
|
22
18
|
response = HTTParty.get("https://api.telstra.com/v1/oauth/token?client_id=#{@consumer_key}&client_secret=#{@consumer_secret}&grant_type=client_credentials&scope=SMS")
|
23
19
|
@token = JSON.parse(response.body)['access_token']
|
24
20
|
end
|
25
21
|
|
26
|
-
|
22
|
+
# Receipient number should be in the format of 04xxxxxxxx where x is a digit.
|
23
|
+
# Authorization header value should be in the format of "Bearer xxx" where xxx
|
24
|
+
# is the access token returned from a token request.
|
25
|
+
def send_sms(sms_body, sms_to)
|
27
26
|
generate_token
|
28
27
|
options = { body: {
|
29
28
|
body: sms_body,
|
30
29
|
to: sms_to
|
31
30
|
}.to_json,
|
32
31
|
headers: { "Content-Type" => "application/json", "Authorization" => "Bearer #{@token}" }}
|
33
|
-
HTTParty.post("https://api.telstra.com/v1/sms/messages", options)
|
32
|
+
response = HTTParty.post("https://api.telstra.com/v1/sms/messages", options)
|
33
|
+
return response.body
|
34
|
+
end
|
35
|
+
|
36
|
+
# Get the status of a previously sent SMS message
|
37
|
+
# May return:
|
38
|
+
#
|
39
|
+
# PEND -> The message is pending and has not yet been sent
|
40
|
+
# SENT -> Message has been send, but not delivered
|
41
|
+
# DELIVRD -> Message has been delivered
|
42
|
+
# READ -> The message has been read by the intended recipeitn
|
43
|
+
#
|
44
|
+
# Note: Some responses are dependent on the phone network of the user.
|
45
|
+
# Obviously, more info can be grabbed from those on the Telstra network.
|
46
|
+
def get_message_status(message_id)
|
47
|
+
generate_token
|
48
|
+
options = { headers: { "Authorization" => "Bearer #{@token}" } }
|
49
|
+
repsonse = HTTParty.post("https://api.telstra.com/v1/sms/messages/#{message_id}")
|
50
|
+
return response.body
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_message_response(message_id)
|
54
|
+
generate_token
|
55
|
+
options = { headers: { "Authorization" => "Bearer #{@token}" } }
|
56
|
+
repsonse = HTTParty.post("https://api.telstra.com/v1/sms/messages/#{message_id}/response")
|
57
|
+
return response.body
|
34
58
|
end
|
35
59
|
|
36
60
|
end
|
data/lib/telstra/sms/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'telstra/sms'
|
data/telstra-sms.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: telstra-sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Millar
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- paul@digitaldawn.com.au
|
@@ -60,12 +74,15 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
77
|
+
- ".rspec"
|
63
78
|
- Gemfile
|
64
79
|
- LICENSE.txt
|
65
80
|
- README.md
|
66
81
|
- Rakefile
|
67
82
|
- lib/telstra/sms.rb
|
68
83
|
- lib/telstra/sms/version.rb
|
84
|
+
- spec/spec_helper.rb
|
85
|
+
- spec/telstra/sms_spec.rb
|
69
86
|
- telstra-sms.gemspec
|
70
87
|
homepage: https://github.com/soccerbrain/telstra-sms
|
71
88
|
licenses:
|
@@ -91,4 +108,6 @@ rubygems_version: 2.2.2
|
|
91
108
|
signing_key:
|
92
109
|
specification_version: 4
|
93
110
|
summary: Send SMS through the Telstra SMS API
|
94
|
-
test_files:
|
111
|
+
test_files:
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
- spec/telstra/sms_spec.rb
|