Class: Quintype::API::Client
- Inherits:
-
Object
- Object
- Quintype::API::Client
- Defined in:
- lib/quintype/api/client.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_config ⇒ Object
- #get_story_by_slug(slug) ⇒ Object
-
#initialize(conn) ⇒ Client
constructor
A new instance of Client.
- #post_bulk(requests) ⇒ Object
Constructor Details
#initialize(conn) ⇒ Client
Returns a new instance of Client.
27 28 29 |
# File 'lib/quintype/api/client.rb', line 27 def initialize(conn) @conn = conn end |
Class Method Details
.establish_connection(host, adapter = nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/quintype/api/client.rb', line 13 def establish_connection(host, adapter = nil) connection = Faraday.new(host) do |conn| conn.request :json conn.response :json, :content_type => /\bjson$/ conn.adapter(adapter || Faraday.default_adapter) end @client = new(connection) end |
.instance ⇒ Object
22 23 24 |
# File 'lib/quintype/api/client.rb', line 22 def instance @client end |
Instance Method Details
#get_config ⇒ Object
31 32 33 |
# File 'lib/quintype/api/client.rb', line 31 def get_config get("/api/v1/config") end |
#get_story_by_slug(slug) ⇒ Object
35 36 37 |
# File 'lib/quintype/api/client.rb', line 35 def get_story_by_slug(slug) get("/api/v1/stories-by-slug", slug: slug) end |
#post_bulk(requests) ⇒ Object
39 40 41 |
# File 'lib/quintype/api/client.rb', line 39 def post_bulk(requests) post("/api/v1/bulk", requests) end |