Class: SuapApi::Connect
- Inherits:
-
Object
- Object
- SuapApi::Connect
- Defined in:
- lib/suap_api/connect.rb
Instance Method Summary collapse
- #get_json_by_uri(uri) ⇒ Object
-
#initialize(username, password) ⇒ Connect
constructor
A new instance of Connect.
Constructor Details
#initialize(username, password) ⇒ Connect
Returns a new instance of Connect.
3 4 5 6 |
# File 'lib/suap_api/connect.rb', line 3 def initialize(username, password) @username = username @password = password end |
Instance Method Details
#get_json_by_uri(uri) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/suap_api/connect.rb', line 8 def get_json_by_uri(uri) mechanize = Mechanize.new mechanize.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE page = mechanize.get(SuapApi::BASE_URL) form = page.forms.first form['username'] = @username form['password'] = @password page = form.submit api = mechanize.get("#{BASE_URL}#{uri}") api.body end |