Sha256: 9599bb9614dd8d6a170435226f3489fed470287e43c7d51c266ca9c7a6e5a006

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

require 'outreach-ruby/model'

module Outreach
  class Prospect
    extend Outreach::Model

    attr_accessor :id, :first_name, :last_name, :emails, :owner_id, :response

    def initialize(attrs)
      @id = attrs['id']
      @first_name = attrs['first_name']
      @last_name = attrs['last_name']
      @emails = attrs['emails']
      @owner_id = attrs['owner_id']
      @response = attrs['response']
    end

    def self.build_from_attributes_hash(data)
      result = {}
      result['first_name'] = nested_hash_value(
        data,
        %w[attributes firstName]
      )
      result['last_name'] = nested_hash_value(
        data,
        %w[attributes lastName]
      )
      result['emails'] = nested_hash_value(
        data,
        %w[attributes emails]
      )
      result['id'] = data['id']
      result['owner_id'] = nested_hash_value(
        data,
        %w[relationships owner data id]
      )
      result['response'] = data
      new(result)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outreach-ruby-0.0.2 lib/outreach-ruby/prospect.rb