Class: Sendara::Resources::ApiKeys

Inherits:
Sendara::Resource show all
Defined in:
lib/sendara/resources/api_keys.rb

Instance Method Summary collapse

Methods inherited from Sendara::Resource

#initialize

Constructor Details

This class inherits a constructor from Sendara::Resource

Instance Method Details

#create(scope: nil, test_mode: nil) ⇒ Object



12
13
14
15
# File 'lib/sendara/resources/api_keys.rb', line 12

def create(scope: nil, test_mode: nil)
  body = compact_params("scope" => scope, "test_mode" => test_mode)
  request(:post, "/v1/keys", body: body) || {}
end

#listObject



6
7
8
9
10
# File 'lib/sendara/resources/api_keys.rb', line 6

def list
  response = request(:get, "/v1/keys") || {}
  keys = response["keys"]
  keys.is_a?(Array) ? keys : []
end

#revoke(id) ⇒ Object



22
23
24
25
# File 'lib/sendara/resources/api_keys.rb', line 22

def revoke(id)
  request(:delete, "/v1/keys/#{encode(id)}")
  nil
end

#rotate(id) ⇒ Object



17
18
19
20
# File 'lib/sendara/resources/api_keys.rb', line 17

def rotate(id)
  response = request(:post, "/v1/keys/#{encode(id)}/rotate") || {}
  response["key"].to_s
end