Sha256: 710f4968a421b62a51f45f22fe56dcf2bcfd46093ccb8926742094dab62fb3eb
Contents?: true
Size: 717 Bytes
Versions: 2
Compression:
Stored size: 717 Bytes
Contents
# frozen_string_literal: true require "dry/monads" module Tana module API # A low-level API client for making basic HTTP requests. class Client include Dependencies[:configuration, :http] include Dry::Monads[:result] def post path, body = nil, **parameters call __method__, path, json: body, params: parameters end private def call method, path, **options http.auth("Bearer #{configuration.token}") .headers(accept: configuration.accept) .public_send(method, "#{configuration.url}/#{path}", options) .then { |response| response.status.success? ? Success(response) : Failure(response) } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
tana-0.15.0 | lib/tana/api/client.rb |
tana-0.14.0 | lib/tana/api/client.rb |