class NotionRuby::Connection

Attributes

hash[R]

Public Class Methods

new(hash = {}) { |builder| ... } click to toggle source
Calls superclass method
# File lib/notion_ruby/connection.rb, line 17
def initialize(hash = {})
  @hash = hash

  super(hash[:api_url] || "https://api.notion.com") do |builder|
    yield builder if block_given?
    builder.use Faraday::Response::RaiseNotionRubyError
    builder.use FaradayMiddleware::EncodeJson
    builder.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
    builder.adapter Faraday.default_adapter
  end

  headers["Authorization"] = "Bearer #{hash[:access_token]}" if hash.key?(:access_token)
  headers["Notion-Version"] = NOTION_VERSION
end

Public Instance Methods

parallel_connection(adapter = :typhoeus) click to toggle source
# File lib/notion_ruby/connection.rb, line 11
def parallel_connection(adapter = :typhoeus)
  conn = self.class.new @hash
  conn.adapter adapter
  conn
end