Class: VpsbClient::CurlWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/vpsb_client/curl_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth_token) ⇒ CurlWrapper

Returns a new instance of CurlWrapper.



5
6
7
# File 'lib/vpsb_client/curl_wrapper.rb', line 5

def initialize(auth_token)
  @auth_token = auth_token
end

Instance Method Details

#get(url, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/vpsb_client/curl_wrapper.rb', line 9

def get(url, &block)
  Curl.get(url) do |curl|
    curl.ssl_verify_host = false
    curl.ssl_verify_peer = false
    curl.headers['Authorization'] = "Token #{@auth_token}"

    yield curl if block_given?
  end
end

#post(url, post_params, content_type, &block) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/vpsb_client/curl_wrapper.rb', line 19

def post(url, post_params, content_type, &block)
  Curl.post(url, post_params) do |curl|
    curl.ssl_verify_host = false
    curl.ssl_verify_peer = false
    curl.headers['content-type'] = content_type
    curl.headers['Authorization'] = "Token #{@auth_token}"

    yield curl if block_given?
  end
end

#put(url, put_params, content_type, &block) ⇒ Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/vpsb_client/curl_wrapper.rb', line 30

def put(url, put_params, content_type, &block)
  Curl.put(url, put_params) do |curl|
    curl.ssl_verify_host = false
    curl.ssl_verify_peer = false
    curl.headers['content-type'] = content_type
    curl.headers['Authorization'] = "Token #{@auth_token}"

    yield curl if block_given?
  end
end