Sha256: b74fcdf49e78d3677b9b5f09d1563b2369579a5d6c0e6fd7bd2be912d968961e

Contents?: true

Size: 839 Bytes

Versions: 14

Compression:

Stored size: 839 Bytes

Contents

dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')

class TripIt
  include HTTParty
  base_uri 'http://www.tripit.com'
  debug_output

  def initialize(email, password)
    @email = email
    response = self.class.get('/account/login')
    response = self.class.post(
      '/account/login',
      body: {
        login_email_address: email,
        login_password: password
      },
      headers: {'Cookie' => response.headers['Set-Cookie']}
    )
    @cookie = response.request.options[:headers]['Cookie']
  end

  def account_settings
    self.class.get('/account/edit', headers: {'Cookie' => @cookie})
  end

  def logged_in?
    account_settings.include? "You're logged in as #{@email}"
  end
end

tripit = TripIt.new('email', 'password')
puts "Logged in: #{tripit.logged_in?}"

Version data entries

14 entries across 13 versions & 5 rubygems

Version Path
simplenet-client-0.2.0 ./vendor/bundle/ruby/1.9.1/gems/httparty-0.13.7/examples/tripit_sign_in.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/2.0.0/gems/httparty-0.13.7/examples/tripit_sign_in.rb
httparty-0.13.7 examples/tripit_sign_in.rb
httparty-0.13.6 examples/tripit_sign_in.rb
httpserious-0.13.5.lstoll1 examples/tripit_sign_in.rb
httparty-0.13.5 examples/tripit_sign_in.rb
httparty-0.13.4 examples/tripit_sign_in.rb
httsoiree-0.13.3 examples/tripit_sign_in.rb
httparty-0.13.3 examples/tripit_sign_in.rb
httparty-0.13.2 examples/tripit_sign_in.rb
httsoiree-0.13.1.1 examples/tripit_sign_in.rb
httsoiree-0.13.1 examples/tripit_sign_in.rb
httparty-enterprise-edition-0.13.1.1 examples/tripit_sign_in.rb
httparty-enterprise-edition-0.13.1 examples/tripit_sign_in.rb