Class: DaFace::Api::Adapter
- Inherits:
-
Object
- Object
- DaFace::Api::Adapter
- Includes:
- Utilities
- Defined in:
- lib/da_face/api/adapter.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#get(path, params = {}) ⇒ Object
Performs a get operation.
-
#initialize(adapter_class = DaFace.configuration.adapter_class) ⇒ Adapter
constructor
A new instance of Adapter.
-
#post(path, payload) ⇒ Object
Performs a post operation.
-
#put(path, payload) ⇒ Object
Performs a put operation.
Methods included from Utilities
#parse_json, #parse_timestamp, #parse_uri, #symbolize_keys
Constructor Details
#initialize(adapter_class = DaFace.configuration.adapter_class) ⇒ Adapter
Returns a new instance of Adapter.
8 9 10 |
# File 'lib/da_face/api/adapter.rb', line 8 def initialize adapter_class = DaFace.configuration.adapter_class @connection = adapter_class.new end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/da_face/api/adapter.rb', line 6 def connection @connection end |
Instance Method Details
#get(path, params = {}) ⇒ Object
Performs a get operation
params is a level 1 hash that should contain params for url
18 19 20 21 |
# File 'lib/da_face/api/adapter.rb', line 18 def get path, params={} response = connection.get path, params return symbolize_keys(response.keys, response) end |
#post(path, payload) ⇒ Object
Performs a post operation
payload is a hash that will be parsed to json and sent as body
26 27 28 29 30 |
# File 'lib/da_face/api/adapter.rb', line 26 def post path, payload response = connection.post path, payload return true if response.empty? return symbolize_keys(response.keys, response) end |
#put(path, payload) ⇒ Object
Performs a put operation
payload is a hash that will be parsed to json and sent as body
35 36 37 38 39 |
# File 'lib/da_face/api/adapter.rb', line 35 def put path, payload response = connection.put path, payload return true if response.empty? return symbolize_keys(response.keys, response) end |