Sha256: 1364d009ce32b603108fa0402acc42d835a36b6c8d411be469cc52c98c4cffbe

Contents?: true

Size: 1.52 KB

Versions: 3

Compression:

Stored size: 1.52 KB

Contents

module Woodpecker
  class Prospect
    VALID_STATUSES = %w(active replied bounced autoreplied invalid blacklist).freeze
    ATTRS = [:email, :status, :first_name, :last_name, :tags, :company,
             :industry, :title, :phone, :address, :city, :state, :country, :website,
             :snipet1, :snipet2, :snipet3, :snipet4].freeze

    attr_accessor(*ATTRS)

    def initialize(prospect)
      @email = prospect[:email]
      raise Errors::Prospect, "Invalid status, valid states are: #{VALID_STATUSES}." unless VALID_STATUSES.include?(prospect[:status])
      @status = prospect[:status].upcase
      @first_name = prospect[:first_name] || ''
      @last_name = prospect[:last_name] || ''
      @tags = prospect[:tags] || ''
      @company = prospect[:company] || ''
      @industry = prospect[:industry] || ''
      @title = prospect[:title] || ''
      @phone = prospect[:phone] || ''
      @address = prospect[:address] || ''
      @city = prospect[:city] || ''
      @state = prospect[:state] || ''
      @country = prospect[:country] || ''
      @website = prospect[:website] || ''
      @snipet1 = prospect[:snipet1] || ''
      @snipet2 = prospect[:snipet2] || ''
      @snipet3 = prospect[:snipet3] || ''
      @snipet4 = prospect[:snipet4] || ''
    end

    def email
      raise Errors::Prospect, 'Missing email' unless @email
      @email
    end

    def to_h
      hash = {}
      ATTRS.each do |attr|
        hash[attr.to_sym] = send(attr)
      end
      hash
    end

    def to_json(*_args)
      to_h.to_json
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
woodpecker-0.1.2 lib/woodpecker/prospect.rb
woodpecker-0.1.1 lib/woodpecker/prospect.rb
woodpecker-0.1.0 lib/woodpecker/prospect.rb