Class: ZenfolioAPI::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/ZenfolioAPI/authentication.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Authentication

Connect to the Zenfolio API

Raises:

Author:

  • David Slone



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ZenfolioAPI/authentication.rb', line 9

def initialize username,password
	@api_url = "http://api.zenfolio.com/api/1.7/zfapi.asmx"
	@username = username
	@password = password


	connection = ZenfolioAPI::HTTP.new()
	@response = connection.POST('AuthenticatePlain', [username, password])
	
	# Unable to authenticate the user. Return error code from server
	raise ZenfolioAPI::ZenfolioAPIAuthenticationError, @response['error'] if !@response['error'].nil?

	@token = @response['result']
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/ZenfolioAPI/authentication.rb', line 4

def token
  @token
end