Sha256: 3fb7102f24db0bbb28ee3093b08c07e9c008c27e8f5ac75992baea5ec45714a7

Contents?: true

Size: 857 Bytes

Versions: 5

Compression:

Stored size: 857 Bytes

Contents

# TODO: Uncomment the checking of the request scheme
class K2Client
  attr_accessor :api_secret_key,
                :hash_body,
                :k2_signature

  # Initialize method
  def initialize(api_secret_key)
    raise ArgumentError, 'No Secret Key Given!' if api_secret_key.blank?
    @api_secret_key = api_secret_key
  end

  # Method for parsing the Entire Request. Come back to it later to trim. L8r call it set_client_variables
  def parse_request(the_request)
    raise ArgumentError, 'Nil Request Parameter Input!' if the_request.blank?

    # The Response Body.
    @hash_body = Yajl::Parser.parse(the_request.body.read.as_json)
    # The Response Header
    hash_header = Yajl::Parser.parse(the_request.env.select { |k, _| k =~ /^HTTP_/ }.to_json)
    # The K2 Signature
    @k2_signature = hash_header['HTTP_X_KOPOKOPO_SIGNATURE']
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
k2-connect-ruby-2.0.0 lib/k2-connect-ruby/k2_services/client/k2_client.rb
k2-connect-ruby-1.0.0 lib/k2-connect-ruby/k2_services/client/k2_client.rb
k2-connect-ruby-0.0.3 lib/k2-connect-ruby/k2_services/client/k2_client.rb
k2-connect-ruby-0.0.2 lib/k2-connect-ruby/k2_services/client/k2_client.rb
k2-connect-ruby-0.0.1 lib/k2-connect-ruby/k2_services/client/k2_client.rb