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.48 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.47 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.46 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.45 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.44 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.43 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.42 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.41 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.40 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.39 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.38 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.37 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.36 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.35 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.34 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.33 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.32 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.31 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.30 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.29 lib/snaptrade/api_client_custom.rb