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, tz: nil, copy: {}, client: HTTParty) ⇒ Service

Returns a new instance of Service.



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

def initialize(
  domain:,
  api_key:,
  base_url: nil,
  environment: nil,
  tz: nil,
  copy: {},
  client: HTTParty
)
  @tz = tz
  @copy = copy
  @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

#copyObject (readonly)

Returns the value of attribute copy.



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

def copy
  @copy
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

#tzObject (readonly)

Returns the value of attribute tz.



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

def tz
  @tz
end

Instance Method Details

#fetch(path:) ⇒ Object



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

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

  send_request(options)
end