voodoo_sms 0.0.2 → 1.1.0
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.
- checksums.yaml +4 -4
- data/lib/voodoo_sms.rb +16 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 115134764b84dcf7c9c79d25f92a51dead47b909
|
4
|
+
data.tar.gz: ee4247bd703c8f2f50f12289638ab6e4f555b382
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12eac62e925d6966dbad5bc987f51cdce8046ed6af23143e1cd0a773c5a781711577f9a0dc831a563c9c298c277f4674edddbc7fd304d73311add386bd769be8
|
7
|
+
data.tar.gz: 0a8fd82085f6ff29065068eee52e8b5c94d7f5d7c11a367abc11266e11e86976daca0ff107243f985c2f20500462b5534c060da64c45b8e4ecbd9b46142a392c
|
data/lib/voodoo_sms.rb
CHANGED
@@ -24,18 +24,20 @@ class VoodooSMS
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def get_credit
|
27
|
-
make_request('getCredit')
|
27
|
+
response = make_request('getCredit')
|
28
|
+
fetch_from_response(response, 'credit')
|
28
29
|
end
|
29
30
|
|
30
31
|
def send_sms(originator, destination, message)
|
31
32
|
merge_params(orig: originator, dest: destination, msg: message, validity: 1)
|
32
|
-
make_request('sendSMS')
|
33
|
+
response = make_request('sendSMS').parsed_response
|
34
|
+
fetch_from_response(response, 'reference_id')
|
33
35
|
end
|
34
36
|
|
35
37
|
def get_sms(from, to, keyword = '')
|
36
38
|
merge_params(from: format_date(from), to: format_date(to), keyword: keyword)
|
37
|
-
response = make_request('getSMS')['messages']
|
38
|
-
if response.is_a?(Array)
|
39
|
+
response = make_request('getSMS')['messages'] # unfortunately we can't use fetch_from_response here
|
40
|
+
if response.is_a?(Array) # response doesn't have messages key if no new messages
|
39
41
|
response.map { |r| OpenStruct.new(from: r['Originator'],
|
40
42
|
timestamp: DateTime.parse(r['TimeStamp']),
|
41
43
|
message: r['Message']) }
|
@@ -44,6 +46,12 @@ class VoodooSMS
|
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
49
|
+
def get_delivery_status(reference_id)
|
50
|
+
merge_params(reference_id: reference_id)
|
51
|
+
response = make_request('getDlrStatus')
|
52
|
+
fetch_from_response(response, 'delivery_status')
|
53
|
+
end
|
54
|
+
|
47
55
|
private
|
48
56
|
def merge_params(opts)
|
49
57
|
@params[:query].merge!(opts)
|
@@ -103,4 +111,8 @@ class VoodooSMS
|
|
103
111
|
def format_date(date)
|
104
112
|
date.respond_to?(:strftime) ? date.strftime("%F %T") : date
|
105
113
|
end
|
114
|
+
|
115
|
+
def fetch_from_response(response, key)
|
116
|
+
response.fetch(key) { raise Error::Unexpected.new("No #{key} found from Voodoo response!") }
|
117
|
+
end
|
106
118
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voodoo_sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Sabin
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.4.5
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: VoodooSMS API
|