yuntongxun-api 0.0.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/.gitignore +0 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/LICENSE.txt +22 -0
- data/README.md +3 -0
- data/lib/yuntongxun.rb +16 -0
- data/lib/yuntongxun/service.rb +60 -0
- data/lib/yuntongxun/service/calls.rb +13 -0
- data/lib/yuntongxun/utils.rb +7 -0
- data/lib/yuntongxun/version.rb +3 -0
- data/yuntongxun.gemspec +25 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 932eec97a9df9de1dcf888d5e84a4af253f4df93
|
4
|
+
data.tar.gz: f0da4c4c31e5e7d86e36af9e574e3c690ffe6859
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 63eefc43b328a55a7d4849664f9b21eeff6460465e9acd4fe56d3e7c401891b162a065bd62be126415b50db8ac41d361d81cd7c61cb0f3b78c9ad115e35c6a06
|
7
|
+
data.tar.gz: 4d1b16aa5f83c12cc940b9db07fb3bb5e5bb98582a89811f747728f87957415b331b1956e52e72557a8c8462d34e6ded653aa2133c0a9693bb12e392dd59e465
|
data/.gitignore
ADDED
File without changes
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
yuntongxun (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.1)
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
method_source (0.8.2)
|
12
|
+
pry (0.10.3)
|
13
|
+
coderay (~> 1.1.0)
|
14
|
+
method_source (~> 0.8.1)
|
15
|
+
slop (~> 3.4)
|
16
|
+
rake (10.5.0)
|
17
|
+
rspec (3.4.0)
|
18
|
+
rspec-core (~> 3.4.0)
|
19
|
+
rspec-expectations (~> 3.4.0)
|
20
|
+
rspec-mocks (~> 3.4.0)
|
21
|
+
rspec-core (3.4.4)
|
22
|
+
rspec-support (~> 3.4.0)
|
23
|
+
rspec-expectations (3.4.0)
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
25
|
+
rspec-support (~> 3.4.0)
|
26
|
+
rspec-mocks (3.4.1)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.4.0)
|
29
|
+
rspec-support (3.4.1)
|
30
|
+
slop (3.6.0)
|
31
|
+
|
32
|
+
PLATFORMS
|
33
|
+
ruby
|
34
|
+
|
35
|
+
DEPENDENCIES
|
36
|
+
bundler (~> 1.3)
|
37
|
+
pry
|
38
|
+
rake (~> 10.0)
|
39
|
+
rspec (~> 3.4)
|
40
|
+
yuntongxun!
|
41
|
+
|
42
|
+
BUNDLED WITH
|
43
|
+
1.12.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Fwshun8023
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/lib/yuntongxun.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'json'
|
3
|
+
require 'digest'
|
4
|
+
require 'base64'
|
5
|
+
require 'net/http'
|
6
|
+
require 'net/https'
|
7
|
+
require 'yuntongxun/version'
|
8
|
+
require 'yuntongxun/utils'
|
9
|
+
require 'yuntongxun/service'
|
10
|
+
require 'yuntongxun/service/calls'
|
11
|
+
|
12
|
+
module YunTongXun
|
13
|
+
class << self
|
14
|
+
attr_accessor :account_sid, :auth_token, :base_url
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module YunTongXun
|
2
|
+
class Service
|
3
|
+
|
4
|
+
# 子账号调用接口时需传入子账号信息
|
5
|
+
def initialize(sub_account_sid = nil, sub_auth_token = nil, version = "2013-12-26")
|
6
|
+
@sub_account_sid = sub_account_sid
|
7
|
+
@sub_auth_token = sub_auth_token
|
8
|
+
@version = version
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_response(header, data, path)
|
12
|
+
uri = URI(base_url + path)
|
13
|
+
|
14
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
15
|
+
|
16
|
+
http.use_ssl = true
|
17
|
+
|
18
|
+
request = Net::HTTP::Post.new(base_url + path, header)
|
19
|
+
|
20
|
+
request.body = data.to_json
|
21
|
+
|
22
|
+
response = http.request(request)
|
23
|
+
|
24
|
+
result response.body
|
25
|
+
end
|
26
|
+
|
27
|
+
# account_sid: 主账号或子账号
|
28
|
+
def sign(account_sid, auth_token)
|
29
|
+
Digest::MD5.hexdigest(account_sid + auth_token + YunTongXun::Utils.timestamp).upcase
|
30
|
+
end
|
31
|
+
|
32
|
+
# account_sid: 主账号或子账号
|
33
|
+
def headers(account_sid)
|
34
|
+
{
|
35
|
+
'Accept' => 'application/json',
|
36
|
+
'Content-Type' => 'application/json;charset=utf-8',
|
37
|
+
'Authorization' => Base64.strict_encode64(account_sid + ':' + YunTongXun::Utils.timestamp)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def base_url
|
42
|
+
YunTongXun.base_url || "https://app.cloopen.com:8883"
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
private
|
47
|
+
def result body
|
48
|
+
begin
|
49
|
+
JSON.parse body
|
50
|
+
rescue => e
|
51
|
+
{
|
52
|
+
code: 502,
|
53
|
+
msg: "内容解析错误",
|
54
|
+
detail: e.to_s
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module YunTongXun
|
2
|
+
class Calls < Service
|
3
|
+
CALLBACK = "/Calls/Callback"
|
4
|
+
|
5
|
+
def callback(options = {})
|
6
|
+
header = headers(@sub_account_sid)
|
7
|
+
sig = sign(@sub_account_sid, @sub_auth_token)
|
8
|
+
path = "/#{@version}/SubAccounts/#{@sub_account_sid}/Calls/Callback?sig=#{sig}"
|
9
|
+
get_response(header, options, path)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
data/yuntongxun.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'yuntongxun/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'yuntongxun-api'
|
8
|
+
s.version = YunTongXun::VERSION
|
9
|
+
s.date = '2016-06-23'
|
10
|
+
s.summary = "Ruby SDK for 容联云通讯 development"
|
11
|
+
s.description = "Ruby SDK for 容联云通讯 development"
|
12
|
+
s.authors = ["fwshun8023"]
|
13
|
+
s.email = ['fwshun8023@gmai.com']
|
14
|
+
s.homepage = 'https://github.com/fwshun8023/yuntongxun-api'
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split($/)
|
18
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "bundler", "~> 1.3"
|
23
|
+
s.add_development_dependency "rake", "~> 10.0"
|
24
|
+
s.add_development_dependency 'rspec', "~> 3.4"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yuntongxun-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- fwshun8023
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
description: Ruby SDK for 容联云通讯 development
|
56
|
+
email:
|
57
|
+
- fwshun8023@gmai.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- lib/yuntongxun.rb
|
68
|
+
- lib/yuntongxun/service.rb
|
69
|
+
- lib/yuntongxun/service/calls.rb
|
70
|
+
- lib/yuntongxun/utils.rb
|
71
|
+
- lib/yuntongxun/version.rb
|
72
|
+
- yuntongxun.gemspec
|
73
|
+
homepage: https://github.com/fwshun8023/yuntongxun-api
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.6.4
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Ruby SDK for 容联云通讯 development
|
97
|
+
test_files: []
|
98
|
+
has_rdoc:
|