Class: Apitool::Client::ApiKey
- Inherits:
-
ApitoolClient
- Object
- ApitoolClient
- Apitool::Client::ApiKey
- Defined in:
- lib/apitool/client/api_key.rb
Instance Method Summary collapse
-
#create(roles = 3) ⇒ Object
roles = 3 roles = [3] roles = [1, 2, 3].
- #destroy(token) ⇒ Object
-
#index ⇒ Object
ApiKey.
- #show(token) ⇒ Object
- #update(token, roles = 3) ⇒ Object
Methods inherited from ApitoolClient
#errors, #initialize, #request, #response, #result
Constructor Details
This class inherits a constructor from Apitool::Client::ApitoolClient
Instance Method Details
#create(roles = 3) ⇒ Object
roles = 3 roles = [3] roles = [1, 2, 3]
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/apitool/client/api_key.rb', line 55 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 |
#destroy(token) ⇒ Object
85 86 87 88 89 90 91 92 93 |
# File 'lib/apitool/client/api_key.rb', line 85 def destroy(token) delete("/api_keys/#{token}") do |response| if response.code == 200 parse(response) else nil end end end |
#index ⇒ Object
ApiKey
{
:api_key => {
:id => NUMERIC,
:token => "TOKEN",
:roles=>[
{
:role => {
:id => 1,
:name=>"master"
}
},
{
:role => {
:id => 2,
:name=>"admin"
}
},
{
:role => {
:id => 3,
:name=>"user"
}
}
]
}
}
32 33 34 35 36 37 38 39 40 |
# File 'lib/apitool/client/api_key.rb', line 32 def index get('/api_keys') do |response, request, result| if response.code == 200 parse(response) else nil end end end |
#show(token) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/apitool/client/api_key.rb', line 42 def show(token) get("/api_keys/#{token}") do |response| if response.code == 200 parse(response) else nil end end end |
#update(token, roles = 3) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/apitool/client/api_key.rb', line 70 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 |