Sha256: ec67443744344f9a87082db465ee58843dc144fb5a1ae9eaa3f197ba73434565
Contents?: true
Size: 818 Bytes
Versions: 4
Compression:
Stored size: 818 Bytes
Contents
module Airrecord class Client attr_reader :api_key attr_writer :connection def initialize(api_key) @api_key = api_key end def connection @connection ||= Faraday.new(url: "https://api.airtable.com", headers: { "Authorization" => "Bearer #{api_key}", "X-API-VERSION" => "0.1.0", }) { |conn| conn.adapter :net_http_persistent } end def escape(*args) URI.escape(*args) end def parse(body) JSON.parse(body) rescue JSON::ParserError nil end def handle_error(status, error) if error.is_a?(Hash) raise Error, "HTTP #{status}: #{error['error']["type"]}: #{error['error']['message']}" else raise Error, "HTTP #{status}: Communication error: #{error}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
airrecord-0.2.1 | lib/airrecord/client.rb |
airrecord-0.2.0 | lib/airrecord/client.rb |
airrecord-0.1.4 | lib/airrecord/client.rb |
airrecord-0.1.3 | lib/airrecord/client.rb |