Sha256: 99732e2b7b387e84554fc3440ae36bfb84849136e1af2301409f0df08b5ad1c3
Contents?: true
Size: 998 Bytes
Versions: 4
Compression:
Stored size: 998 Bytes
Contents
# frozen_string_literal: true require 'httpclient' require 'uri' require 'json' module GhostRb # @author Rene Hernandez # @since 0.1 class Client attr_reader :base_url, :client_id, :client_secret, :default_query def initialize(base_url, client_id, client_secret) @base_url = URI.join(base_url, 'ghost/', 'api/', 'v0.1/') @client_id = client_id @client_secret = client_secret @http = HTTPClient.new(base_url: @base_url) @default_query = Support::HashWithIndifferentAccess.new( client_id: @client_id, client_secret: @client_secret ) end def posts Controllers::PostsController.new(self) end def tags Controllers::TagsController.new(self) end def get(endpoint, query) response = @http.get(endpoint, query, {}, follow_redirect: true) content = Support::HashWithIndifferentAccess.new( JSON.parse(response.body) ) [response.status_code, content] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ghost_rb-0.2.8 | lib/ghost_rb/client.rb |
ghost_rb-0.2.7 | lib/ghost_rb/client.rb |
ghost_rb-0.2.6 | lib/ghost_rb/client.rb |
ghost_rb-0.2.5 | lib/ghost_rb/client.rb |