Blame view

lib/syspro.rb 2.62 KB
dc8aa5b6   Joe Weakley   Rubocop corrections
1
2
3
4
5
6
7
  # frozen_string_literal: true
  
  require 'cgi'
  require 'faraday'
  require 'json'
  require 'logger'
  require 'openssl'
701afa86   Samuel J Clopton   Move configuratio...
8
  require 'forwardable'
dc8aa5b6   Joe Weakley   Rubocop corrections
9
  
701afa86   Samuel J Clopton   Move configuratio...
10
  require 'syspro/configuration'
dc8aa5b6   Joe Weakley   Rubocop corrections
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  require 'syspro/api_resource'
  require 'syspro/errors'
  require 'syspro/get_logon_profile'
  require 'syspro/get_version'
  require 'syspro/logoff'
  require 'syspro/logon'
  require 'syspro/syspro_client'
  require 'syspro/singleton_api_resource'
  require 'syspro/syspro_object'
  require 'syspro/syspro_response'
  require 'syspro/util'
  require 'syspro/version'
  
  require 'syspro/api_operations/request'
  require 'syspro/api_operations/query'
810ca84b   Isaac Lewis   wip purchase orde...
26
  require 'syspro/api_operations/transaction'
dc8aa5b6   Joe Weakley   Rubocop corrections
27
28
29
30
  
  require 'syspro/business_objects/combrw'
  require 'syspro/business_objects/comfch'
  require 'syspro/business_objects/comfnd'
b0dddc7f   Isaac Lewis   change from sorqb...
31
  require 'syspro/business_objects/sorqry'
810ca84b   Isaac Lewis   wip purchase orde...
32
33
  require 'syspro/business_objects/portor'
  require 'syspro/business_objects/porqry'
b0dddc7f   Isaac Lewis   change from sorqb...
34
  
810ca84b   Isaac Lewis   wip purchase orde...
35
  require 'syspro/business_objects/models/sor'
b0dddc7f   Isaac Lewis   change from sorqb...
36
  require 'syspro/business_objects/models/sor_detail'
0e38c117   Chad Zink   Finished POR pars...
37
  require 'syspro/business_objects/models/por_detail'
dc8aa5b6   Joe Weakley   Rubocop corrections
38
39
40
41
  
  require 'syspro/business_objects/parsers/combrw_parser'
  require 'syspro/business_objects/parsers/comfch_parser'
  require 'syspro/business_objects/parsers/comfnd_parser'
b0dddc7f   Isaac Lewis   change from sorqb...
42
  require 'syspro/business_objects/parsers/sorqry_parser'
810ca84b   Isaac Lewis   wip purchase orde...
43
  require 'syspro/business_objects/parsers/portor_parser'
dc8aa5b6   Joe Weakley   Rubocop corrections
44
45
  
  # Main Module
31f9a345   Isaac Lewis   init; some tests
46
  module Syspro
db76748d   Isaac Lewis   cop a bunch of St...
47
48
49
50
51
52
53
54
55
56
57
    # Options that should be persisted between API requests. This includes
    # client, which is an object containing an HTTP client to reuse.
    OPTS_PERSISTABLE = (
      Set[:client]
    ).freeze
  
    # map to the same values as the standard library's logger
    LEVEL_DEBUG = Logger::DEBUG
    LEVEL_ERROR = Logger::ERROR
    LEVEL_INFO = Logger::INFO
  
701afa86   Samuel J Clopton   Move configuratio...
58
59
60
61
62
    # Delegate old deprecated configuration
    class << self
      def configure
        yield configuration
      end
51fb5579   Isaac Lewis   add client test, ...
63
  
701afa86   Samuel J Clopton   Move configuratio...
64
65
      def configuration
        Configuration.instance
db76748d   Isaac Lewis   cop a bunch of St...
66
      end
db76748d   Isaac Lewis   cop a bunch of St...
67
  
701afa86   Samuel J Clopton   Move configuratio...
68
69
70
      def api_base
        @api_base || "#{configuration.server_url}/SYSPROWCFService/Rest"
      end
db76748d   Isaac Lewis   cop a bunch of St...
71
  
701afa86   Samuel J Clopton   Move configuratio...
72
73
74
75
      def api_base=(url)
        warn "[DEPRECATION] `api_base=` is deprecated. Please use `configuration.server_url=` instead."
        @api_base = url
      end
db76748d   Isaac Lewis   cop a bunch of St...
76
  
701afa86   Samuel J Clopton   Move configuratio...
77
78
79
80
81
82
      private
  
      def deprecate_config(name)
        define_singleton_method(name) { call_deprecated_config(name) }
        define_singleton_method("#{name}=") { |v| call_deprecated_config("#{name}=", v) }
      end
db76748d   Isaac Lewis   cop a bunch of St...
83
  
701afa86   Samuel J Clopton   Move configuratio...
84
85
86
87
      def call_deprecated_config(name, *args)
        warn "[DEPRECATION] `#{name}` is deprecated. Please use `configuration.#{name}` instead."
        configuration.send(name, *args)
      end
db76748d   Isaac Lewis   cop a bunch of St...
88
89
    end
  
701afa86   Samuel J Clopton   Move configuratio...
90
91
92
93
94
    deprecate_config :open_timeout
    deprecate_config :read_timeout
    deprecate_config :log_level
    deprecate_config :logger
    deprecate_config :max_network_retries
31f9a345   Isaac Lewis   init; some tests
95
  end