avod 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +34 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +23 -0
- data/LICENSE +20 -0
- data/README.md +72 -0
- data/Rakefile +8 -0
- data/avod.gemspec +26 -0
- data/lib/avod.rb +20 -0
- data/lib/avod/client.rb +242 -0
- data/lib/avod/version.rb +3 -0
- data/spec/avod_spec.rb +7 -0
- data/spec/client_install_spec.rb +31 -0
- data/spec/client_object_spec.rb +56 -0
- data/spec/client_user_spec.rb +56 -0
- metadata +119 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ca82b194b47acdbf6a8622d7494ac63eec079dae
|
4
|
+
data.tar.gz: 665d1c141c210be7c3ade031d4382eb3fa623e19
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5c9062b3086e16fe6e891ecfb432b02c838321572764fa3a8fb0741cff555ee656587e03bbb1d6929b03deb92ebded7c659564214a9449e4a2f8eda0a75b7bf6
|
7
|
+
data.tar.gz: 5e2eccb53bbdb5ec7999ea9d915dd2e4c2d2c982bdc413bfef30dcb3466dd2edbed43acb254065411916807ba00210eb20bc92c098cd6a0025a7fffc90082df5
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
#********** OSX template**********
|
3
|
+
|
4
|
+
.DS_Store
|
5
|
+
|
6
|
+
# Thumbnails
|
7
|
+
._*
|
8
|
+
|
9
|
+
# Files that might appear on external disk
|
10
|
+
.Spotlight-V100
|
11
|
+
.Trashes
|
12
|
+
|
13
|
+
|
14
|
+
#********** ruby template**********
|
15
|
+
|
16
|
+
*.gem
|
17
|
+
*.rbc
|
18
|
+
.bundle
|
19
|
+
.config
|
20
|
+
coverage
|
21
|
+
InstalledFiles
|
22
|
+
lib/bundler/man
|
23
|
+
pkg
|
24
|
+
rdoc
|
25
|
+
spec/reports
|
26
|
+
test/tmp
|
27
|
+
test/version_tmp
|
28
|
+
tmp
|
29
|
+
|
30
|
+
# YARD artifacts
|
31
|
+
.yardoc
|
32
|
+
_yardoc
|
33
|
+
doc/
|
34
|
+
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
GEM
|
2
|
+
specs:
|
3
|
+
diff-lcs (1.2.4)
|
4
|
+
json (1.8.1)
|
5
|
+
mime-types (2.0)
|
6
|
+
rest-client (1.6.7)
|
7
|
+
mime-types (>= 1.16)
|
8
|
+
rspec (2.14.1)
|
9
|
+
rspec-core (~> 2.14.0)
|
10
|
+
rspec-expectations (~> 2.14.0)
|
11
|
+
rspec-mocks (~> 2.14.0)
|
12
|
+
rspec-core (2.14.7)
|
13
|
+
rspec-expectations (2.14.3)
|
14
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
15
|
+
rspec-mocks (2.14.4)
|
16
|
+
|
17
|
+
PLATFORMS
|
18
|
+
ruby
|
19
|
+
|
20
|
+
DEPENDENCIES
|
21
|
+
json
|
22
|
+
rest-client
|
23
|
+
rspec
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Lin Xiangyu
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
AvodCloud Ruby Client
|
2
|
+
======================
|
3
|
+
|
4
|
+
|
5
|
+
Ruby wrapper of https://cn.avoscloud.com/ REST API
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
more details is in `lib/avod/client.rb`
|
12
|
+
|
13
|
+
client = Avod::Client.new(your_app_id, your_app_key, you_master_key)
|
14
|
+
|
15
|
+
client.get_all_users
|
16
|
+
|
17
|
+
=> {"results"=>
|
18
|
+
[{"username"=>"h",
|
19
|
+
"createdAt"=>"2013-10-08T12:15:11.517Z",
|
20
|
+
"email"=>"oa414@163.COM",
|
21
|
+
"objectId"=>"525386cfe4b03677117c865e",
|
22
|
+
"emailVerified"=>false,
|
23
|
+
"updatedAt"=>"2013-10-08T12:15:11.517Z"}]}
|
24
|
+
|
25
|
+
b = {beauty: "zj"}
|
26
|
+
|
27
|
+
=> {:beauty=>"zj"}
|
28
|
+
|
29
|
+
client.create_object("person", b)
|
30
|
+
|
31
|
+
=> {"createdAt"=>"2013-11-06T13:03:51.360Z",
|
32
|
+
"objectId"=>"5279cdb7e4b048391d4746ac"}
|
33
|
+
|
34
|
+
client.get_object("5279cdb7e4b048391d4746ac")
|
35
|
+
|
36
|
+
{"objectId"=>"5279cdb7e4b048391d4746ac",
|
37
|
+
"beauty"=>"zj",
|
38
|
+
"createdAt"=>"2013-11-06T13:03:51.360Z",
|
39
|
+
"updatedAt"=>"2013-11-06T13:03:51.360Z"}
|
40
|
+
|
41
|
+
## TODO
|
42
|
+
|
43
|
+
- add more REST API wrapper
|
44
|
+
- now the rspec test rely on my test app_id created in avodcloud , if someone delete some object of it, the test may be failing
|
45
|
+
|
46
|
+
## Author
|
47
|
+
|
48
|
+
- Lin Xiangyu
|
49
|
+
- [lxyweb@gmail.com](mailto://lxyweb@gmail.com)
|
50
|
+
|
51
|
+
----
|
52
|
+
|
53
|
+
The MIT License (MIT)
|
54
|
+
|
55
|
+
Copyright (c) 2013 Lin Xiangyu
|
56
|
+
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
58
|
+
this software and associated documentation files (the "Software"), to deal in
|
59
|
+
the Software without restriction, including without limitation the rights to
|
60
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
61
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
62
|
+
subject to the following conditions:
|
63
|
+
|
64
|
+
The above copyright notice and this permission notice shall be included in all
|
65
|
+
copies or substantial portions of the Software.
|
66
|
+
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
68
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
69
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
70
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
71
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
72
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/avod.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'avod/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "avod"
|
8
|
+
spec.version = Avod::VERSION
|
9
|
+
spec.authors = ["Linxiangyu"]
|
10
|
+
spec.email = ["lxyweb@gmail.com"]
|
11
|
+
spec.description = %q{avod cloud client}
|
12
|
+
spec.summary = %q{avod cloud client}
|
13
|
+
spec.homepage = "https://github.com/oa414/avod-ruby"
|
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_development_dependency "rest-client"
|
24
|
+
spec.add_development_dependency "json"
|
25
|
+
|
26
|
+
end
|
data/lib/avod.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.expand_path("../avod/client.rb", __FILE__)
|
2
|
+
require File.expand_path("../avod/version.rb", __FILE__)
|
3
|
+
|
4
|
+
|
5
|
+
module Avod
|
6
|
+
|
7
|
+
|
8
|
+
def get_test_client
|
9
|
+
app_id = "ty3gmgv4wy39ce0fip38179tr785kwzdxi36s0tjp6c1qlql"
|
10
|
+
app_key = "frul1auqu2qpqayn4bvlfnj8if9cboqdwxzfv9tko6z4rzwk"
|
11
|
+
master_key = "1y91cayb2izmenmifwm9o5th57k2du2ykatxfafdsl36gd69"
|
12
|
+
@client = Avod::Client.new(app_id, app_key, master_key)
|
13
|
+
end
|
14
|
+
|
15
|
+
module_function :get_test_client
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
|
data/lib/avod/client.rb
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
require "rest_client"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module Avod
|
5
|
+
|
6
|
+
|
7
|
+
class Client
|
8
|
+
|
9
|
+
BASE_URL = "https://cn.avoscloud.com/"
|
10
|
+
VERSION_CODE = "1"
|
11
|
+
API_URL = BASE_URL + VERSION_CODE + "/"
|
12
|
+
API_OBJECT_URL = API_URL + "classes/"
|
13
|
+
API_USER_URL = API_URL + "users"
|
14
|
+
API_INSTALLIIONS_URL = API_URL + "installations"
|
15
|
+
|
16
|
+
def initialize(app_id, app_key, master_key)
|
17
|
+
@app_id = app_id
|
18
|
+
@app_key = app_key
|
19
|
+
@master_key = master_key
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# /1/classes/<className> POST 创建对象
|
24
|
+
# /1/classes/<className>/<objectId> GET 获取对象
|
25
|
+
# /1/classes/<className>/<objectId> PUT 更新对象
|
26
|
+
# /1/classes/<className> GET 查询对象
|
27
|
+
# /1/classes/<className>/<objectId> DELETE 删除对象
|
28
|
+
|
29
|
+
|
30
|
+
def get_all_object(name)
|
31
|
+
get API_OBJECT_URL + name
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_object(class_name, object)
|
35
|
+
post API_OBJECT_URL + class_name, object.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_object(class_name, object_id)
|
39
|
+
get API_OBJECT_URL + class_name + "/" + object_id
|
40
|
+
end
|
41
|
+
|
42
|
+
def update_object(class_name, object_id, object)
|
43
|
+
put API_OBJECT_URL + class_name + "/" + object_id, object.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete_object(class_name, object_id)
|
47
|
+
delete API_OBJECT_URL + class_name + "/" + object_id
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# URL HTTP 功能
|
52
|
+
# /1/users POST 用户注册
|
53
|
+
# 用户连接
|
54
|
+
# /1/login GET 用户登录
|
55
|
+
# /1/users/<objectId> GET 获取用户
|
56
|
+
# /1/users/<objectId> PUT 更新用户
|
57
|
+
# 用户连接
|
58
|
+
# 验证Email
|
59
|
+
# /1/users GET 查询用户
|
60
|
+
# /1/users/<objectId> DELETE 删除用户
|
61
|
+
# /1/requestPasswordReset POST 请求密码重设
|
62
|
+
|
63
|
+
def update_user(user_id, params, session) #untest
|
64
|
+
url = API_USER_URL + user_id
|
65
|
+
result = RestClient.put url , params,
|
66
|
+
:"content-type" => "application/json",
|
67
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
68
|
+
:"X-AVOSCloud-Application-Key" => @app_key,
|
69
|
+
:"X-AVOSCloud-Session-Token" => session
|
70
|
+
return to_json(params)
|
71
|
+
end
|
72
|
+
|
73
|
+
def get_all_users
|
74
|
+
get API_USER_URL
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_user(object_id)
|
78
|
+
get API_USER_URL + "/" + object_id
|
79
|
+
end
|
80
|
+
|
81
|
+
def register_user(username, password, email, *opt) #untest
|
82
|
+
if opt
|
83
|
+
params = opt
|
84
|
+
else
|
85
|
+
params = Hash.new
|
86
|
+
end
|
87
|
+
params[:password] = password
|
88
|
+
params[:username] = username
|
89
|
+
post API_USER_URL, params
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def rest_password(email) #untest
|
94
|
+
params = {"email" => email}
|
95
|
+
post API_URL + "requestPasswordReset", params
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete_user(user_id, session) #untest
|
99
|
+
url = API_USER_URL + user_id
|
100
|
+
result = RestClient.delete url ,
|
101
|
+
:"content-type" => "application/json",
|
102
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
103
|
+
:"X-AVOSCloud-Application-Key" => @app_key,
|
104
|
+
:"X-AVOSCloud-Session-Token" => session
|
105
|
+
result.code == 200
|
106
|
+
end
|
107
|
+
|
108
|
+
def reset_email(email) #faild
|
109
|
+
url = "https://cn.avoscloud.com/1/requestPasswordReset"
|
110
|
+
params = {"email" => email}
|
111
|
+
result = RestClient.post url , params,
|
112
|
+
:"content-type" => "application/json",
|
113
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
114
|
+
:"X-AVOSCloud-Application-Key" => @app_key,
|
115
|
+
:"X-AVOSCloud-Master-Key" => @master_key
|
116
|
+
result.code == 200
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
# URL HTTP 功能
|
126
|
+
# /1/roles POST 创建角色
|
127
|
+
# /1/roles/<objectId> GET 获取角色
|
128
|
+
# /1/roles/<objectId> PUT 更新角色
|
129
|
+
# /1/roles GET 查询角色
|
130
|
+
# /1/roles/<objectId> DELETE 删除角色
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
# URL HTTP 功能
|
135
|
+
# /1/push POST 推送通知
|
136
|
+
|
137
|
+
|
138
|
+
# 安装数据
|
139
|
+
|
140
|
+
# URL HTTP 功能
|
141
|
+
# /1/installations POST 上传安装数据
|
142
|
+
# /1/installations/<objectId> GET 获取安装数据
|
143
|
+
# /1/installations/<objectId> PUT 更新安装数据
|
144
|
+
# /1/installations GET 查询安装数据
|
145
|
+
# /1/installations/<objectId> DELETE 删除安装数据
|
146
|
+
|
147
|
+
def get_installations
|
148
|
+
private_get API_INSTALLIIONS_URL
|
149
|
+
end
|
150
|
+
|
151
|
+
def get_install(object_id)
|
152
|
+
get API_INSTALLIIONS_URL + "/" + object_id
|
153
|
+
end
|
154
|
+
|
155
|
+
def update_install(object_id, params) #untest
|
156
|
+
put API_INSTALLIIONS_URL + "/" + params["objectId"], params
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
# Cloud函数
|
164
|
+
|
165
|
+
# URL HTTP 功能
|
166
|
+
# /1/functions POST 调用Cloud Code函数
|
167
|
+
|
168
|
+
|
169
|
+
protected
|
170
|
+
|
171
|
+
|
172
|
+
def to_json(str)
|
173
|
+
return JSON.parse(str)
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
def private_post(url, params)
|
178
|
+
result = RestClient.post url , params,
|
179
|
+
:"content-type" => "application/json",
|
180
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
181
|
+
:"X-AVOSCloud-Application-Key" => @app_key,
|
182
|
+
:"X-AVOSCloud-Master-Key" => @master_key
|
183
|
+
to_json(result)
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
def post(url, params)
|
188
|
+
result = RestClient.post url , params,
|
189
|
+
:"content-type" => "application/json",
|
190
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
191
|
+
:"X-AVOSCloud-Application-Key" => @app_key
|
192
|
+
to_json(result)
|
193
|
+
|
194
|
+
end
|
195
|
+
|
196
|
+
def get(url)
|
197
|
+
result = RestClient.get url ,
|
198
|
+
:"content-type" => "application/json",
|
199
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
200
|
+
:"X-AVOSCloud-Application-Key" => @app_key
|
201
|
+
to_json(result)
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
def private_get(url)
|
206
|
+
result = RestClient.get url ,
|
207
|
+
:"content-type" => "application/json",
|
208
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
209
|
+
:"X-AVOSCloud-Application-Key" => @app_key,
|
210
|
+
:"X-AVOSCloud-Master-Key" => @master_key
|
211
|
+
to_json(result)
|
212
|
+
end
|
213
|
+
|
214
|
+
def delete(url)
|
215
|
+
result = RestClient.delete url ,
|
216
|
+
:"content-type" => "application/json",
|
217
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
218
|
+
:"X-AVOSCloud-Application-Key" => @app_key
|
219
|
+
result.code == 200
|
220
|
+
end
|
221
|
+
|
222
|
+
def put(url, params)
|
223
|
+
result = RestClient.put url , params,
|
224
|
+
:"content-type" => "application/json",
|
225
|
+
:"X-AVOSCloud-Application-Id" => @app_id,
|
226
|
+
:"X-AVOSCloud-Application-Key" => @app_key
|
227
|
+
to_json(result)
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
data/lib/avod/version.rb
ADDED
data/spec/avod_spec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path("../../lib/avod.rb", __FILE__)
|
2
|
+
|
3
|
+
describe "avod" do
|
4
|
+
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
app_id = "ty3gmgv4wy39ce0fip38179tr785kwzdxi36s0tjp6c1qlql"
|
8
|
+
app_key = "frul1auqu2qpqayn4bvlfnj8if9cboqdwxzfv9tko6z4rzwk"
|
9
|
+
master_key = "1y91cayb2izmenmifwm9o5th57k2du2ykatxfafdsl36gd69"
|
10
|
+
@client = Avod::Client.new(app_id, app_key, master_key)
|
11
|
+
@class_name = 'PP'
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
context "Installions" do
|
16
|
+
it "return Installions list " do
|
17
|
+
@client.get_installations["results"].should_not be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "return install information " do
|
21
|
+
@client.get_install("5253d4cae4b0289ec776bd35")["deviceType"].should_not be_nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "update install information" do
|
25
|
+
data = @client.get_install("5253d4cae4b0289ec776bd35")
|
26
|
+
data["channels"] = ["123","rabbit","cpp", (SecureRandom.hex 2)]
|
27
|
+
@client.update_install("5253d4cae4b0289ec776bd35", data)["updatedAt"].should_not be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path("../../lib/avod.rb", __FILE__)
|
2
|
+
|
3
|
+
describe "avod" do
|
4
|
+
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
app_id = "ty3gmgv4wy39ce0fip38179tr785kwzdxi36s0tjp6c1qlql"
|
8
|
+
app_key = "frul1auqu2qpqayn4bvlfnj8if9cboqdwxzfv9tko6z4rzwk"
|
9
|
+
master_key = "1y91cayb2izmenmifwm9o5th57k2du2ykatxfafdsl36gd69"
|
10
|
+
@client = Avod::Client.new(app_id, app_key, master_key)
|
11
|
+
@class_name = 'PP'
|
12
|
+
end
|
13
|
+
|
14
|
+
context "Test Object" do
|
15
|
+
|
16
|
+
|
17
|
+
it "get all object " do
|
18
|
+
result = @client.get_all_object("PP")
|
19
|
+
result.should be_a_kind_of(Hash)
|
20
|
+
result.length.should be > 0
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it "create object" do
|
25
|
+
object = {mm: 1, xx: "xx"}
|
26
|
+
result = @client.create_object(@class_name, object)
|
27
|
+
result["objectId"].should_not be_nil
|
28
|
+
result["createdAt"].should_not be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "get object " do
|
32
|
+
@client.get_object("PP","525cf2e5e4b0007871b4da21").length.should be > 2
|
33
|
+
end
|
34
|
+
|
35
|
+
it "delete object" do
|
36
|
+
object = {mm: 1, xx: "xx"}
|
37
|
+
result = @client.create_object(@class_name, object)
|
38
|
+
objectId = result["objectId"]
|
39
|
+
@client.delete_object("PP", objectId).should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "update object" do
|
43
|
+
object = {mm: 1, xx: "xx"}
|
44
|
+
result = @client.create_object(@class_name, object)
|
45
|
+
objectId = result["objectId"]
|
46
|
+
object = {mm: 2, xx: "xx"}
|
47
|
+
result = @client.update_object("PP", objectId, object)
|
48
|
+
result = @client.get_object("PP", objectId)
|
49
|
+
result["mm"].should eq(2)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path("../../lib/avod.rb", __FILE__)
|
2
|
+
|
3
|
+
describe "avod" do
|
4
|
+
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
app_id = "ty3gmgv4wy39ce0fip38179tr785kwzdxi36s0tjp6c1qlql"
|
8
|
+
app_key = "frul1auqu2qpqayn4bvlfnj8if9cboqdwxzfv9tko6z4rzwk"
|
9
|
+
master_key = "1y91cayb2izmenmifwm9o5th57k2du2ykatxfafdsl36gd69"
|
10
|
+
@client = Avod::Client.new(app_id, app_key, master_key)
|
11
|
+
@class_name = 'PP'
|
12
|
+
end
|
13
|
+
|
14
|
+
context "Test Object" do
|
15
|
+
|
16
|
+
|
17
|
+
it "get all object " do
|
18
|
+
result = @client.get_all_object("PP")
|
19
|
+
result.should be_a_kind_of(Hash)
|
20
|
+
result.length.should be > 0
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
it "create object" do
|
25
|
+
object = {mm: 1, xx: "xx"}
|
26
|
+
result = @client.create_object(@class_name, object)
|
27
|
+
result["objectId"].should_not be_nil
|
28
|
+
result["createdAt"].should_not be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "get object " do
|
32
|
+
@client.get_object("PP","525cf2e5e4b0007871b4da21").length.should be > 2
|
33
|
+
end
|
34
|
+
|
35
|
+
it "delete object" do
|
36
|
+
object = {mm: 1, xx: "xx"}
|
37
|
+
result = @client.create_object(@class_name, object)
|
38
|
+
objectId = result["objectId"]
|
39
|
+
@client.delete_object("PP", objectId).should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "update object" do
|
43
|
+
object = {mm: 1, xx: "xx"}
|
44
|
+
result = @client.create_object(@class_name, object)
|
45
|
+
objectId = result["objectId"]
|
46
|
+
object = {mm: 2, xx: "xx"}
|
47
|
+
result = @client.update_object("PP", objectId, object)
|
48
|
+
result = @client.get_object("PP", objectId)
|
49
|
+
result["mm"].should eq(2)
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: avod
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Linxiangyu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-06 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: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: avod cloud client
|
70
|
+
email:
|
71
|
+
- lxyweb@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- avod.gemspec
|
83
|
+
- lib/avod.rb
|
84
|
+
- lib/avod/client.rb
|
85
|
+
- lib/avod/version.rb
|
86
|
+
- spec/avod_spec.rb
|
87
|
+
- spec/client_install_spec.rb
|
88
|
+
- spec/client_object_spec.rb
|
89
|
+
- spec/client_user_spec.rb
|
90
|
+
homepage: https://github.com/oa414/avod-ruby
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.1.10
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: avod cloud client
|
114
|
+
test_files:
|
115
|
+
- spec/avod_spec.rb
|
116
|
+
- spec/client_install_spec.rb
|
117
|
+
- spec/client_object_spec.rb
|
118
|
+
- spec/client_user_spec.rb
|
119
|
+
has_rdoc:
|