module Outreach module Service class SequenceState def initialize(client) @request = client.request end def find(id) response = @request.get("#{api_url}/#{id}") collection_class.build_from_attributes_hash(response['data']) end def find_all(attrs = {}) response = @request.get(api_url, filter_attribute_mapping(attrs)) response['data'].map do |attrs| collection_class.build_from_attributes_hash(attrs) end end private def filter_attribute_mapping(attrs) if attrs[:prospect_id] attrs['filter[prospect][id]'] = attrs.delete(:prospect_id) end attrs end def api_url 'https://api.outreach.io/api/v2/sequenceStates' end def collection_class Outreach::SequenceState end end end end