Class: Mailfloss::Resources::Keywords

Inherits:
Base
  • Object
show all
Defined in:
lib/mailfloss/resources.rb,
sig/resources.rbs

Overview

/integrations/type/connections/id/keywords/#list*

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#encode, #initialize

Constructor Details

This class inherits a constructor from Mailfloss::Resources::Base

Instance Method Details

#add(type, id, list, rules:, idempotency_key: nil) ⇒ Hash

POST .../keywords/#list — add keyword rules (1-1000, all-or-nothing).

Parameters:

  • rules (Array<Hash>)

    each { keyword:, match: "exact"|"contains", applies_to: { localpart:, domain:, email: } }

Returns:

  • (Hash)

    { data: [Rule] } — the created rules with ids



261
262
263
264
# File 'lib/mailfloss/resources.rb', line 261

def add(type, id, list, rules:, idempotency_key: nil)
  client.request(:post, keywords_path(type, id, list),
                 body: { rules: rules }, idempotency_key: idempotency_key)
end

#delete(type, id, list, rule_id) ⇒ Hash

DELETE .../keywords/#list/ruleId — remove a keyword rule.

Parameters:

  • type (String)
  • id (String)
  • list (String)
  • rule_id (String)

Returns:

  • (Hash)

    { deleted:, id: }



269
270
271
# File 'lib/mailfloss/resources.rb', line 269

def delete(type, id, list, rule_id)
  client.request(:delete, "#{keywords_path(type, id, list)}/#{encode(rule_id)}")
end

#keywords_path(type, id, list) ⇒ String

Parameters:

  • type (String)
  • id (String)
  • list (String)

Returns:

  • (String)


275
276
277
# File 'lib/mailfloss/resources.rb', line 275

def keywords_path(type, id, list)
  "/integrations/#{encode(type)}/connections/#{encode(id)}/keywords/#{encode(list)}"
end

#list(type, id, list, per_page: nil, cursor: nil) ⇒ Hash

GET .../keywords/#list — list keyword rules (blacklist or whitelist).

Parameters:

  • list (String)

    "blacklist" or "whitelist"

Returns:

  • (Hash)

    { data: [Rule], pagination: { next_cursor:, has_more: } }



251
252
253
254
# File 'lib/mailfloss/resources.rb', line 251

def list(type, id, list, per_page: nil, cursor: nil)
  client.request(:get, keywords_path(type, id, list),
                 query: { per_page: per_page, cursor: cursor })
end