class GhostRb::Client

@author Rene Hernandez @since 0.1

Attributes

base_url[R]
client_id[R]
client_secret[R]
default_query[R]

Public Class Methods

new(base_url, client_id, client_secret) click to toggle source
# File lib/ghost_rb/client.rb, line 13
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

Public Instance Methods

get(endpoint, query) click to toggle source
# File lib/ghost_rb/client.rb, line 36
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
posts() click to toggle source
# File lib/ghost_rb/client.rb, line 24
def posts
  Controllers::PostsController.new(self)
end
tags() click to toggle source
# File lib/ghost_rb/client.rb, line 28
def tags
  Controllers::TagsController.new(self)
end
users() click to toggle source
# File lib/ghost_rb/client.rb, line 32
def users
  Controllers::UsersController.new(self)
end