Sha256: 70ede817729deead4400cf52eccd26282a725729d6c90c625fd0ddc15ba862ad

Contents?: true

Size: 724 Bytes

Versions: 10

Compression:

Stored size: 724 Bytes

Contents

require "bixby-auth"

module Bixby
  class SignedJsonRequest < JsonRequest

    attr_accessor :headers

    def initialize(json_request, access_key=nil, secret_key=nil)
      @operation = json_request.operation
      @params = json_request.params
      @access_key = access_key
      @secret_key = secret_key
      @headers = {}
    end

    # api-auth requires a path
    def path
      "/api"
    end

    def body=(str)
      @body = str
    end

    def body
      if @body.nil? then
        hash = { :operation => operation, :params => params }
        @body = MultiJson.dump(hash)
      end
      return @body
    end

    def to_wire
      ApiAuth.sign!(self, @access_key, @secret_key)
      body
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bixby-common-0.7.1 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.7.0 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.6 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.5 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.4 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.3 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.2 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.1 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.6.0 lib/bixby-common/api/signed_json_request.rb
bixby-common-0.5.0 lib/bixby-common/api/signed_json_request.rb