Module: PatchRetention::Contacts::Find

Extended by:
Find
Includes:
Util
Included in:
Find
Defined in:
lib/patch_retention/contacts/find.rb

Overview

The PatchRetention::Contacts::Find module provides methods to find contacts in the PatchRetention system. It includes methods to find a contact by ID and to retrieve all contacts with pagination.

Examples:

Finding a contact by ID

PatchRetention::Contacts::Find.by_id(123)

Retrieving all contacts with pagination

PatchRetention::Contacts::Find.all(10, 0)

Instance Method Summary collapse

Methods included from Util

#parse_error_message, #raise_error_if_present

Instance Method Details

#all(limit:, offset:, email: nil, config: nil) ⇒ Object

Retrieves all contacts with pagination.

Parameters:

  • limit (Integer)

    The number of contacts to retrieve per page.

  • offset (Integer)

    The number of contacts to skip before starting to collect the result set.

  • email (String) (defaults to: nil)

    Optional email to filter contacts by.

  • config (Configuration) (defaults to: nil)

    Optional configuration object.

Returns:

  • (Object)

    The response from the PatchRetention API.

Raises:



36
37
38
39
40
41
42
43
44
# File 'lib/patch_retention/contacts/find.rb', line 36

def all(limit:, offset:, email: nil, config: nil)
  raise_error_if_present do
    PatchRetention.connection(config).get(PatchRetention::Contacts::API_PATH) do |req|
      req.params["limit"] = limit
      req.params["offset"] = offset
      req.params["email"] = email if email
    end
  end
end

#by_id(id, config = nil) ⇒ Object

Finds a contact by its ID.

Parameters:

  • id (Integer)

    The ID of the contact to find.

Returns:

  • (Object)

    The response from the PatchRetention API.

Raises:



22
23
24
25
26
# File 'lib/patch_retention/contacts/find.rb', line 22

def by_id(id, config = nil)
  raise_error_if_present do
    PatchRetention.connection(config).get("#{PatchRetention::Contacts::API_PATH}/#{id}")
  end
end