Class: Ghost::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/ghost/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, version:, api_type:, key:) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
12
13
14
# File 'lib/ghost/config.rb', line 7

def initialize(url:, version:, api_type:, key:)
  @url = url.to_s.chomp("/")
  @version = version
  @api_type = api_type
  @key = key

  validate!
end

Instance Attribute Details

#api_typeObject (readonly)

Returns the value of attribute api_type.



5
6
7
# File 'lib/ghost/config.rb', line 5

def api_type
  @api_type
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/ghost/config.rb', line 5

def url
  @url
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/ghost/config.rb', line 5

def version
  @version
end

Instance Method Details

#base_urlObject



16
17
18
# File 'lib/ghost/config.rb', line 16

def base_url
  "#{@url}/ghost/api/#{@api_type}"
end

#resource_email_url(resource, email) ⇒ Object



32
33
34
# File 'lib/ghost/config.rb', line 32

def resource_email_url(resource, email)
  "#{base_url}/#{resource}/email/#{email}/"
end

#resource_id_url(resource, id) ⇒ Object



24
25
26
# File 'lib/ghost/config.rb', line 24

def resource_id_url(resource, id)
  "#{base_url}/#{resource}/#{id}/"
end

#resource_slug_url(resource, slug) ⇒ Object



28
29
30
# File 'lib/ghost/config.rb', line 28

def resource_slug_url(resource, slug)
  "#{base_url}/#{resource}/slug/#{slug}/"
end

#resource_url(resource) ⇒ Object



20
21
22
# File 'lib/ghost/config.rb', line 20

def resource_url(resource)
  "#{base_url}/#{resource}/"
end