Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module PrivateGroupApi
- class Request
- attr_accessor :url
- def initialize(url)
- self.url = url
- end
- def authenticate(username, password)
- uri = URI.parse "#{url}?username=#{username}&password=#{password}"
- request = Net::HTTP::Get.new uri.path
- http = Net::HTTP.new uri.host, uri.port
- response = http.request request
- PrivateGroupApi::Response.new response.code
- end
- end
- class Response
- attr_accessor :code
- def initialize(code)
- self.code = code
- end
- def success?
- code == '200'
- end
- def failure?
- code == '404'
- end
- def error?
- code == '500'
- end
- end
- end
Add Comment
Please, Sign In to add comment