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
96 97 98 99 100 101 |
# File 'lib/mailgun/tags/tags.rb', line 96 def get_countries_aggregated_stats(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain fail(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
122 123 124 125 126 127 |
# File 'lib/mailgun/tags/tags.rb', line 122 def get_devices_aggregated_stats(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain fail(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
109 110 111 112 113 114 |
# File 'lib/mailgun/tags/tags.rb', line 109 def get_providers_aggregated_stats(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain fail(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.
35 36 37 38 39 40 |
# File 'lib/mailgun/tags/tags.rb', line 35 def get_tag(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain fail(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
69 70 71 72 73 74 |
# File 'lib/mailgun/tags/tags.rb', line 69 def get_tag_stats(domain, tag, = {}) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain fail(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 |
# File 'lib/mailgun/tags/tags.rb', line 23 def (domain, = {}) warn('This API is deprecated in favor of our new analytics Tags API') fail(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
83 84 85 86 87 88 |
# File 'lib/mailgun/tags/tags.rb', line 83 def remove(domain, tag) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to remove on Mailgun', caller) unless domain fail(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
50 51 52 53 54 55 |
# File 'lib/mailgun/tags/tags.rb', line 50 def update(domain, tag, = {}) warn('This API is deprecated in favor of our new analytics Tags API') fail(ParameterError, 'No domain given to find on Mailgun', caller) unless domain fail(ParameterError, 'No tag name given to find on provided domain', caller) unless tag @client.put("#{domain}/tags/#{tag}", ).to_h['message'] == 'Tag updated' end |