Sha256: 91067b3be38feb663014036b3eb5ec279b4e5dffe7e3207bc5d1ef9c1e136edb

Contents?: true

Size: 939 Bytes

Versions: 77

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

77 entries across 77 versions & 1 rubygems

Version Path
snaptrade-2.0.72 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.71 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.70 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.69 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.68 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.67 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.66 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.64 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.59 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.58 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.57 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.56 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.55 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.54 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.53 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.52 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.51 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.50 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.49 lib/snaptrade/api_client_custom.rb
snaptrade-2.0.48 lib/snaptrade/api_client_custom.rb