Module: Vonage::Http

Included in:
Client, Rest
Defined in:
lib/vonage/http.rb

Instance Method Summary collapse

Instance Method Details

#get(action, params = {}, num_retries = 0) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/vonage/http.rb', line 4

def get action, params = {}, num_retries = 0
  options = {query: params, headers: {'Cookie': @cookies.to_cookie_string}}
  check_response self.class.get(action, options)

rescue Vonage::AuthenticationError => e
  handle_expired_cookies :get, action, params, num_retries, e

rescue SocketError, Interrupt, EOFError, SystemCallError, Timeout::Error => e
  raise Vonage::NetError.new(e)
end

#parse_cookies(resp) ⇒ Object



15
16
17
18
19
# File 'lib/vonage/http.rb', line 15

def parse_cookies resp
  cookie_hash = HTTParty::CookieHash.new
  resp.get_fields('Set-Cookie').each { |c| cookie_hash.add_cookies(c) }
  cookie_hash
end