Class: InvisibleCollector::Resources::EmailResource
- Inherits:
-
Object
- Object
- InvisibleCollector::Resources::EmailResource
- Includes:
- DefaultHandlers
- Defined in:
- lib/invisible_collector/resources/email_resource.rb
Instance Method Summary collapse
- #find(params = {}) ⇒ Object
- #get(id, attrs = {}) ⇒ Object
-
#initialize(options = {}) ⇒ EmailResource
constructor
A new instance of EmailResource.
Methods included from DefaultHandlers
#execute, #execute_get, #execute_post, #handle, #handles
Constructor Details
#initialize(options = {}) ⇒ EmailResource
Returns a new instance of EmailResource.
8 9 10 11 12 13 14 |
# File 'lib/invisible_collector/resources/email_resource.rb', line 8 def initialize( = {}) super() handle(400) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) } handle(404) { |response| raise InvisibleCollector::NotFound.from_json(response.body) } handle(409) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) } handle(422) { |response| raise InvisibleCollector::InvalidRequest.from_json(response.body) } end |
Instance Method Details
#find(params = {}) ⇒ Object
16 17 18 19 |
# File 'lib/invisible_collector/resources/email_resource.rb', line 16 def find(params = {}) response = execute_get('email/find', params) Response.new(response, Model::EmailList.new(JSON.parse(response.body).deep_transform_keys(&:underscore))) end |
#get(id, attrs = {}) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/invisible_collector/resources/email_resource.rb', line 21 def get(id, attrs = {}) response = @connection.get("email/#{id}", attrs) if response.status == 404 nil else build_response(response) end end |