An unofficial, mostly Bitwarden-compatible API server written in Ruby (Sinatra and ActiveRecord)
1module Rubywarden
2 module Test
3 module RequestHelpers
4 def last_json_response
5 JSON.parse(last_response.body)
6 end
7
8 def get_json(path, params = {}, headers = {})
9 json_request :get, path, params, headers
10 end
11
12 def post_json(path, params = {}, headers = {})
13 json_request :post, path, params, headers
14 end
15
16 def put_json(path, params = {}, headers = {})
17 json_request :put, path, params, headers
18 end
19
20 def delete_json(path, params = {}, headers = {})
21 json_request :delete, path, params, headers
22 end
23
24 def json_request(verb, path, params = {}, headers = {})
25 send verb, path, params.to_json,
26 headers.merge({ "CONTENT_TYPE" => "application/json" })
27 end
28 end
29 end
30end