Class: ZuoraAPI::Basic

Inherits:
Login
  • Object
show all
Defined in:
lib/zuora_api/logins/basic.rb

Constant Summary

Constants inherited from Login

Login::CONNECTION_EXCEPTIONS, Login::CONNECTION_READ_EXCEPTIONS, Login::ENVIRONMENTS, Login::MIN_Endpoints, Login::REGIONS, Login::USER_AGENT, Login::XML_SAVE_OPTIONS, Login::ZUORA_API_ERRORS, Login::ZUORA_SERVER_ERRORS

Instance Attribute Summary collapse

Attributes inherited from Login

#bearer_token, #current_error, #current_session, #entity_header_type, #entity_id, #entity_identifier, #environment, #errors, #hostname, #oauth_session_expires_at, #region, #status, #tenant_id, #tenant_name, #timeout_sleep, #url, #user_info, #wsdl_number, #zconnect_provider

Instance Method Summary collapse

Methods inherited from Login

#aqua_endpoint, #aqua_query, #checkJRStatus, #createJournalRun, #dateFormat, #describe_call, endpoints, #entity_header, environments, #error_logger, #errors_via_content_type, #exception_args, #fileURL, #getDataSourceExport, #getFileById, #get_catalog, #get_entity_id, #get_file, #get_full_nav, #get_identity, #get_oauth_client, #get_session, #get_soap_error_and_message, #insert_entity_header, #log, #query, #raise_errors, #raise_errors_helper, #refresh_nav, regions, #reporting_url, #reset_files, #rest_call, #rest_domain, #rest_endpoint, #set_nav, #soap_call, #update_create_tenant, #update_environment, #update_region, #update_zconnect_provider

Constructor Details

#initialize(username: nil, password: nil, session: nil, **keyword_args) ⇒ Basic

Returns a new instance of Basic.



4
5
6
7
8
9
10
# File 'lib/zuora_api/logins/basic.rb', line 4

def initialize(username: nil, password: nil, session: nil, **keyword_args)
  self.username = username
  self.password = password
  self.current_session = session
  raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Request Basic Login but either 'Username' or 'Password' were not passed.") if self.current_session.blank? && (self.password.blank? && self.username.blank?)
  super
end

Instance Attribute Details

#passwordObject

Returns the value of attribute password.



3
4
5
# File 'lib/zuora_api/logins/basic.rb', line 3

def password
  @password
end

#sessionObject

Returns the value of attribute session.



3
4
5
# File 'lib/zuora_api/logins/basic.rb', line 3

def session
  @session
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/zuora_api/logins/basic.rb', line 3

def username
  @username
end

Instance Method Details

#new_session(auth_type: :basic, debug: false, zuora_track_id: nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/zuora_api/logins/basic.rb', line 12

def new_session(auth_type: :basic, debug: false, zuora_track_id: nil)
  super do 
    raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Basic Login, does not support Authentication of Type: #{auth_type}") if auth_type != :basic
    raise ZuoraAPI::Exceptions::ZuoraAPIAuthenticationTypeError.new("Request Basic Login but either 'Username' or 'Password' were not passed.") if (self.password.blank? && self.username.blank?)

    output_xml, input_xml, response = soap_call(timeout_retry: true, skip_session: true, zuora_track_id: zuora_track_id) do |xml|
      xml['api']. do
        xml['api'].username self.username
        xml['api'].password self.password
        xml['api'].entityId self.entity_id if !self.entity_id.blank?
      end
    end

    retrieved_session = output_xml.xpath('//ns1:Session', 'ns1' =>'http://api.zuora.com/').text
    raise ZuoraAPI::Exceptions::ZuoraAPISessionError.new("No session found for api call.", response) if retrieved_session.blank?
    self.current_session = retrieved_session
    self.status = 'Active'
    return self.status
  end
end