Class: Dinie::Resources::Credentials
- Inherits:
-
Object
- Object
- Dinie::Resources::Credentials
- Defined in:
- lib/dinie/generated/resources/credentials.rb
Overview
Operations on the credentials resource.
Instance Method Summary collapse
-
#create(request_options: {}, **fields) ⇒ Object
Create a new API key.
-
#initialize(http) ⇒ Credentials
constructor
A new instance of Credentials.
-
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) ⇒ Object
List API keys.
-
#revoke(client_id, request_options: {}) ⇒ Object
Revoke an API key.
Constructor Details
#initialize(http) ⇒ Credentials
Returns a new instance of Credentials.
10 11 12 |
# File 'lib/dinie/generated/resources/credentials.rb', line 10 def initialize(http) @http = http end |
Instance Method Details
#create(request_options: {}, **fields) ⇒ Object
Create a new API key
Create a new credential pair; the ‘client_secret` is shown only once in the response
21 22 23 24 25 |
# File 'lib/dinie/generated/resources/credentials.rb', line 21 def create(request_options: {}, **fields) body = Credential.serialize_create(**fields) raw = @http.request(method: :post, path: "/auth/credentials", body:, request_options:) CredentialWithSecret.deserialize(raw) end |
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) ⇒ Object
List API keys
Return all API credentials for the authenticated partner
33 34 35 36 37 38 39 40 41 |
# File 'lib/dinie/generated/resources/credentials.rb', line 33 def list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) fetch_page = lambda do |cursor| query = { limit:, starting_after: cursor || starting_after } .reject { |_key, value| Internal.omitted?(value) } body = @http.request(method: :get, path: "/auth/credentials", query:, request_options:) { data: body[:data].map { |raw| Credential.deserialize(raw) }, has_more: body[:has_more] } end Dinie::Page.from_fetch(fetch_page) end |
#revoke(client_id, request_options: {}) ⇒ Object
Revoke an API key
Immediately and permanently revoke an API credential
50 51 52 53 |
# File 'lib/dinie/generated/resources/credentials.rb', line 50 def revoke(client_id, request_options: {}) @http.request(method: :delete, path: "/auth/credentials/#{client_id}", request_options:) nil end |