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.

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.

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.

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.



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