yunpian_sms 0.1.0 → 0.1.1
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/README.md +8 -4
- data/lib/yunpian_sms/result.rb +10 -0
- data/lib/yunpian_sms/template.rb +3 -2
- data/lib/yunpian_sms/version.rb +1 -1
- data/spec/yunpian_sms_spec.rb +16 -8
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a34e72affc14403a0c3618e90e754f4ce4e7c6b4
|
4
|
+
data.tar.gz: 7434efcaef5f9fc729d8f5f02f23dcf7166bde5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34bfeaa8a83180d56f68298ae24145b65b509bc1ebb6a8abdff7bf7e8de4b570a4717bfae0fae4902fa655ca225620b88c963685caa9db8e2ebc4f585af5a011
|
7
|
+
data.tar.gz: b483585943c34c5b3f8b0fc12b05d1c2e6ebe107f4caf99c6565738be94fcc1a4832829166aa560b25480ce3a91bdb5d990e7a3e81c7b0c467719d939392296d
|
data/README.md
CHANGED
@@ -33,11 +33,15 @@ require 'yunpian_sms'
|
|
33
33
|
YunPianSMS.api_key = 'your api key'
|
34
34
|
|
35
35
|
# template examples
|
36
|
-
|
37
|
-
|
36
|
+
result = YunPianSMS::Template.all
|
37
|
+
if result.successful
|
38
|
+
result.body.each do |element|
|
38
39
|
template_id = element["tpl_id"]
|
39
|
-
template = YunPianSMS::Template.find
|
40
|
-
end
|
40
|
+
template = YunPianSMS::Template.find(template_id).body
|
41
|
+
end
|
42
|
+
else
|
43
|
+
# raise error
|
44
|
+
end
|
41
45
|
~~~
|
42
46
|
|
43
47
|
|
data/lib/yunpian_sms/template.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
|
+
require 'yunpian_sms/result'
|
3
4
|
|
4
5
|
class YunPianSMS::Template
|
5
6
|
|
@@ -24,9 +25,9 @@ class YunPianSMS::Template
|
|
24
25
|
http.request req
|
25
26
|
end
|
26
27
|
if YunPianSMS.debug_mode && YunPianSMS.logger
|
27
|
-
YunPianSMS.logger.debug "Get Templates response #{res.body}"
|
28
|
+
YunPianSMS.logger.debug "Get Templates response status: #{res.code}, body: #{res.body}"
|
28
29
|
end
|
29
|
-
JSON.parse
|
30
|
+
YunPianSMS::Result.new(res.kind_of?(Net::HTTPSuccess), JSON.parse(res.body))
|
30
31
|
end
|
31
32
|
|
32
33
|
end
|
data/lib/yunpian_sms/version.rb
CHANGED
data/spec/yunpian_sms_spec.rb
CHANGED
@@ -7,23 +7,31 @@ require 'logger'
|
|
7
7
|
describe YunPianSMS do
|
8
8
|
|
9
9
|
subject(:logger) { Logger.new STDOUT }
|
10
|
+
subject(:api_key) { YAML.load_file('./spec/fixtures/configuration.yml')['api_key'] }
|
10
11
|
|
11
12
|
before do
|
12
|
-
configuration = YAML.load_file('./spec/fixtures/configuration.yml')
|
13
13
|
YunPianSMS.debug_mode = true
|
14
14
|
YunPianSMS.logger = logger
|
15
|
-
YunPianSMS.api_key = configuration['api_key']
|
16
15
|
end
|
17
16
|
|
18
17
|
context 'templates' do
|
19
18
|
|
20
|
-
it 'should get
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
it 'should get error response when api key missing' do
|
20
|
+
result = YunPianSMS::Template.all
|
21
|
+
expect(result.successful).to be false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should get all templates successfully' do
|
25
|
+
YunPianSMS.api_key = api_key
|
26
|
+
result = YunPianSMS::Template.all
|
27
|
+
expect(result.successful).to be true
|
28
|
+
logger.debug "all templtes #{result.body}"
|
29
|
+
expect(YunPianSMS::Template.find(12324235345435).successful).to be false
|
30
|
+
result.body.each do |element|
|
24
31
|
template_id = element["tpl_id"]
|
25
|
-
|
26
|
-
|
32
|
+
template_result = YunPianSMS::Template.find template_id
|
33
|
+
expect(template_result.successful).to be true
|
34
|
+
logger.debug "template #{template_result.body}"
|
27
35
|
end
|
28
36
|
end
|
29
37
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yunpian_sms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LCola
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- LICENSE.md
|
34
34
|
- README.md
|
35
35
|
- lib/yunpian_sms.rb
|
36
|
+
- lib/yunpian_sms/result.rb
|
36
37
|
- lib/yunpian_sms/template.rb
|
37
38
|
- lib/yunpian_sms/version.rb
|
38
39
|
- spec/yunpian_sms_spec.rb
|