Class: Moltin::Api::RestClientWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/moltin/api/rest_client_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, custom_headers = {}) ⇒ RestClientWrapper

Returns a new instance of RestClientWrapper.



5
6
7
8
9
10
11
12
13
# File 'lib/moltin/api/rest_client_wrapper.rb', line 5

def initialize(path, custom_headers = {})
  @instance = RestClient::Resource.new(
    Moltin::Api::Request.build_endpoint(path),
    {
      verify_ssl: OpenSSL::SSL::VERIFY_NONE,
      headers: Moltin::Api::Request.headers(custom_headers),
    }
  )
end

Instance Method Details

#deleteObject



33
34
35
36
37
# File 'lib/moltin/api/rest_client_wrapper.rb', line 33

def delete
  @instance.delete do |response|
    yield response
  end
end

#getObject



15
16
17
18
19
# File 'lib/moltin/api/rest_client_wrapper.rb', line 15

def get
  @instance.get do |response|
    yield response
  end
end

#post(data) ⇒ Object



21
22
23
24
25
# File 'lib/moltin/api/rest_client_wrapper.rb', line 21

def post data
  @instance.post data do |response|
    yield response
  end
end

#put(data) ⇒ Object



27
28
29
30
31
# File 'lib/moltin/api/rest_client_wrapper.rb', line 27

def put data
  @instance.put data do |response|
    yield response
  end
end