Class: Rapidmail::Resources::Recipient

Inherits:
Base
  • Object
show all
Defined in:
lib/rapidmail/resources/recipient.rb

Overview

Resource class for managing recipients.

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#find, #initialize

Constructor Details

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

Instance Method Details

#create(params = {}) ⇒ Faraday::Response

Creates a new recipient.

Parameters:

  • params (Hash) (defaults to: {})

    The parameters for creating a recipient.

Returns:

  • (Faraday::Response)

    The response from the API.



17
18
19
# File 'lib/rapidmail/resources/recipient.rb', line 17

def create(params = {})
  post(resource_path, params)
end

#destroy(id) ⇒ Faraday::Response

Deletes a recipient by ID.

Parameters:

  • id (String)

    The ID of the recipient to delete.

Returns:

  • (Faraday::Response)

    The response from the API.



25
26
27
# File 'lib/rapidmail/resources/recipient.rb', line 25

def destroy(id)
  delete("#{resource_path}/#{id}")
end

#import(params = {}) ⇒ Faraday::Response

Imports recipients.

Parameters:

  • params (Hash) (defaults to: {})

    The parameters for importing recipients.

Returns:

  • (Faraday::Response)

    The response from the API.



42
43
44
# File 'lib/rapidmail/resources/recipient.rb', line 42

def import(params = {})
  post("#{resource_path}/import", params)
end

#list(params = {}) ⇒ Faraday::Response

Lists all recipients with optional filters.

Parameters:

  • params (Hash) (defaults to: {})

    Optional filters for listing recipients.

Returns:

  • (Faraday::Response)

    The response from the API.



9
10
11
# File 'lib/rapidmail/resources/recipient.rb', line 9

def list(params = {})
  get(resource_path, params)
end

#update(id, params = {}) ⇒ Faraday::Response

Updates a recipient by ID.

Parameters:

  • id (String)

    The ID of the recipient to update.

  • params (Hash) (defaults to: {})

    The parameters for updating the recipient.

Returns:

  • (Faraday::Response)

    The response from the API.



34
35
36
# File 'lib/rapidmail/resources/recipient.rb', line 34

def update(id, params = {})
  patch("#{resource_path}/#{id}", params)
end