Class: Sendgrid::Web::Blocks

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

Instance Method Summary collapse

Methods inherited from Client

base_uri, config, #config, configure

Instance Method Details

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

Deletes all blocks associated with the provided email

Parameters:

  • email (String) (defaults to: nil)

    Email block address to remove

Returns:



38
39
40
41
42
43
44
45
46
# File 'lib/sendgrid/web/blocks.rb', line 38

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

#get(date: nil, days: nil, start_date: nil, end_date: nil, limit: nil, offset: nil) ⇒ Sendgrid::Web::Response

Note:

All parameters are optional

Retrieves a list of all blocked email addresses along with the reason why they are blocked.

Parameters:

  • date (Integer) (defaults to: nil)

    Retrieve the timestamp of the Block records.

  • days (Integer) (defaults to: nil)

    Number of days in the past for which to retrieve blocks (includes today)

  • start_date (DateTime) (defaults to: nil)

    The start of the date range for which to retrieve blocks.

  • end_date (DateTime) (defaults to: nil)

    The end of the date range for which to retrieve blocks.

  • limit (Integer) (defaults to: nil)

    Optional field to limit the number of results returned.

  • offset (Integer) (defaults to: nil)

    Optional beginning point in the list to retrieve from.

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sendgrid/web/blocks.rb', line 19

def get(
  date: nil, days: nil, start_date: nil,
  end_date: nil, limit: nil, offset: nil)
  res = connection.post(
    '/api/blocks.get.json',
    default_params(
      date: date,
      days: days,
      start_date: start_date,
      end_date: end_date,
      limit: limit,
      offset: offset))
  craft_response(res)
end