Class: Mailersend::Analytics
- Inherits:
-
Object
- Object
- Mailersend::Analytics
- Defined in:
- lib/mailersend/analytics/analytics.rb
Overview
This is a class for getting the analytics from MailerSend API.
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#date_from ⇒ Object
Returns the value of attribute date_from.
-
#date_to ⇒ Object
Returns the value of attribute date_to.
-
#domain_id ⇒ Object
Returns the value of attribute domain_id.
-
#events ⇒ Object
Returns the value of attribute events.
-
#group_by ⇒ Object
Returns the value of attribute group_by.
-
#recipient_id ⇒ Object
Returns the value of attribute recipient_id.
-
#tags ⇒ Object
Returns the value of attribute tags.
Instance Method Summary collapse
- #country(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) ⇒ Object
- #date(date_from:, date_to:, events:, domain_id: nil, recipient_id: nil, group_by: nil, tags: nil) ⇒ Object
-
#initialize(client = Mailersend::Client.new) ⇒ Analytics
constructor
A new instance of Analytics.
- #ua_name(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) ⇒ Object
- #ua_type(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) ⇒ Object
Constructor Details
#initialize(client = Mailersend::Client.new) ⇒ Analytics
Returns a new instance of Analytics.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mailersend/analytics/analytics.rb', line 15 def initialize(client = Mailersend::Client.new) @client = client @date_from = '' @date_to = '' @events = [] @domain_id = '' @recipient_id = '' @group_by = '' @tags = [] end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def client @client end |
#date_from ⇒ Object
Returns the value of attribute date_from.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def date_from @date_from end |
#date_to ⇒ Object
Returns the value of attribute date_to.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def date_to @date_to end |
#domain_id ⇒ Object
Returns the value of attribute domain_id.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def domain_id @domain_id end |
#events ⇒ Object
Returns the value of attribute events.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def events @events end |
#group_by ⇒ Object
Returns the value of attribute group_by.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def group_by @group_by end |
#recipient_id ⇒ Object
Returns the value of attribute recipient_id.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def recipient_id @recipient_id end |
#tags ⇒ Object
Returns the value of attribute tags.
6 7 8 |
# File 'lib/mailersend/analytics/analytics.rb', line 6 def @tags end |
Instance Method Details
#country(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mailersend/analytics/analytics.rb', line 41 def country(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) hash = { domain_id: domain_id, recipient_id: recipient_id, date_from: date_from, date_to: date_to, 'tags[]': } client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/country', query: URI.encode_www_form(hash.compact))) end |
#date(date_from:, date_to:, events:, domain_id: nil, recipient_id: nil, group_by: nil, tags: nil) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mailersend/analytics/analytics.rb', line 26 def date(date_from:, date_to:, events:, domain_id: nil, recipient_id: nil, group_by: nil, tags: nil) hash = { 'date_from' => date_from, 'date_to' => date_to, 'event[]' => events, 'domain_id' => domain_id, 'recipient_id' => recipient_id, 'group_by' => group_by, 'tags[]' => } client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/date', query: URI.encode_www_form(hash.compact))) end |
#ua_name(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/mailersend/analytics/analytics.rb', line 54 def ua_name(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) hash = { domain_id: domain_id, recipient_id: recipient_id, date_from: date_from, date_to: date_to, 'tags[]': } client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/ua-name', query: URI.encode_www_form(hash.compact))) end |
#ua_type(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/mailersend/analytics/analytics.rb', line 67 def ua_type(date_from:, date_to:, domain_id: nil, recipient_id: nil, tags: nil) hash = { domain_id: domain_id, recipient_id: recipient_id, date_from: date_from, date_to: date_to, 'tags[]': } client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/analytics/ua-type', query: URI.encode_www_form(hash.compact))) end |