Class: K2ConnectRuby::K2Services::K2Client
- Inherits:
-
Object
- Object
- K2ConnectRuby::K2Services::K2Client
- Defined in:
- lib/k2-connect-ruby/k2_services/k2_client.rb
Instance Attribute Summary collapse
-
#api_secret_key ⇒ Object
Returns the value of attribute api_secret_key.
-
#hash_body ⇒ Object
Returns the value of attribute hash_body.
-
#k2_signature ⇒ Object
Returns the value of attribute k2_signature.
Instance Method Summary collapse
-
#initialize(api_secret_key) ⇒ K2Client
constructor
Initialize method.
-
#parse_request(the_request) ⇒ Object
Method for parsing the Entire Request.
Constructor Details
#initialize(api_secret_key) ⇒ K2Client
Initialize method
9 10 11 12 |
# File 'lib/k2-connect-ruby/k2_services/k2_client.rb', line 9 def initialize(api_secret_key) raise ArgumentError, 'No Secret Key Given!' if api_secret_key.blank? @api_secret_key = api_secret_key end |
Instance Attribute Details
#api_secret_key ⇒ Object
Returns the value of attribute api_secret_key.
4 5 6 |
# File 'lib/k2-connect-ruby/k2_services/k2_client.rb', line 4 def api_secret_key @api_secret_key end |
#hash_body ⇒ Object
Returns the value of attribute hash_body.
4 5 6 |
# File 'lib/k2-connect-ruby/k2_services/k2_client.rb', line 4 def hash_body @hash_body end |
#k2_signature ⇒ Object
Returns the value of attribute k2_signature.
4 5 6 |
# File 'lib/k2-connect-ruby/k2_services/k2_client.rb', line 4 def k2_signature @k2_signature end |
Instance Method Details
#parse_request(the_request) ⇒ Object
Method for parsing the Entire Request. Come back to it later to trim. L8r call it set_client_variables
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/k2-connect-ruby/k2_services/k2_client.rb', line 15 def parse_request(the_request) raise ArgumentError, 'Nil Request Parameter Input!' if the_request.blank? # The Response Body. @hash_body = JSON.parse(the_request.body.read) # The Response Header hash_header = JSON.parse(the_request.env.select { |k, _| k =~ /^HTTP_/ }.to_json) # The K2 Signature @k2_signature = hash_header['HTTP_X_KOPOKOPO_SIGNATURE'] end |