Class: Jekyll::JamComments::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll_jam_comments/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain:, api_key:, base_url: nil, environment: nil, client: HTTParty) ⇒ Service

Returns a new instance of Service.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jekyll_jam_comments/service.rb', line 10

def initialize(
  domain:,
  api_key:,
  base_url: nil,
  environment: nil,
  client: HTTParty
)
  @client = client
  @domain = domain
  @api_key = api_key
  @base_url = base_url || "https://go.jamcomments.com"
  @environment = environment || "production"
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



8
9
10
# File 'lib/jekyll_jam_comments/service.rb', line 8

def api_key
  @api_key
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



8
9
10
# File 'lib/jekyll_jam_comments/service.rb', line 8

def base_url
  @base_url
end

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/jekyll_jam_comments/service.rb', line 8

def client
  @client
end

#domainObject (readonly)

Returns the value of attribute domain.



8
9
10
# File 'lib/jekyll_jam_comments/service.rb', line 8

def domain
  @domain
end

#environmentObject (readonly)

Returns the value of attribute environment.



8
9
10
# File 'lib/jekyll_jam_comments/service.rb', line 8

def environment
  @environment
end

Instance Method Details

#fetch(path:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/jekyll_jam_comments/service.rb', line 24

def fetch(path:)
  options = {
    :query   => {
      :path   => formatted_path(path),
      :domain => domain,
      :stub   => stub_value,
    },
    :headers => {
      :Authorization => "Bearer #{api_key}",
      :Accept        => "application/json",
      :"X-Platform"  => "jekyll",
    },
  }

  send_request(options)
end