class Vonage::Secrets

Public Instance Methods

create(params) click to toggle source

Create API Secret.

@example

response = client.secrets.create(secret: 'T0ps3cr3t')

@option params [required, String] :secret

The new secret must follow these rules:
- minimum 8 characters
- maximum 25 characters
- minimum 1 lower case character
- minimum 1 upper case character
- minimum 1 digit

@param [Hash] params

@return [Response]

@see developer.nexmo.com/api/account#createAPISecret

# File lib/vonage/secrets.rb, line 29
def create(params)
  request('/accounts/' + account_id + '/secrets', params: params, type: Post)
end
get(secret_id) click to toggle source

Retrieve one API Secret.

@example

response = client.secrets.get(secret_id)

@param [String] secret_id

@return [Response]

@see developer.nexmo.com/api/account#retrieveAPISecret

# File lib/vonage/secrets.rb, line 64
def get(secret_id)
  request('/accounts/' + account_id + '/secrets/' + secret_id)
end
list(params = nil, auto_advance = true) click to toggle source

Retrieve API Secrets.

@example

response = client.secrets.list
response.each do |item|
  puts "#{item.created_at} #{item.id}"
end

@option params [Boolean] :auto_advance

Set this to `false` to not auto-advance through all the pages in the record
and collect all the data. The default is `true`.

@return [ListResponse]

@see developer.nexmo.com/api/account#retrieveAPISecrets

# File lib/vonage/secrets.rb, line 49
def list(params = nil, auto_advance = true)
  request('/accounts/' + account_id + '/secrets', params: params, response_class: ListResponse)
end
revoke(secret_id) click to toggle source

Revoke an API Secret.

@example

response = client.secrets.revoke(secret_id)

@param [String] secret_id

@return [Response]

@see developer.nexmo.com/api/account#revokeAPISecret

# File lib/vonage/secrets.rb, line 79
def revoke(secret_id)
  request('/accounts/' + account_id + '/secrets/' + secret_id, type: Delete)
end

Private Instance Methods

account_id() click to toggle source
# File lib/vonage/secrets.rb, line 85
def account_id
  @config.api_key
end