/
api.rb
70 lines (62 loc) · 1.63 KB
/
api.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
Application.class_eval do
post '/categories.json' do
ABPlugin::API.create_category(
:name => params[:name],
:site_id => params[:site_id],
:token => current_user.single_access_token
).to_json
end
delete '/categories.json' do
ABPlugin::API.delete_category(
:name => params[:name],
:token => current_user.single_access_token
).to_json
end
post '/envs.json' do
ABPlugin::API.create_env(
:name => params[:name],
:site_id => params[:site_id],
:token => current_user.single_access_token
).to_json
end
delete '/envs.json' do
ABPlugin::API.delete_env(
:name => params[:name],
:token => current_user.single_access_token
).to_json
end
delete '/sites.json' do
ABPlugin::API.delete_site(
:name => params[:name],
:token => current_user.single_access_token
).to_json
end
post '/sites.json' do
ABPlugin::API.create_site(
:include => params[:include],
:name => params[:name],
:only => params[:only],
:token => current_user.single_access_token
).to_json
end
post '/tests.json' do
ABPlugin::API.create_test(
:category => params[:category],
:include => params[:include] || {
:variants => {
:methods => :for_dashboard
}
},
:name => params[:name],
:only => params[:only],
:token => current_user.single_access_token,
:variants => params[:variants]
).to_json
end
delete '/tests.json' do
ABPlugin::API.delete_test(
:id => params[:id],
:token => current_user.single_access_token
).to_json
end
end