Class: Workarea::Listrak::EmailApi::Events
- Inherits:
-
Object
- Object
- Workarea::Listrak::EmailApi::Events
- Defined in:
- app/services/workarea/listrak/email_api/events.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#all(list_id) ⇒ Array<Workarea::Listrak::Models::Event>
Returns the collection of events associated with the specified list.
-
#create(list_id, event) ⇒ String
Creates a new event on the specified list.
-
#initialize(client) ⇒ Events
constructor
A new instance of Events.
Constructor Details
#initialize(client) ⇒ Events
Returns a new instance of Events.
6 7 8 |
# File 'app/services/workarea/listrak/email_api/events.rb', line 6 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'app/services/workarea/listrak/email_api/events.rb', line 4 def client @client end |
Instance Method Details
#all(list_id) ⇒ Array<Workarea::Listrak::Models::Event>
Returns the collection of events associated with the specified list.
18 19 20 21 22 23 |
# File 'app/services/workarea/listrak/email_api/events.rb', line 18 def all(list_id) request = Net::HTTP::Get.new("/email/v1/List/#{list_id}/Event") response = client.request request body = JSON.parse(response.body) body["data"].map { |event| Listrak::Models::Event.new event } end |
#create(list_id, event) ⇒ String
Creates a new event on the specified list.
34 35 36 37 38 39 40 41 |
# File 'app/services/workarea/listrak/email_api/events.rb', line 34 def create(list_id, event) request = Net::HTTP::Post.new("/email/v1/List/#{list_id}/Event").tap do |post| post.body = event.to_json end response = client.request request body = JSON.parse(response.body) body["resourceId"] end |