cloopen_rest 0.0.2

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4323b6204d1b37dca693dc086eec0fda780a8f3
4
+ data.tar.gz: f838f11e22075da01bf5249cab047ea6f383561f
5
+ SHA512:
6
+ metadata.gz: c8dbd0aa21ff01f5d5f12c0cf5f19963f7643537b3837aa031383880af20fcab8921aebdaa897c9bf28609e12d5ad6a67779906ef6f3822e5bb931d6218da751
7
+ data.tar.gz: 7e5c7d5a22bdae3f5d5a90143f0aa34b99b1e20851add5ab181d2a6968b6eb19b3d452f4b348f1b8baa8f1ab7919242997d9581718e143fbb6033d4358dc8d5a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cloopen_rest.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 fahchen
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
@@ -0,0 +1,86 @@
1
+ # CloopenRest
2
+
3
+ The ruby wrapper of cloopen rest.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cloopen_rest'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cloopen_rest
18
+
19
+ ## Usage
20
+
21
+ ### Setup Work
22
+ ```ruby
23
+ require 'rubygems' # not necessary with ruby 1.9 but included for completeness
24
+ require 'cloopen_rest'
25
+
26
+ account_sid = 'your_account_sid'
27
+ auth_token = 'your_auth_token'
28
+ app_id = 'your_app_id'
29
+
30
+ @client = Cloopen::REST::Client.new(account_sid, auth_token, app_id)
31
+ @account = client.account
32
+ ```
33
+
34
+ ### Send a SMS ([official doc](http://42.121.15.9/index.php/短信))
35
+ ```ruby
36
+ message = @account.sms.messages.create(
37
+ to: 'your_phone_number',
38
+ body: 'text sms from gem',
39
+ sub_account_sid: 'your_sub_account_sid')
40
+
41
+ # Get the resquest response and status
42
+ message.response
43
+ message.response.body
44
+ message.response.status
45
+ message.response.status_code
46
+ ```
47
+
48
+ ### Get info of the account ([official doc](http://42.121.15.9/index.php/账户信息查询))
49
+ ```ruby
50
+ info = @account.account_info.get
51
+
52
+ info.response
53
+ ```
54
+
55
+ ### Make a landing call ([official doc](http://42.121.15.9/index.php/营销外呼))
56
+ ```ruby
57
+ landing_call = @account.calls.landing_calls.create(
58
+ to: 'your_phone_number',
59
+ media_txt: 'Hello, from Gem.',
60
+ play_times: 3)
61
+
62
+ landing_call.response
63
+ ```
64
+
65
+ ### Create a sub_account ([official doc](http://42.121.15.9/index.php/子账户))
66
+ ```ruby
67
+ sub_account = @account.sub_accounts.create friendly_name: 'awesome_name'
68
+
69
+ sub_account.response
70
+ ```
71
+
72
+ ## TODO
73
+ * Test
74
+ * More APIs
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create new Pull Request
83
+
84
+ ## Thanks
85
+
86
+ Inspired by [twilio-ruby](https://github.com/twilio/twilio-ruby)
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -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 'cloopen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cloopen_rest'
8
+ spec.version = Cloopen::REST::VERSION
9
+ spec.authors = ['fahchen']
10
+ spec.email = ['dev.fah@gmail.com']
11
+ spec.description = %q{the ruby wrapper of cloopen rest}
12
+ spec.summary = %q{cloopen rest}
13
+ spec.homepage = 'http://fahchen.github.io/cloopen_rest/'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+ spec.add_dependency 'httparty', '~> 0.11.0'
24
+ spec.add_dependency 'builder', '~> 2.0'
25
+ end
@@ -0,0 +1,169 @@
1
+ '108015': 应用未配置
2
+ '108022': 参数结点名称异常
3
+ '108023': 参数结点内容有误
4
+ '108034': 语音验证码长度有误(4~8位)
5
+ '108035': 外呼号码受限
6
+ '108036': 播放次数有误(1~3次)
7
+ '110000': 主账户Id错误
8
+ '110001': 主账户授权令牌错误
9
+ '110002': 主账户名称重复
10
+ '110003': 主账户Id为空
11
+ '110004': 主账户名称为空
12
+ '110005': 主账户状态为空
13
+ '110006': 主账户不存在
14
+ '110007': 主账户余额不足
15
+ '110008': 主账户未激活
16
+ '110009': 子账户Id错误
17
+ '110010': 子账户授权令牌错误
18
+ '110011': 子账户名称重复
19
+ '110012': 子账户名称为空
20
+ '110013': 子账户状态为空
21
+ '110014': 子账户类型为空
22
+ '110015': 子账户不存在
23
+ '110016': 子账户Id为空
24
+ '110017': 创建子账号失败
25
+ '110018': (主、子)账户Id或授权令牌无效
26
+ '110020': 生成电话回拨记录失败
27
+ '110021': 接收短信成功
28
+ '110022': 接收短信失败
29
+ '110023': 查询短信剩余数失败
30
+ '110024': 创建会议失败
31
+ '110025': IVR转发会议信息失败
32
+ '110026': 邀请加入会议失败
33
+ '110027': 退出会议失败
34
+ '110028': 会议静音失败
35
+ '110029': 实时对讲通知成功
36
+ '110030': 实时对讲通知失败
37
+ '110031': 启动实时对讲失败
38
+ '110032': 实时对讲抢麦失败
39
+ '110033': 实时对讲释放麦失败
40
+ '110034': 删除实时对讲通知成功
41
+ '110035': 删除实时对讲通知失败
42
+ '110036': 超过最大实时对讲人数
43
+ '110037': 实时对讲callid为空
44
+ '110038': 成员加入实时对讲失败
45
+ '110039': 成员退出实时对讲失败
46
+ '110040': 查询实时对讲成员失败
47
+ '110041': 延时语音留言状态修改成功
48
+ '110042': 延时语音留言状态修改失败
49
+ '110043': 延时语音留言文件状态为空
50
+ '110044': 延时语音留言接收端VoIP账号为空
51
+ '110045': 延时语音留言群组Id为空
52
+ '110046': 延时语音留言群组Id不存在
53
+ '110047': 上传延时语音留言文件失败
54
+ '110048': 查询未下载的延时语音留言文件失败
55
+ '110049': 查询延时语音留言群组成员失败
56
+ '110050': 应用名称重复
57
+ '110051': 应用Id为空
58
+ '110052': 应用名称为空
59
+ '110053': 应用状态异常
60
+ '110054': 应用类型为空
61
+ '110055': 应用删除成功
62
+ '110056': 应用删除失败
63
+ '110057': 应用不存在
64
+ '110058': 应用被禁用或删除,不能发送短信
65
+ '110059': 应用未上线,1分钟内只允许3次回拨
66
+ '110060': 没有找到软交换地址信息
67
+ '110061': 未知错误
68
+ '110062': 数据长度超长
69
+ '110063': 调用语音验证码接口失败
70
+ '110064': 网络超时
71
+ '110065': 非上线应用不能调用语音验证码功能
72
+ '110066': 子账号不属于该应用
73
+ '110067': 获取多人聊天室房间列表失败
74
+ '110068': 获取多人聊天室房间成员失败
75
+ '110069': 创建多人聊天室失败
76
+ '110070': 邀请人数有误
77
+ '110071': 邀请加入聊天室失败
78
+ '110072': 聊天室创建者为空
79
+ '110073': 聊天室房间别名为空
80
+ '110074': 应用未上线
81
+ '110075': 聊天室房间已满
82
+ '110076': 话单为空
83
+ '110077': 创建队列失败
84
+ '110078': 删除队列失败
85
+ '110079': 读取XML文档错误
86
+ '110080': 呼叫控制返回信息有误
87
+ '110081': medianame与mediatxt节点同时为空
88
+ '110082': 话单下载失败
89
+ '110083': 坐席上班失败
90
+ '110084': 坐席下班失败
91
+ '110085': 坐席准备失败
92
+ '110086': 坐席创建队列失败
93
+ '110087': 坐席删除队列失败
94
+ '110088': 坐席接口转发失败
95
+ '110089': IVR接口转发失败
96
+ '110090': 会议接口转发失败
97
+ '110091': 会议外呼失败
98
+ '110092': 房间人数超过最大限制
99
+ '110093': 最大人数为空
100
+ '110094': 连接超时
101
+ '110095': 权限验证错误
102
+ '110096': 发送多媒体im失败
103
+ '110097': 未下载多媒体im为空
104
+ '110098': 确认下载多媒体im失败
105
+ '110099': 多媒体im发送方账号为空
106
+ '110100': 发送多媒体im文件大小为空
107
+ '110101': 发送多媒体im文件类型为空
108
+ '110102': 查询未下载im失败
109
+ '110103': 查询未下载im参数有误
110
+ '110104': receive节点输入内容有误
111
+ '110105': misId为空
112
+ '110106': serviceId为空
113
+ '110107': PGM访问错误
114
+ '110108': 用户VoIP帐号为空
115
+ '110109': 群组发起者账号为空
116
+ '110110': 群组目标账号为空
117
+ '110111': 群组名字为空
118
+ '110112': 群组类型为空
119
+ '110113': 群组申请加入模式为空
120
+ '110114': 群组创建失败
121
+ '110115': 群组Id为空
122
+ '110116': 修改群组失败
123
+ '110117': 删除群组失败
124
+ '110118': 查询群组属性失败
125
+ '110119': 申请加入群组失败
126
+ '110120': 群组是否需要确认参数为空
127
+ '110121': 删除群组成员失败
128
+ '110122': 退出群组失败
129
+ '110123': 群组不存在
130
+ '110124': 用户名为空
131
+ '110125': 发送端VoIP账号为空
132
+ '110126': 呼叫控制错误
133
+ '110127': 参数错误
134
+ '110128': 会议Id错误
135
+ '110129': 主账户金额不足
136
+ '110130': 关闭子账号失败
137
+ '110131': 计费失败
138
+ '110132': 群组用户已存在
139
+ '110133': 私有群组不允许申请加入
140
+ '110134': 群组条件查询参数错误
141
+ '110135': 设置群组消息接收规则失败
142
+ '110136': 群组成员禁言参数为空
143
+ '110137': 群组成员禁言失败
144
+ '110138': 群组成员不能对自己禁言
145
+ '110139': 群组用户已被禁言
146
+ '110140': 群组成员成员不存在
147
+ '110141': 请求格式错误
148
+ '110142': 发送消息为空
149
+ '110143': IM用户私有数据为空
150
+ '110148': 查询坐席队列数据有误
151
+ '110149': 删除群组成员失败
152
+ '110150': 查询群组成员失败
153
+ '110151': 查询用户加入的群组失败
154
+ '110152': 管理员验证用户加入群组失败
155
+ '110153': 用户验证管理员邀请加入群组失败
156
+ '110154': 查询坐席队列失败
157
+ '110155': 查询坐席状态数据有误
158
+ '110156': 查询坐席状态失败
159
+ '110157': 坐席外呼失败
160
+ '100158': 添加群组成员失败
161
+ '100159': 修改群组成员失败
162
+ '110160': 添加群名片失败
163
+ '110161': 修改群名片失败
164
+ '110162': 成员数量超过群组最大成员数
165
+ '110163': 群聊房间ID错误
166
+ '110164': 路由配置有误
167
+ '121001': 计费鉴权失败--主账户错误
168
+ '121002': 计费鉴权失败--余额不足
169
+ '121003': 计费鉴权失败--费率有误
@@ -0,0 +1,11 @@
1
+ module Cloopen
2
+ module REST
3
+ class AccountInfo < InstanceResource
4
+ def get
5
+ raise "Can't create a resource without a REST Client" unless @client
6
+ response = @client.get self
7
+ self.class.new @uri, @client, response
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Cloopen
2
+ module REST
3
+
4
+ class SubAccounts < ListResource
5
+ end
6
+
7
+ class SubAccount < InstanceResource
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ module Cloopen
2
+ module REST
3
+ class Account < InstanceResource
4
+ def initialize(uri, cilent)
5
+ super uri, cilent
6
+ resource :account_info, :sms, :calls, :sub_accounts
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module Cloopen
2
+ module REST
3
+
4
+ class LandingCalls < ListResource
5
+ def initialize(uri, client)
6
+ super uri, client
7
+ end
8
+ end
9
+
10
+ class LandingCall < InstanceResource
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module Cloopen
2
+ module REST
3
+ class Calls < InstanceResource
4
+ def initialize(uri, cilent)
5
+ super uri, cilent
6
+ resource :landing_calls
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,79 @@
1
+ module Cloopen
2
+ module REST
3
+ class Client
4
+ include Utils
5
+
6
+ API_VERSION = '2013-03-22'
7
+
8
+ HTTP_HEADERS = {
9
+ 'Accept' => 'application/xml',
10
+ 'Content-Type' => 'application/xml;charset=utf-8'
11
+ }
12
+
13
+ PRODUCTION_HOST = 'https://app.cloopen.com'
14
+ LOCAL_HOST = '127.0.0.1'
15
+ SANDBOX_HOST = 'https://sandboxapp.cloopen.com'
16
+
17
+ attr_reader :account_sid, :auth_token, :signature, :authorization, :config, :headers, :account, :app_id
18
+
19
+ def initialize(account_sid, auth_token, app_id, options={})
20
+ @account_sid, @auth_token, @app_id = account_sid.strip, auth_token.strip, app_id.strip
21
+ @config = apply_defaults(options)
22
+ generate_authorization_params
23
+ set_up_subresources
24
+ end
25
+
26
+ def inspec
27
+ "<Cloopen::REST::Client @account_sid=#{@account_sid}>"
28
+ end
29
+
30
+ [:get, :post].each do |method|
31
+ define_method method do |resource, *args|
32
+ uri = "#{@config[:host]}:#{@config[:port]}#{resource.uri}?sig=#{@signature}"
33
+ options = { headers: @headers }
34
+ if [:post, :put].include? method
35
+ params = build_body args[0], resource
36
+ params = {} if params.empty?
37
+ options.merge! body: params
38
+ end
39
+ HTTParty.send(method, uri, options)
40
+ end
41
+ end
42
+
43
+ private
44
+ def generate_authorization_params
45
+ timestamp = Time.now.strftime('%Y%m%d%H%M%S')
46
+ @signature = Digest::MD5.hexdigest("#{@account_sid}#{@auth_token}#{timestamp}").upcase
47
+ authorization = Base64.strict_encode64("#{@account_sid}:#{timestamp}").strip
48
+ @headers = HTTP_HEADERS.merge! 'Authorization' => authorization
49
+ end
50
+
51
+ def defaults
52
+ {
53
+ host: find_default_host,
54
+ port: 8883
55
+ }
56
+ end
57
+
58
+ def find_default_host
59
+ case Cloopen.env.downcase
60
+ when 'production'
61
+ PRODUCTION_HOST
62
+ when 'test'
63
+ LOCAL_HOST
64
+ else
65
+ SANDBOX_HOST
66
+ end
67
+ end
68
+
69
+ def apply_defaults(options)
70
+ defaults.merge(options)
71
+ end
72
+
73
+ def set_up_subresources
74
+ @account = Cloopen::REST::Account.new "/#{API_VERSION}/Accounts/#{@account_sid}", self
75
+ end
76
+
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,43 @@
1
+ module Cloopen
2
+ module REST
3
+ class InstanceResource
4
+ include Utils
5
+
6
+ attr_reader :uri
7
+
8
+ def initialize(uri, client, params=nil)
9
+ @uri, @client = uri, client
10
+ params and set_up_properties_from params
11
+ end
12
+
13
+ def inspect
14
+ "<#{self.class} @uri='#{@uri}'>"
15
+ end
16
+
17
+ protected
18
+
19
+ def set_up_properties_from(hash)
20
+ hash.each do |p,v|
21
+ property = decloopfy p
22
+ response_body = prase_body v
23
+ unless ['uri', 'client'].include? property
24
+ instance_variable_set "@#{property}", Cloopen::REST::Response.new(response_body)
25
+ end
26
+ self.class.instance_eval {attr_reader property}
27
+ end
28
+ end
29
+
30
+ def resource(*resources)
31
+ resources.each do |r|
32
+ resource = cloopfy r
33
+ relative_uri = r == :sms ? 'SMS' : resource
34
+ uri = "#{@uri}/#{relative_uri}"
35
+ resource_class = Cloopen::REST.const_get resource
36
+ instance_variable_set("@#{r}", resource_class.new(uri, @client))
37
+ end
38
+ self.class.instance_eval {attr_reader *resources}
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,27 @@
1
+ module Cloopen
2
+ module REST
3
+ class ListResource
4
+ include Utils
5
+
6
+ attr_reader :uri, :instance_key
7
+
8
+ def initialize(uri, client)
9
+ @uri, @client = uri, client
10
+ @instance_key ||= self.class.name.split('::')[-1]
11
+
12
+ resource_name = self.class.name.split('::')[-1]
13
+ @instance_class = Cloopen::REST.const_get resource_name.chop
14
+ end
15
+
16
+ def inspect
17
+ "<#{self.class} @uri='#{@uri}'>"
18
+ end
19
+
20
+ def create(params={})
21
+ raise "Can't create a resource without a REST Client" unless @client
22
+ response = @client.post self, params
23
+ @instance_class.new @uri, @client, response
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ module Cloopen
2
+ module REST
3
+ class Response
4
+ STATUS_CODE_DESCRIPTIONS = YAML.load_file("conf/status_code_descriptions.yml")
5
+
6
+ attr_reader :status, :status_code, :body
7
+ def initialize(body)
8
+ @body = body
9
+ @status_code = @body.delete(:status_code)
10
+ @status = status_code_descritptions[@status_code]
11
+ end
12
+
13
+ private
14
+ def status_code_descritptions
15
+ hash = STATUS_CODE_DESCRIPTIONS
16
+ hash.default = 'unknow_error'
17
+ hash.merge({'000000' => 'succeeds'})
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,15 @@
1
+ module Cloopen
2
+ module REST
3
+
4
+ class Messages < ListResource
5
+ def initialize(uri, client)
6
+ @instance_key = 'SMSMessages'
7
+ super uri, client
8
+ end
9
+ end
10
+
11
+ class Message < InstanceResource
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ module Cloopen
2
+ module REST
3
+ class Sms < InstanceResource
4
+ def initialize(uri, cilent)
5
+ super uri, cilent
6
+ resource :messages
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,62 @@
1
+ module Cloopen
2
+ module REST
3
+ module Utils
4
+
5
+ def build_body(something, resource)
6
+ builder = Builder::XmlMarkup.new
7
+ builder.instruct! :xml, version: '1.0', encoding: 'UTF-8'
8
+
9
+ builder.tag! resource.instance_key.chop do |resource|
10
+ something.each do |k, v|
11
+ attr = downcase_first cloopfy(k)
12
+ resource.tag! attr, v
13
+ end
14
+ resource.appId @app_id
15
+ end
16
+ end
17
+
18
+ def prase_body(something)
19
+ if something.is_a? Hash
20
+ beautify_hash something
21
+ else
22
+ something
23
+ end
24
+ end
25
+
26
+ def beautify_hash(hash)
27
+ hash = decloopfy hash
28
+ hash.each do |k, v|
29
+ hash[k] = if v.is_a? Hash
30
+ beautify_hash v
31
+ else
32
+ v
33
+ end
34
+ end
35
+ end
36
+
37
+
38
+ def downcase_first(something)
39
+ [something[0, 1].downcase, something[1..-1]].join('')
40
+ end
41
+
42
+ def cloopfy(something)
43
+ if something.is_a? Hash
44
+ Hash[*something.to_a.map {|a| [cloopfy(a[0]).to_sym, a[1]]}.flatten]
45
+ else
46
+ something.to_s.split('_').map do |s|
47
+ [s[0,1].capitalize, s[1..-1]].join
48
+ end.join
49
+ end
50
+ end
51
+
52
+ def decloopfy(something)
53
+ if something.is_a? Hash
54
+ Hash[*something.to_a.map {|pair| [decloopfy(pair[0]).to_sym, pair[1]]}.flatten]
55
+ else
56
+ something.to_s.gsub(/[A-Z][a-z]*/) {|s| "_#{s.downcase}"}.gsub(/^_/, '')
57
+ end
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,5 @@
1
+ module Cloopen
2
+ module REST
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ require 'httparty'
2
+ require 'builder'
3
+ require 'net/http'
4
+ require 'digest/md5'
5
+ require 'base64'
6
+
7
+ require 'cloopen/version'
8
+ require 'cloopen/rest/utils'
9
+ require 'cloopen/rest/response'
10
+ require 'cloopen/rest/instance_resource'
11
+ require 'cloopen/rest/list_resource'
12
+ require 'cloopen/rest/account/account_info'
13
+ require 'cloopen/rest/account/sub_accounts'
14
+ require 'cloopen/rest/account'
15
+ require 'cloopen/rest/sms/messages'
16
+ require 'cloopen/rest/sms'
17
+ require 'cloopen/rest/call/landing_calls'
18
+ require 'cloopen/rest/calls'
19
+ require 'cloopen/rest/client'
20
+
21
+ module Cloopen
22
+ def self.env
23
+ ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloopen_rest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - fahchen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-02 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: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: httparty
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 0.11.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 0.11.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: builder
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ description: the ruby wrapper of cloopen rest
70
+ email:
71
+ - dev.fah@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - cloopen_rest.gemspec
82
+ - conf/status_code_descriptions.yml
83
+ - lib/cloopen/rest/account.rb
84
+ - lib/cloopen/rest/account/account_info.rb
85
+ - lib/cloopen/rest/account/sub_accounts.rb
86
+ - lib/cloopen/rest/call/landing_calls.rb
87
+ - lib/cloopen/rest/calls.rb
88
+ - lib/cloopen/rest/client.rb
89
+ - lib/cloopen/rest/instance_resource.rb
90
+ - lib/cloopen/rest/list_resource.rb
91
+ - lib/cloopen/rest/response.rb
92
+ - lib/cloopen/rest/sms.rb
93
+ - lib/cloopen/rest/sms/messages.rb
94
+ - lib/cloopen/rest/utils.rb
95
+ - lib/cloopen/version.rb
96
+ - lib/cloopen_rest.rb
97
+ homepage: http://fahchen.github.io/cloopen_rest/
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.0.7
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: cloopen rest
121
+ test_files: []
122
+ has_rdoc: