Class: Haunted::GhostContentApi

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/haunted.rb

Overview

Client that communicates with the Ghost CMS content API

Instance Method Summary collapse

Constructor Details

#initialize(site_url, key, **options) ⇒ GhostContentApi

Initializes a new Ghost Content API client

site_url: URL to the Ghost site key: Content API key options: api_path - override the default content API path, api_version - override the default API version



20
21
22
23
24
25
# File 'lib/haunted.rb', line 20

def initialize(site_url, key, **options)
  @site_url = site_url
  @key = key
  @api_path = options[:api_path] || "ghost/api/content"
  @api_version = options[:api_version] || "v5.0"
end

Instance Method Details

#settingsObject

Gets the settings



130
131
132
133
134
135
136
# File 'lib/haunted.rb', line 130

def settings
  self.class.get(
    build_browse_api_endpoint("settings"),
    query: build_query_string_params,
    headers: build_headers
  )
end

#tiers(fields: nil, paging: nil) ⇒ Object

Gets the available tiers

fields: Array of strings or symbols that specify which resource fields are returned. If you only need some fields then use this option.

Available options for the include and fields options vary depending on the resource, see the Ghost Content API for more information.

paging: Hash that specifies paging and limit options. Use { limit: all } to return all items. Specify a number to returned that number of items per page. Use { page: x } to specify what page of results to return.



119
120
121
122
123
124
125
# File 'lib/haunted.rb', line 119

def tiers(fields: nil, paging: nil)
  self.class.get(
    build_browse_api_endpoint("tiers"),
    query: build_query_string_params(fields: fields, paging: paging),
    headers: build_headers
  )
end