Class: SnapSearch::Client
- Inherits:
-
Object
- Object
- SnapSearch::Client
- Defined in:
- lib/snap_search/client.rb
Overview
The Client sends an authenticated HTTP request to the SnapChat API and returns the ‘content` field from the JSON response body.
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#ca_cert_file ⇒ Object
Returns the value of attribute ca_cert_file.
-
#email ⇒ Object
Returns the value of attribute email.
-
#key ⇒ Object
Returns the value of attribute key.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
Create a new Client instance.
-
#request(url) ⇒ String
Send an authenticated HTTP request to the ‘api_url` and return the `content` field from the JSON response body.
Constructor Details
#initialize(options = {}) ⇒ Client
Create a new Client instance.
22 23 24 |
# File 'lib/snap_search/client.rb', line 22 def initialize(={}) initialize_attributes() end |
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
12 13 14 |
# File 'lib/snap_search/client.rb', line 12 def api_url @api_url end |
#ca_cert_file ⇒ Object
Returns the value of attribute ca_cert_file.
12 13 14 |
# File 'lib/snap_search/client.rb', line 12 def ca_cert_file @ca_cert_file end |
#email ⇒ Object
Returns the value of attribute email.
12 13 14 |
# File 'lib/snap_search/client.rb', line 12 def email @email end |
#key ⇒ Object
Returns the value of attribute key.
12 13 14 |
# File 'lib/snap_search/client.rb', line 12 def key @key end |
#parameters ⇒ Object
Returns the value of attribute parameters.
12 13 14 |
# File 'lib/snap_search/client.rb', line 12 def parameters @parameters end |
Instance Method Details
#request(url) ⇒ String
Send an authenticated HTTP request to the ‘api_url` and return the `content` field from the JSON response body.
82 83 84 85 86 87 |
# File 'lib/snap_search/client.rb', line 82 def request(url) raise TypeError, 'url must be a String or respond_to #to_s' unless url.is_a?(String) || url.respond_to?(:to_s) @parameters['url'] = url.to_s # The URL must contain the entire URL with the _escaped_fragment_ parsed out content_from_response(send_request) end |