Sha256: 91067b3be38feb663014036b3eb5ec279b4e5dffe7e3207bc5d1ef9c1e136edb

Contents?: true

Size: 939 Bytes

Versions: 78

Compression:

Stored size: 939 Bytes

Contents

=begin
#SnapTrade

#Connect brokerage accounts to your app for live positions and trading

The version of the OpenAPI document: 1.0.0
Contact: api@snaptrade.com

=end

require 'base64'
require 'openssl'

module SnapTrade
  class ApiClientCustom
    def self.request_hook(request, configuration)
      request.params[:timestamp] = Time.now.to_i
      path = request.path[request.path.index('/api/v1/')..-1]
      query = Faraday::Utils.build_query(request.params)
      sig_object = {
        "content" => request.body.nil? || request.body.empty? ? nil : Hash[JSON.parse(request.body).sort],
        "path" => path,
        "query" => query
      }
      sig_content = JSON.generate(sig_object, sort_by: :to_s)
      sig_digest = OpenSSL::HMAC.digest(OpenSSL::Digest::SHA256.new, configuration.consumer_key, sig_content)
      signature = Base64.encode64(sig_digest).strip()
      request.headers[:Signature] = signature
    end
  end
end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
snaptrade-2.0.28 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.27 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.26 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.25 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.24 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.23 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.22 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.21 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.16 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.15 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.14 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.13 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.12 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.11 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.10 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.9 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.8 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.7 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.6 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.5 lib/snaptrade/api_client_custom.rb