Module: StrawberryAPI::Client::ApiKeys
- Included in:
- StrawberryAPI::Client
- Defined in:
- lib/strawberry_api/client/api_keys.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#id ⇒ Object
Returns the value of attribute id.
-
#key ⇒ Object
Returns the value of attribute key.
-
#name ⇒ Object
Returns the value of attribute name.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#user_id ⇒ Object
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#api_key(user_id:) ⇒ Array<StrawberryAPI::ApiKey>
Fetches user API keys.
-
#create_api_key(user_id:, name:) ⇒ ApiKey
Creates user API key.
-
#delete_api_key(user_id:, api_key_id:) ⇒ Boolean
Deletes user API key.
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at
9 10 11 |
# File 'lib/strawberry_api/client/api_keys.rb', line 9 def created_at @created_at end |
#id ⇒ Object
Returns the value of attribute id
5 6 7 |
# File 'lib/strawberry_api/client/api_keys.rb', line 5 def id @id end |
#key ⇒ Object
Returns the value of attribute key
8 9 10 |
# File 'lib/strawberry_api/client/api_keys.rb', line 8 def key @key end |
#name ⇒ Object
Returns the value of attribute name
7 8 9 |
# File 'lib/strawberry_api/client/api_keys.rb', line 7 def name @name end |
#updated_at ⇒ Object
Returns the value of attribute updated_at
10 11 12 |
# File 'lib/strawberry_api/client/api_keys.rb', line 10 def updated_at @updated_at end |
#user_id ⇒ Object
Returns the value of attribute user_id
6 7 8 |
# File 'lib/strawberry_api/client/api_keys.rb', line 6 def user_id @user_id end |
Instance Method Details
#api_key(user_id:) ⇒ Array<StrawberryAPI::ApiKey>
Fetches user API keys
18 19 20 21 22 |
# File 'lib/strawberry_api/client/api_keys.rb', line 18 def api_key(user_id:) get("/users/#{user_id}/api_keys").parse['api_keys']&.map do |api_key| ApiKey.new(api_key) end end |
#create_api_key(user_id:, name:) ⇒ ApiKey
Creates user API key
31 32 33 34 |
# File 'lib/strawberry_api/client/api_keys.rb', line 31 def create_api_key(user_id:, name:) data = post("/users/#{user_id}/api_keys", body: {name: name}.to_json).parse['api_key'] data.nil? ? nil : ApiKey.new(data) end |
#delete_api_key(user_id:, api_key_id:) ⇒ Boolean
Deletes user API key
43 44 45 |
# File 'lib/strawberry_api/client/api_keys.rb', line 43 def delete_api_key(user_id:, api_key_id:) delete("/users/#{user_id}/api_keys/#{api_key_id}").success? end |