class UniaraVirtualParser::Client

This module handle the connections between all services and the UniaraVirtual server

Constants

ENDPOINT

Public Class Methods

configure_endpoint(endpoint) click to toggle source
# File lib/uniara_virtual_parser/client.rb, line 25
def configure_endpoint(endpoint)
  @endpoint = endpoint
end
get_with_token(path, token) click to toggle source
# File lib/uniara_virtual_parser/client.rb, line 11
def get_with_token(path, token)
  uri = URI("#{endpoint}#{path}")
  req = Net::HTTP::Get.new(uri)
  req['Cookie'] = "PHPSESSID=#{token};"
  res = Net::HTTP.start(uri.hostname, uri.port) do |http|
    http.request(req)
  end
end
post(path, body=nil) click to toggle source
# File lib/uniara_virtual_parser/client.rb, line 20
def post(path, body=nil)
  uri = URI("#{endpoint}#{path}")
  Net::HTTP.post_form(uri, body)
end

Private Class Methods

endpoint() click to toggle source
# File lib/uniara_virtual_parser/client.rb, line 31
def endpoint
  @endpoint || ENDPOINT
end