Module: Adyen::Admin::Client

Included in:
Adyen::Admin
Defined in:
lib/adyen-admin/client.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#authenticated?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/adyen-admin/client.rb', line 34

def authenticated?
  @authenticated
end

#clientObject



30
31
32
# File 'lib/adyen-admin/client.rb', line 30

def client
  @agent ||= Mechanize.new
end

#get(url) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/adyen-admin/client.rb', line 21

def get(url)
  client.get(url).tap do |page|
    if !page.uri.to_s.include?(url)
      @authenticated = false
      raise AuthenticationError
    end
  end
end

#login(accountname, username, password) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/adyen-admin/client.rb', line 9

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