Module: Missinglink::Connection
- Extended by:
- Connection
- Included in:
- Missinglink, Connection
- Defined in:
- lib/missinglink/connection.rb
Instance Method Summary collapse
- #credential_hash=(key_pair) ⇒ Object
- #credentials_provided? ⇒ Boolean
- #request(request_type, body = { }) ⇒ Object
Instance Method Details
#credential_hash=(key_pair) ⇒ Object
16 17 18 |
# File 'lib/missinglink/connection.rb', line 16 def credential_hash=(key_pair) @credential_hash = { api_key: nil, token: nil }.merge(key_pair) end |
#credentials_provided? ⇒ Boolean
20 21 22 |
# File 'lib/missinglink/connection.rb', line 20 def credentials_provided? !!(@credential_hash && @credential_hash[:api_key] && @credential_hash[:token]) end |
#request(request_type, body = { }) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/missinglink/connection.rb', line 7 def request(request_type, body = { }) (puts "Please provide credentials before making a request." && return) unless credentials_provided? JSON.parse(typh_request(request_type, @credential_hash[:api_key], @credential_hash[:token], body.to_json).tap {|x| x.run}.response.body)['data'] end |