class Apitool::Client::ApiKey < Apitool::Client::ApitoolClient # ApiKey # # { # :api_key => { # :id => NUMERIC, # :token => "TOKEN", # :roles=>[ # { # :role => { # :id => 1, # :name=>"master" # } # }, # { # :role => { # :id => 2, # :name=>"admin" # } # }, # { # :role => { # :id => 3, # :name=>"user" # } # } # ] # } # } def index get('/api_keys') do |response, request, result| if response.code == 200 parse(response) else nil end end end def show(token) get("/api_keys/#{token}") do |response| if response.code == 200 parse(response) else nil end end end # roles = 3 # roles = [3] # roles = [1, 2, 3] def create(roles = 3) parameters = { api_key: { role_ids: [roles].flatten } } post("/api_keys", parameters) do |response| if response.code == 200 parse(response) else nil end end end def update(token, roles = 3) parameters = { api_key: { role_ids: [roles].flatten } } put("/api_keys/#{token}", parameters) do |response| if response.code == 200 parse(response) else nil end end end def destroy(token) delete("/api_keys/#{token}") do |response| if response.code == 200 parse(response) else nil end end end end