Blame view

lib/syspro/get_logon_profile.rb 2.25 KB
dc8aa5b6   Joe Weakley   Rubocop corrections
1
2
  # frozen_string_literal: true
  
a61f2fc8   Isaac Lewis   parse logon profile
3
4
5
  module Syspro
    class GetLogonProfile < ApiResource
      def self.get_logon_profile(user_id)
dc8aa5b6   Joe Weakley   Rubocop corrections
6
7
        params = { 'UserId' => user_id }
        resp = request(:get, resource_url, params)
a61f2fc8   Isaac Lewis   parse logon profile
8
9
10
11
        parse_response(resp[0])
      end
  
      def resource_url
dc8aa5b6   Joe Weakley   Rubocop corrections
12
        '/GetLogonProfile'
a61f2fc8   Isaac Lewis   parse logon profile
13
14
      end
  
dc8aa5b6   Joe Weakley   Rubocop corrections
15
      def self.parse_response(resp) # rubocop:disable Metrics/MethodLength
a61f2fc8   Isaac Lewis   parse logon profile
16
17
        doc = resp.data
  
a3292c71   Isaac Lewis   remove unneeded c...
18
19
20
        OpenStruct.new(
          company_name: doc.xpath('//CompanyName').text,
          operator_code: doc.xpath('//OperatorCode').text,
b0dddc7f   Isaac Lewis   change from sorqb...
21
          operator_group: doc.xpath('//OperatorGroup').text,
a3292c71   Isaac Lewis   remove unneeded c...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
          operator_email_address: doc.xpath('//OperatorEmailAddress').text,
          operator_location: doc.xpath('//OperatorLocation').text,
          operator_language_code: doc.xpath('//OperatorLanguageCode').text,
          system_language: doc.xpath('//SystemLanguage').text,
          accounting_date: doc.xpath('//AccountingDate').text,
          company_date: doc.xpath('//CompanyDate').text,
          default_ar_branch: doc.xpath('//DefaultArBranch').text,
          default_ap_branch: doc.xpath('//DefaultApBranch').text,
          default_bank: doc.xpath('//DefaultBank').text,
          default_warehouse: doc.xpath('//DefaultWarehouse').text,
          default_customer: doc.xpath('//DefaultCustomer').text,
          system_site_id: doc.xpath('//SystemSiteId').text,
          system_nationality_code: doc.xpath('//SystemNationalityCode').text,
          local_currency_code: doc.xpath('//LocalCurrencyCode').text,
          currency_description: doc.xpath('//CurrencyDescription').text,
          default_requisition_user: doc.xpath('//DefaultRequisitionUser').text,
          xml_to_html_transform: doc.xpath('//XMLToHTMLTransform').text,
          css_style: doc.xpath('//CssStyle').text,
          css_suffix: doc.xpath('//CssSuffix').text,
          decimal_format: doc.xpath('//DecimalFormat').text,
          date_format: doc.xpath('//DateFormat').text,
          functional_role: doc.xpath('//FunctionalRole').text,
          database_type: doc.xpath('//DatabaseType').text,
          syspro_version: doc.xpath('//SysproVersion').text,
          enet_version: doc.xpath('//EnetVersion').text,
          syspro_server_bit_width: doc.xpath('//SysproServerBitWidth').text
a61f2fc8   Isaac Lewis   parse logon profile
48
49
50
        )
      end
      private_class_method :parse_response
a61f2fc8   Isaac Lewis   parse logon profile
51
52
    end
  end