Class: EmailOctopus::Contact

Inherits:
Model
  • Object
show all
Defined in:
lib/email_octopus/contact.rb

Overview

Contact of a list

Instance Attribute Summary

Attributes inherited from Model

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

all, attribute, create, #destroy, find, #initialize, method_missing, #persisted?, #reload!, #save, #to_json

Constructor Details

This class inherits a constructor from EmailOctopus::Model

Class Method Details

.where(list_id: '') ⇒ Object


14
15
16
17
18
19
# File 'lib/email_octopus/contact.rb', line 14

def self.where(list_id: '')
  api = API.new EmailOctopus.config.api_key
  api.get("/lists/#{list_id}/contacts").body['data'].map do |params|
    new(params)
  end
end

Instance Method Details

#as_jsonObject


21
22
23
24
25
# File 'lib/email_octopus/contact.rb', line 21

def as_json
  attributes.reject do |(key, _val)|
    key.to_s =~ 'list_id'
  end.to_h
end