Class: Mailersend::Activity

Inherits:
Object
  • Object
show all
Defined in:
lib/mailersend/activity/activity.rb

Overview

Activity endpoint from MailerSend API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = Mailersend::Client.new) ⇒ Activity

Returns a new instance of Activity.



13
14
15
16
17
18
19
20
# File 'lib/mailersend/activity/activity.rb', line 13

def initialize(client = Mailersend::Client.new)
  @client = client
  @domain_id = domain_id
  @page = page
  @limit = limit
  @date_from = date_from
  @date_to = date_to
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/mailersend/activity/activity.rb', line 6

def client
  @client
end

#date_fromObject

Returns the value of attribute date_from.



6
7
8
# File 'lib/mailersend/activity/activity.rb', line 6

def date_from
  @date_from
end

#date_toObject

Returns the value of attribute date_to.



6
7
8
# File 'lib/mailersend/activity/activity.rb', line 6

def date_to
  @date_to
end

#domain_idObject

Returns the value of attribute domain_id.



6
7
8
# File 'lib/mailersend/activity/activity.rb', line 6

def domain_id
  @domain_id
end

#limitObject

Returns the value of attribute limit.



6
7
8
# File 'lib/mailersend/activity/activity.rb', line 6

def limit
  @limit
end

#pageObject

Returns the value of attribute page.



6
7
8
# File 'lib/mailersend/activity/activity.rb', line 6

def page
  @page
end

Instance Method Details

#get(domain_id:, page: nil, limit: nil, date_from: nil, date_to: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mailersend/activity/activity.rb', line 22

def get(domain_id:, page: nil, limit: nil, date_from: nil, date_to: nil)
  hash = {
    page: page,
    limit: limit,
    date_from: date_from,
    date_to: date_to
  }

  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/activity/#{domain_id}",
                                   query: URI.encode_www_form(hash.compact)))
end