Sha256: 58703b7abb8e71e13a5268ba85be8ff54365cd01be8eae9d9c09eb2dd1e1aa65

Contents?: true

Size: 945 Bytes

Versions: 8

Compression:

Stored size: 945 Bytes

Contents

require 'mechanize'

module Adyen
  module Admin
    module Client
      LOGIN       = "https://ca-test.adyen.com/ca/ca/login.shtml"
      DASHBOARD   = "https://ca-test.adyen.com/ca/ca/overview/default.shtml"

      def login(accountname, username, password)
        @authenticated = false
        page = Adyen::Admin.client.get(LOGIN)
        page = Adyen::Admin.client.submit(page.form.tap do |form|
          form.j_account  = accountname
          form.j_username  = username
          form.j_password = password
        end)
        raise "Wrong username + password combination" if page.uri.to_s != DASHBOARD
        @authenticated = true
      end

      def get(url)
        client.get(url).tap do |page|
          raise AuthenticationError unless page.uri.to_s.include?(url)
        end
      end

      def client
        @agent ||= Mechanize.new
      end

      def authenticated?
        @authenticated
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
adyen-admin-0.0.10 lib/adyen-admin/client.rb
adyen-admin-0.0.9 lib/adyen-admin/client.rb
adyen-admin-0.0.8 lib/adyen-admin/client.rb
adyen-admin-0.0.7 lib/adyen-admin/client.rb
adyen-admin-0.0.6 lib/adyen-admin/client.rb
adyen-admin-0.0.5 lib/adyen-admin/client.rb
adyen-admin-0.0.4 lib/adyen-admin/client.rb
adyen-admin-0.0.3 lib/adyen-admin/client.rb