No release in over a year
This library currently supports generating a signed authorization header which is required to make requests to KindTap Platform APIs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

KindTap Platform Library for Ruby

This library currently supports generating a signed authorization header which is required to make requests to KindTap Platform APIs.

Installation

  • If using Bundler, add the following to your Gemfile gem 'kindtap-platform-ruby', '0.1.0'

  • Otherwise gem install kindtap-platform-ruby -v 0.1.0

Example using Faraday

Important Notes

  • the host and x-kt-date headers are required
  • request body must be a string that matches exactly the body of the HTTP request
require 'date'
require 'faraday'
require 'json'
require 'kindtap_platform'

host = 'kindtap-platform-host'
date = Time.now.utc

path = '/path/to/api/endpoint/'
service = 'kindtap-platform-service-name'
key = 'kindtap-client-key'
secret = 'kindtap-client-secret'
method = '<http-method>'
headers = {
  'Content-Type' => 'application/json',
  'Host' => host,
  'X-KT-Date' => KindTapPlatform.stringify_date(date),
}
body = JSON.generate({})
query = {}
querystring = URI.encode_www_form(query)

headers['Authorization'] = KindTapPlatform.generate_signed_auth_header(
  service,
  key,
  secret,
  method,
  path,
  date,
  headers,
  body,
  query,
)

session = Faraday.new

response = session.post do |request|
    request.url "https://#{host}#{path}?#{querystring}"
    request.headers = headers
    request.body = body
end

puts response.body