Class: Sendgrid::Web::Credentials

Inherits:
Client
  • Object
show all
Defined in:
lib/sendgrid/web/credentials.rb

Instance Method Summary collapse

Methods inherited from Client

base_uri, config, #config, configure

Instance Method Details

#add(username: nil, password: nil, permissions: nil) ⇒ Sendgrid::Web::Response

Note:

Requires username and password.

This API call allows user to add a new set of credentials to their account.

Parameters:

  • username (String) (defaults to: nil)

    Enter a username for the new account.

  • password (String) (defaults to: nil)

    Enter a password for the new account.

  • permissions (Hash) (defaults to: nil)

    There are three key names: email for access to SMTP, api for programmatic access, and web for administration. The values for each are a bit, 0 for off or 1 for on.

    The following example allows the specified username/password to log into the dashboard, but not send email or have access to any of the APIs:

    { email: 0, web: 1, api: 0 }
    

Returns:

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
43
44
45
# File 'lib/sendgrid/web/credentials.rb', line 35

def add(username: nil, password: nil, permissions: nil)
  raise ArgumentError.new('Missing required `username` option') if username.nil?
  raise ArgumentError.new('Missing required `password` option') if password.nil?
  res = connection.post(
    '/api/credentials/add.json',
    default_params(
      username: username,
      password: password,
      permissions: permissions))
  craft_response(res)
end

#delete(username: nil) ⇒ Sendgrid::Web::Response

Note:

username is required.

Remove an individuals credentials.

Parameters:

  • username (String) (defaults to: nil)

    The credential to remove.

Returns:

Raises:

  • (ArgumentError)


71
72
73
74
75
76
77
78
# File 'lib/sendgrid/web/credentials.rb', line 71

def delete(username: nil)
  raise ArgumentError.new('Missing required `username` option') if username.nil?
  res = connection.post(
    '/api/credentials/delete.json',
    default_params(
      username: username))
  craft_response(res)
end

#edit(username: nil, password: nil, permissions: nil) ⇒ Sendgrid::Web::Response

Note:

Only username is required.

Update/edit a users credentials and permissions.

Parameters:

  • username (String) (defaults to: nil)

    The existing users username.

  • password (String) (defaults to: nil)

    Optionally update the password.

  • permissions (Hash) (defaults to: nil)

    Optionally update the permissions.

Returns:

Raises:

  • (ArgumentError)

See Also:



55
56
57
58
59
60
61
62
63
64
# File 'lib/sendgrid/web/credentials.rb', line 55

def edit(username: nil, password: nil, permissions: nil)
  raise ArgumentError.new('Missing required `username` option') if username.nil?
  res = connection.post(
    '/api/credentials/edit.json',
    default_params(
      username: username,
      password: password,
      permissions: permissions))
  craft_response(res)
end

#get(username: nil) ⇒ Sendgrid::Web::Response

Note:

All parameters are optional

Retrieve a list of all credentials, or permissions for a specific credential.

Parameters:

  • username (String) (defaults to: nil)

    If a username is supplied, the API returns the JSON permissions for that user.

Returns:



10
11
12
13
14
15
# File 'lib/sendgrid/web/credentials.rb', line 10

def get(username: nil)
  res = connection.post(
    '/api/credentials/get.json',
    default_params(username: username))
  craft_response(res)
end