Sha256: ab3e5680790e4124111c670c3757cccb84bb8b3c4c2a74a1607d8bc1284e632e

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

# frozen_string_literal: true

require_relative '../utilities/response'

module Crunchbase
  # Get the Organization data from API
  module Models
    # Root
    class Entity
      include ::Crunchbase::Utilities::Response

      def fields
        field_ids.map(&:to_sym)
      end

      def parse_response(response, request_field_ids = [])
        extract_fields = (request_field_ids.empty? ? field_ids : request_field_ids)

        dynamic_attributes(self, extract_fields, response.dig('properties'))
      end

      def parse_cards_response(response)
        parse_response(response, response.dig('properties'))
        # response.dig('cards')
      end

      def as_json
        fields.each_with_object({}) { |item, hash| hash[item] = send(item) }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
crunchbase4-0.1.2 lib/crunchbase/models/entity.rb
crunchbase4-0.1.1 lib/crunchbase/models/entity.rb