Class: Mailgun::Tags
- Inherits:
-
Object
- Object
- Mailgun::Tags
- Defined in:
- lib/mailgun/tags/tags.rb
Overview
A Mailgun::Tags object is a simple CRUD interface to Mailgun Tags. Uses Mailgun
Instance Method Summary collapse
-
#get_countries_aggregated_stats(domain, tag) ⇒ Object
Public: Get a list of countries of origin for a given domain for different event types.
-
#get_devices_aggregated_stats(domain, tag) ⇒ Object
Public: Get a list of devices for a given domain that have triggered event types.
-
#get_providers_aggregated_stats(domain, tag) ⇒ Object
Public: Get a list of email providers for a given domain for different event types.
-
#get_tag(domain, tag) ⇒ Object
Public: Get tag information.
-
#get_tag_stats(domain, tag, options = {}) ⇒ Object
Public: Get statistics for a given tag.
-
#get_tags(domain, options = {}) ⇒ Object
Public: Get Tags.
-
#initialize(client = Mailgun::Client.new) ⇒ Tags
constructor
Public: creates a new Mailgun::Tags instance.
-
#remove(domain, tag) ⇒ Object
Public: Delete Tag NOTE: Deletes the tag.
-
#update(domain, tag, options = {}) ⇒ Object
Public: Updates a given tag with the information provided.
Constructor Details
Instance Method Details
#get_countries_aggregated_stats(domain, tag) ⇒ Object
Public: Get a list of countries of origin for a given domain for different event types.
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for
Returns [Hash] of countries of origin for a given domain
103 104 105 106 107 108 109 |
# File 'lib/mailgun/tags/tags.rb', line 103 def get_countries_aggregated_stats(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to find on Mailgun', caller) unless domain raise(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.get("#{domain}/tags/#{tag}/stats/aggregates/countries").to_h end |
#get_devices_aggregated_stats(domain, tag) ⇒ Object
Public: Get a list of devices for a given domain that have triggered event types.
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for
Returns [Hash] of devices for a given domain
131 132 133 134 135 136 137 |
# File 'lib/mailgun/tags/tags.rb', line 131 def get_devices_aggregated_stats(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to find on Mailgun', caller) unless domain raise(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.get("#{domain}/tags/#{tag}/stats/aggregates/devices").to_h end |
#get_providers_aggregated_stats(domain, tag) ⇒ Object
Public: Get a list of email providers for a given domain for different event types
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for
Returns [Hash] of email providers for a given domain
117 118 119 120 121 122 123 |
# File 'lib/mailgun/tags/tags.rb', line 117 def get_providers_aggregated_stats(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to find on Mailgun', caller) unless domain raise(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.get("#{domain}/tags/#{tag}/stats/aggregates/providers").to_h end |
#get_tag(domain, tag) ⇒ Object
Public: Get tag information
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for
Returns [Hash] Information on the requested tag.
36 37 38 39 40 41 42 |
# File 'lib/mailgun/tags/tags.rb', line 36 def get_tag(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to find on Mailgun', caller) unless domain raise(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.get("#{domain}/tags/#{tag}").to_h! end |
#get_tag_stats(domain, tag, options = {}) ⇒ Object
Public: Get statistics for a given tag
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for options - [Hash] of
event - [String] The type of the event. Required. (ex. accepted, delivered, failed, opened)
start - [String] The starting time. Should be in RFC 282 or unix epoch format.
Default: 7 days from the current time.
end - [String] The ending date. Should be in RFC 2822 or unix epoch time in seconds. Default: current time.
resolution - [String] Can be either hour, day or month. Default: day
duration - [String] Period of time with resolution encoded.
If provided, overwrites the start date and resolution.
Returns [Hash] of tag stats info
74 75 76 77 78 79 80 |
# File 'lib/mailgun/tags/tags.rb', line 74 def get_tag_stats(domain, tag, = {}) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to find on Mailgun', caller) unless domain raise(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.get("#{domain}/tags/#{tag}/stats", ).to_h end |
#get_tags(domain, options = {}) ⇒ Object
Public: Get Tags
domain - [String] Domain name where tag is stored options - [Hash] of
limit - [Integer] Number of entries to return. Default: 100.
Returns [Array] A list of tags (hash)
23 24 25 26 27 28 |
# File 'lib/mailgun/tags/tags.rb', line 23 def (domain, = {}) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to store template on', caller) unless domain @client.get("#{domain}/tags", ).to_h['items'] end |
#remove(domain, tag) ⇒ Object
Public: Delete Tag NOTE: Deletes the tag. Note: The statistics for the tag are not destroyed.
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for
Returns [Boolean] if successful or not
89 90 91 92 93 94 95 |
# File 'lib/mailgun/tags/tags.rb', line 89 def remove(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to remove on Mailgun', caller) unless domain raise(ParameterError, 'No template name given to find on provided domain', caller) unless tag @client.delete("#{domain}/tags/#{tag}").to_h['message'] == 'Tag deleted' end |
#update(domain, tag, options = {}) ⇒ Object
Public: Updates a given tag with the information provided
domain - [String] Domain name where tag is stored tag - [String] Tag name to lookup for options - [Hash] of
description - [String] Updated description of the tag
Returns [Boolean] if successful or not
52 53 54 55 56 57 58 |
# File 'lib/mailgun/tags/tags.rb', line 52 def update(domain, tag, = {}) warn('This API is deprecated in favor of our new analytics Tags API') raise(ParameterError, 'No domain given to find on Mailgun', caller) unless domain raise(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.put("#{domain}/tags/#{tag}", ).to_h['message'] == 'Tag updated' end |