Class: Rapidmail::Resources::Mailing

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

Overview

Resource class for managing mailings.

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

#activity(id) ⇒ Faraday::Response

Retrieves the activity stats for a mailing by ID.

Parameters:

  • id (String)

    The ID of the mailing.

Returns:

  • (Faraday::Response)

    The response from the API.



65
66
67
# File 'lib/rapidmail/resources/mailing.rb', line 65

def activity(id)
  get("#{resource_path}/#{id}/stats/activity")
end

#anonymize(id) ⇒ Faraday::Response

Anonymizes the stats for a mailing by ID.

Parameters:

  • id (String)

    The ID of the mailing.

Returns:

  • (Faraday::Response)

    The response from the API.



57
58
59
# File 'lib/rapidmail/resources/mailing.rb', line 57

def anonymize(id)
  put("#{resource_path}/#{id}/stats/anonymize")
end

#cancel(id) ⇒ Faraday::Response

Cancels a mailing by ID.

Parameters:

  • id (String)

    The ID of the mailing to cancel.

Returns:

  • (Faraday::Response)

    The response from the API.



41
42
43
# File 'lib/rapidmail/resources/mailing.rb', line 41

def cancel(id)
  post("#{resource_path}/#{id}/cancel")
end

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

Creates a new mailing.

Parameters:

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

    The parameters for creating a mailing.

Returns:

  • (Faraday::Response)

    The response from the API.



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

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

#destroy(id) ⇒ Faraday::Response

Deletes a mailing by ID.

Parameters:

  • id (String)

    The ID of the mailing to delete.

Returns:

  • (Faraday::Response)

    The response from the API.



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

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

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

Lists all mailings with optional filters.

Parameters:

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

    Optional filters for listing mailings.

Returns:

  • (Faraday::Response)

    The response from the API.



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

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

#pause(id) ⇒ Faraday::Response

Pauses a mailing by ID.

Parameters:

  • id (String)

    The ID of the mailing to pause.

Returns:

  • (Faraday::Response)

    The response from the API.



33
34
35
# File 'lib/rapidmail/resources/mailing.rb', line 33

def pause(id)
  post("#{resource_path}/#{id}/pause")
end

#recipient_activity(id, recipient_id) ⇒ Faraday::Response

Retrieves the activity stats for a specific recipient in a mailing by IDs.

Parameters:

  • id (String)

    The ID of the mailing.

  • recipient_id (String)

    The ID of the recipient.

Returns:

  • (Faraday::Response)

    The response from the API.



74
75
76
# File 'lib/rapidmail/resources/mailing.rb', line 74

def recipient_activity(id, recipient_id)
  get("#{resource_path}/#{id}/stats/activity/#{recipient_id}")
end

#stats(id) ⇒ Faraday::Response

Retrieves the stats for a mailing by ID.

Parameters:

  • id (String)

    The ID of the mailing.

Returns:

  • (Faraday::Response)

    The response from the API.



49
50
51
# File 'lib/rapidmail/resources/mailing.rb', line 49

def stats(id)
  get("#{resource_path}/#{id}/stats")
end