Skip to content

Commit

Permalink
Merge pull request #194 from mailjet/DE-34
Browse files Browse the repository at this point in the history
DE-34 Add individual .find implementation
  • Loading branch information
xab3r authored Oct 27, 2020
2 parents 758bca5 + f5b6918 commit 9ea6fb5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/mailjet/resources/contact_getcontactslists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,26 @@ class Contact_getcontactslists
self.public_operations = [:get]
self.filters = []
self.resourceprop = []

def self.find(id, job_id = nil, options = {})
opts = define_options(options)
self.resource_path = create_action_resource_path(id, job_id) if self.action

raw_data = parse_api_json(connection(opts)[id].get(default_headers))

if raw_data.count == 1
return instanciate_from_api(raw_data.first)
end

raw_data.map do |entity|
instanciate_from_api(entity)
end
rescue Mailjet::ApiError => e
if e.code == 404
nil
else
raise e
end
end
end
end

0 comments on commit 9ea6fb5

Please sign in to comment.