Class: SimplyReddit::BaseClient

Inherits:
Object
  • Object
show all
Defined in:
lib/simply_reddit/base_client.rb

Direct Known Subclasses

Client

Defined Under Namespace

Classes: Response

Instance Method Summary collapse

Constructor Details

#initialize(base_url:, adapter: Faraday.default_adapter, headers: {}) ⇒ BaseClient

Returns a new instance of BaseClient.



7
8
9
10
11
12
# File 'lib/simply_reddit/base_client.rb', line 7

def initialize(base_url:, adapter: Faraday.default_adapter, headers: {})
  @base_url = base_url
  @adapter = adapter
  @default_headers = headers
  @connection = nil
end

Instance Method Details

#delete(path, params = {}) ⇒ Object



30
31
32
33
# File 'lib/simply_reddit/base_client.rb', line 30

def delete(path, params = {})
  response = connection.delete(path, params)
  wrap_response(response)
end

#get(path, params = {}) ⇒ Object

HTTP methods



15
16
17
18
# File 'lib/simply_reddit/base_client.rb', line 15

def get(path, params = {})
  response = connection.get(path, params)
  wrap_response(response)
end

#post(path, body = {}) ⇒ Object



20
21
22
23
# File 'lib/simply_reddit/base_client.rb', line 20

def post(path, body = {})
  response = connection.post(path, body)
  wrap_response(response)
end

#put(path, body = {}) ⇒ Object



25
26
27
28
# File 'lib/simply_reddit/base_client.rb', line 25

def put(path, body = {})
  response = connection.put(path, body)
  wrap_response(response)
end