class ZapiAgent
Attributes
generate_xml[R]
responder[R]
response[R]
zapi[R]
Public Class Methods
new(username:, password:, zapi: nil, xml_generator: nil, responder: nil)
click to toggle source
# File lib/zapi_agent.rb, line 5 def initialize username:, password:, zapi: nil, xml_generator: nil, responder: nil @zapi = zapi || Zapi.new() @generate_xml = xml_generator || ZapiXML.new() @responder = responder || ZapiObject @response = _login username: username, password: password end
Public Instance Methods
_account_id()
click to toggle source
# File lib/zapi_agent.rb, line 52 def _account_id response.try(:[],'zapiAccountId').to_i end
_account_type()
click to toggle source
# File lib/zapi_agent.rb, line 56 def _account_type response.try(:[],'zapiAccountType').to_i end
_api_token()
click to toggle source
# File lib/zapi_agent.rb, line 64 def _api_token response.try(:[],'zapiApiToken') end
_cart_id()
click to toggle source
# File lib/zapi_agent.rb, line 60 def _cart_id response.try(:[],'cartId') end
_firstname()
click to toggle source
# File lib/zapi_agent.rb, line 72 def _firstname response.try(:[],'firstName') end
_fullname()
click to toggle source
# File lib/zapi_agent.rb, line 80 def _fullname [_firstname, _lastname].compact.join(" ") if _firstname || _lastname end
_lastname()
click to toggle source
# File lib/zapi_agent.rb, line 76 def _lastname response.try(:[],'lastName') end
_login(username:, password: login_xml = generate_xml.agent_login(username: username, password: password))
click to toggle source
# File lib/zapi_agent.rb, line 43 def _login username:, password: login_xml = generate_xml.agent_login(username: username, password: password) zapi.request(xml: login_xml) end
_method_name()
click to toggle source
# File lib/zapi_agent.rb, line 84 def _method_name response.try(:[],'methodName') end
_user_id()
click to toggle source
# File lib/zapi_agent.rb, line 48 def _user_id response.try(:[],'zapiUserId').to_i end
_username()
click to toggle source
# File lib/zapi_agent.rb, line 68 def _username response.try(:[],'zapiUsername') end
history()
click to toggle source
# File lib/zapi_agent.rb, line 20 def history #raise response.inspect Zaui.agents_get_profile(agent_id: _user_id) end
is_logged_in?()
click to toggle source
# File lib/zapi_agent.rb, line 12 def is_logged_in? response_msg == "Login Successful" && _method_name == 'zapiAgentLogin' end
response_msg()
click to toggle source
# File lib/zapi_agent.rb, line 16 def response_msg response.try(:[],'methodErrorMessage') end
session(hash: session_hash)
click to toggle source
# File lib/zapi_agent.rb, line 39 def session hash: session_hash responder.new(hash: hash) end
session_hash()
click to toggle source
# File lib/zapi_agent.rb, line 25 def session_hash { user_id: _user_id, account_id: _account_id, account_type: _account_type, cart_id: _cart_id, api_token: _api_token, username: _username, firstname: _firstname, lastname: _lastname, fullname: _fullname } end