Sha256: 556feb79820fda8a34d9cf254c3ac8563c7004977e17d79c46587b6fb62817f7
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module Notion class RequestClient include HTTParty base_uri "https://api.notion.com" headers "Content-Type": "application/json" def self.active_client RequestClient.new(Notion.config) end def initialize(config) self.class.headers Authorization: "Bearer #{config.api_token}" self.class.headers "Notion-Version": config.notion_version end def get(*args, &block) response = self.class.get(*args, &block) raise_on_failure(response) end def post(*args, &block) response = self.class.post(*args, &block) raise_on_failure(response) end def patch(*args, &block) response = self.class.patch(*args, &block) raise_on_failure(response) end def put(*args, &block) response = self.class.put(*args, &block) raise_on_failure(response) end def delete(*args, &block) response = self.class.delete(*args, &block) raise_on_failure(response) end def raise_on_failure(response) if response.success? response else raise ErrorFactory.create(response) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
notion-sdk-ruby-0.4.0 | lib/notion-sdk-ruby/request_client.rb |