yunpian_sms 0.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 +7 -0
- data/LICENSE.md +9 -0
- data/README.md +55 -0
- data/lib/yunpian_sms/template.rb +32 -0
- data/lib/yunpian_sms/version.rb +3 -0
- data/lib/yunpian_sms.rb +13 -0
- data/spec/yunpian_sms_spec.rb +32 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0011d0dee558f4d2ae2722d8cbafddc79f82a0f8
|
4
|
+
data.tar.gz: '04129d8f55e5672778d39c1feb7420b10a7afad6'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7baf052d77bd4bc93dd164bcadb1d17a8fe0b68b8d42b172d71b65d8ef18215d28ed091e50059770358058c997535e1e9a0b1441b67e3cb3461f03a8867ef019
|
7
|
+
data.tar.gz: 7a3a7a740dc544c849b1d2ec64faead68bc151aaacf01dbef0fc83a6ff423f01433b6930eca0c3cc73946da2be4ad86bd342017a7d5520d83c557543c79d7b35
|
data/LICENSE.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2009-2013 Nicholas J Humfrey
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
YunPian SMS Ruby SDK
|
2
|
+
=========
|
3
|
+
|
4
|
+
[云片短信](https://www.yunpian.com/doc/zh_CN/introduction/brief.html) Ruby SDK, 非官方。
|
5
|
+
|
6
|
+
Table of Contents
|
7
|
+
-----------------
|
8
|
+
* [Installation](#installation)
|
9
|
+
* [Quick Start](#quick-start)
|
10
|
+
* [License](#license)
|
11
|
+
* [Contact](#contact)
|
12
|
+
|
13
|
+
|
14
|
+
Installation
|
15
|
+
------------
|
16
|
+
|
17
|
+
You may get the latest stable version from [Rubygems]:
|
18
|
+
|
19
|
+
$ gem install yunpian_sms
|
20
|
+
|
21
|
+
For bundler:
|
22
|
+
|
23
|
+
gem 'yunpian_sms'
|
24
|
+
|
25
|
+
|
26
|
+
Quick Start
|
27
|
+
-----------
|
28
|
+
|
29
|
+
~~~ ruby
|
30
|
+
require 'rubygems'
|
31
|
+
require 'yunpian_sms'
|
32
|
+
|
33
|
+
YunPianSMS.api_key = 'your api key'
|
34
|
+
|
35
|
+
# template examples
|
36
|
+
all_templates = YunPianSMS::Template.all
|
37
|
+
all_templates.each do |element|
|
38
|
+
template_id = element["tpl_id"]
|
39
|
+
template = YunPianSMS::Template.find template_id
|
40
|
+
end
|
41
|
+
~~~
|
42
|
+
|
43
|
+
|
44
|
+
License
|
45
|
+
-------
|
46
|
+
|
47
|
+
The yunpian_sms ruby gem is licensed under the terms of the MIT license.
|
48
|
+
See the file LICENSE for details.
|
49
|
+
|
50
|
+
Contact
|
51
|
+
-------
|
52
|
+
|
53
|
+
* Author: James Wang
|
54
|
+
* Email: james.wang.z81@gmail.com
|
55
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class YunPianSMS::Template
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
get_templates({ apikey: YunPianSMS.api_key })
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.find template_id
|
11
|
+
get_templates({ apikey: YunPianSMS.api_key, tpl_id: template_id })
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def self.get_templates(params)
|
17
|
+
uri = URI.parse("#{YunPianSMS.server}/tpl/get.json")
|
18
|
+
if YunPianSMS.debug_mode && YunPianSMS.logger
|
19
|
+
YunPianSMS.logger.debug "Requesting uri #{uri}..."
|
20
|
+
end
|
21
|
+
req = Net::HTTP::Post.new(uri)
|
22
|
+
res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
23
|
+
req.set_form_data(params)
|
24
|
+
http.request req
|
25
|
+
end
|
26
|
+
if YunPianSMS.debug_mode && YunPianSMS.logger
|
27
|
+
YunPianSMS.logger.debug "Get Templates response #{res.body}"
|
28
|
+
end
|
29
|
+
JSON.parse res.body
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/lib/yunpian_sms.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'yaml'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
describe YunPianSMS do
|
8
|
+
|
9
|
+
subject(:logger) { Logger.new STDOUT }
|
10
|
+
|
11
|
+
before do
|
12
|
+
configuration = YAML.load_file('./spec/fixtures/configuration.yml')
|
13
|
+
YunPianSMS.debug_mode = true
|
14
|
+
YunPianSMS.logger = logger
|
15
|
+
YunPianSMS.api_key = configuration['api_key']
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'templates' do
|
19
|
+
|
20
|
+
it 'should get all templates' do
|
21
|
+
all_templates = YunPianSMS::Template.all
|
22
|
+
logger.debug "all templtes #{all_templates}"
|
23
|
+
all_templates.each do |element|
|
24
|
+
template_id = element["tpl_id"]
|
25
|
+
template = YunPianSMS::Template.find template_id
|
26
|
+
logger.debug "template #{template}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yunpian_sms
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- LCola
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: An unofficial simple yunpian sms ruby gem
|
28
|
+
email: james.wang.z81@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- LICENSE.md
|
34
|
+
- README.md
|
35
|
+
- lib/yunpian_sms.rb
|
36
|
+
- lib/yunpian_sms/template.rb
|
37
|
+
- lib/yunpian_sms/version.rb
|
38
|
+
- spec/yunpian_sms_spec.rb
|
39
|
+
homepage: https://github.com/jameswangz/yunpian_sms
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
metadata: {}
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 2.6.14
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: Yunpian sms ruby sdk
|
63
|
+
test_files:
|
64
|
+
- spec/yunpian_sms_spec.rb
|