Sha256: 10388b2c729d4ccdfe1be5d69bb0fa09c54f1ae28193e728528852ee7218148d

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outreach-ruby-0.0.2 lib/outreach-ruby/service/sequence_state.rb