Sha256: b41aab686379ce869501d9bec9f77a4474e6f7c0fbcc600cb3a423649c6bdfe1

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require_rel 'discovery'

module Hubspot
  class Client
    attr_reader :api_key, :access_token

    def self.api_modules
      %i[
        automation
        cms
        communication_preferences
        conversations
        crm
        events
        files
        marketing
        o_auth
        settings
        webhooks
      ].freeze
    end

    include Hubspot::Discovery::BaseModuleClient

    private

    def self.base_module
      'Hubspot::Discovery'
    end

    def configure_api_key
      Hubspot.configure do |config|
        config.api_key['hapikey'] = api_key
      end
    end

    def configure_access_token
      Hubspot.configure do |config|
        config.access_token = access_token
      end
    end

    def initialize(params)
      raise 'Please, pass :api_key or :access_token' if params[:api_key].nil? && params[:developer_api_key].nil? && params[:access_token].nil?
      @api_key = params[:api_key] || params[:developer_api_key]
      @access_token = params[:access_token]
      @params = params
      configure_api_key if @api_key
      configure_access_token if @access_token
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hubspot-api-client-14.1.0 lib/hubspot/client.rb
hubspot-api-client-14.0.0 lib/hubspot/client.rb
hubspot-api-client-13.2.0 lib/hubspot/client.rb
hubspot-api-client-13.1.0 lib/hubspot/client.rb
hubspot-api-client-13.0.0 lib/hubspot/client.rb
hubspot-api-client-12.0.0 lib/hubspot/client.rb