module SendGrid4r::REST::ApiKeysManagement
SendGrid Web API
v3 ApiKeysManagement
SendGrid Web API
v3 ApiKeysManagement
Constants
- ApiKey
- ApiKeys
Public Class Methods
create_api_key(resp)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 26 def self.create_api_key(resp) return resp if resp.nil? ApiKey.new( resp['name'], resp['api_key_id'], resp['api_key'], resp['scopes'] ) end
create_api_keys(resp)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 18 def self.create_api_keys(resp) return resp if resp.nil? api_keys = resp['result'].map do |api_key| ApiKeysManagement.create_api_key(api_key) end ApiKeys.new(api_keys) end
url(api_key_id = nil)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 12 def self.url(api_key_id = nil) url = "#{BASE_URL}/api_keys" url = "#{url}/#{api_key_id}" unless api_key_id.nil? url end
Public Instance Methods
delete_api_key(api_key_id:, &block)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 54 def delete_api_key(api_key_id:, &block) delete(@auth, ApiKeysManagement.url(api_key_id), &block) end
get_api_key(api_key_id:, &block)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 48 def get_api_key(api_key_id:, &block) endpoint = ApiKeysManagement.url(api_key_id) resp = get(@auth, endpoint, &block) finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) } end
get_api_keys(&block)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 36 def get_api_keys(&block) resp = get(@auth, ApiKeysManagement.url, &block) finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_keys(r) } end
patch_api_key(api_key_id:, name:, &block)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 58 def patch_api_key(api_key_id:, name:, &block) params = { name: name } endpoint = ApiKeysManagement.url(api_key_id) resp = patch(@auth, endpoint, params, &block) finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) } end
post_api_key(name:, scopes: nil, &block)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 41 def post_api_key(name:, scopes: nil, &block) params = { name: name } params[:scopes] = scopes unless scopes.nil? resp = post(@auth, ApiKeysManagement.url, params, &block) finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) } end
put_api_key(api_key_id:, name:, scopes:, &block)
click to toggle source
# File lib/sendgrid4r/rest/api_keys_management/api_keys.rb, line 65 def put_api_key(api_key_id:, name:, scopes:, &block) params = {} params[:name] = name unless name.nil? params[:scopes] = scopes unless scopes.nil? endpoint = ApiKeysManagement.url(api_key_id) resp = put(@auth, endpoint, params, &block) finish(resp, @raw_resp) { |r| ApiKeysManagement.create_api_key(r) } end