Module: ZohoInvoice::AuthToken
- Defined in:
- lib/zoho_invoice/auth_token.rb
Defined Under Namespace
Classes: AuthTokenResult
Class Method Summary collapse
Class Method Details
.generate_authtoken(email_id, password) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/zoho_invoice/auth_token.rb', line 10 def self.generate_authtoken(email_id, password) client = ZohoInvoice::Client.new(:client_options => {:url => 'https://accounts.zoho.com'}) response = client.request( :get, '/apiauthtoken/nb/create', { :SCOPE => 'invoiceapi', :EMAIL_ID => email_id, :PASSWORD => password } ) result = ZohoInvoice::AuthToken::AuthTokenResult.new(nil, nil) result.cause = response.body.match(/\nCAUSE=(.+)\n/)[1] if response.body =~ /RESULT=FALSE/ result.authtoken = response.body.match(/AUTHTOKEN=(.+)\n/)[1] if response.body =~ /RESULT=TRUE/ result end |