Sha256: c51a16c5ea8aaed3bc5eca5ec6721a41200e17649ecae8243c2e06b9a3efacef

Contents?: true

Size: 1.1 KB

Versions: 3

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/string/inflections'

require 'zoho_hub/version'
require 'zoho_hub/auth'
require 'zoho_hub/configuration'
require 'zoho_hub/connection'
require 'zoho_hub/errors'
require 'zoho_hub/records/contact'
require 'zoho_hub/records/potential'
require 'zoho_hub/records/campaign'
require 'zoho_hub/records/account'

module ZohoHub
  module_function

  def configuration
    @configuration ||= Configuration.new
  end

  def connection
    @connection
  end

  def on_refresh(&block)
    @connection.on_refresh_cb = block
  end

  def setup_connection(params = {})
    raise "ERROR: #{params[:error]}" if params[:error]

    connection_params = params.slice(:access_token, :expires_in, :api_domain, :refresh_token)

    @connection = Connection.new(connection_params)
  end

  def refresh_token?
    return false unless connection.present?

    connection.refresh_token?
  end

  def access_token?
    return false unless connection.present?

    connection.access_token?
  end

  def configure
    yield(configuration)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zoho_hub-0.1.5 lib/zoho_hub.rb
zoho_hub-0.1.4 lib/zoho_hub.rb
zoho_hub-0.1.3 lib/zoho_hub.rb