Class: Tomba::Flag

Inherits:
Service show all
Defined in:
lib/tomba/services/flag.rb

Overview

Flag service for managing email flags.

Provides methods to list and create flags for email addresses.

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Tomba::Service

Instance Method Details

#create_flag(email:, reason: nil) ⇒ Hash

Create Flag

Creates a new flag for an email address.

Parameters:

  • email (String)

    the email address to flag

  • reason (String, nil) (defaults to: nil)

    optional reason for the flag

Returns:

  • (Hash)

    API response containing the created flag

Raises:

See Also:



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tomba/services/flag.rb', line 40

def create_flag(email:, reason: nil)
  raise Tomba::Exception, 'Missing required parameter: "email"' if email.nil?

  path = '/flags'

  params = { email: email }
  params[:reason] = reason unless reason.nil?

  @client.call('post', path, {
                 'content-type' => 'application/json'
               }, params)
end

#list_flags(page: nil, limit: nil) ⇒ Hash

List Flags

Returns all flags associated with the account.

Parameters:

  • page (Integer, nil) (defaults to: nil)

    the page number for pagination

  • limit (Integer, nil) (defaults to: nil)

    the number of results per page

Returns:

  • (Hash)

    API response containing the list of flags

Raises:

See Also:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tomba/services/flag.rb', line 19

def list_flags(page: nil, limit: nil)
  path = '/flags'

  params = {}
  params[:page] = page unless page.nil?
  params[:limit] = limit unless limit.nil?

  @client.call('get', path, {
                 'content-type' => 'application/json'
               }, params)
end