Class: WpApiClient::Connection
- Inherits:
-
Object
- Object
- WpApiClient::Connection
- Defined in:
- lib/wp_api_client/connection.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
Instance Method Summary collapse
-
#get(url, params = {}) ⇒ Object
translate requests into wp-api urls.
-
#initialize(endpoint) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(endpoint) ⇒ Connection
Returns a new instance of Connection.
9 10 11 12 13 14 15 16 |
# File 'lib/wp_api_client/connection.rb', line 9 def initialize(endpoint) @conn = Faraday.new(:url => endpoint) do |faraday| faraday.request :url_encoded # form-encode POST params #faraday.response :logger # log requests to STDOUT faraday.response :json, :content_type => /\bjson$/ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP end end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
7 8 9 |
# File 'lib/wp_api_client/connection.rb', line 7 def headers @headers end |
Instance Method Details
#get(url, params = {}) ⇒ Object
translate requests into wp-api urls
19 20 21 |
# File 'lib/wp_api_client/connection.rb', line 19 def get(url, params = {}) @conn.get url, params.merge({_embed: true}) end |