Blame view

lib/syspro.rb 3.55 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'
d9a9cb5d   chadzink   Add portoi and co...
27
  require 'syspro/api_operations/setup'
dc8aa5b6   Joe Weakley   Rubocop corrections
28
29
30
31
  
  require 'syspro/business_objects/combrw'
  require 'syspro/business_objects/comfch'
  require 'syspro/business_objects/comfnd'
b0dddc7f   Isaac Lewis   change from sorqb...
32
  require 'syspro/business_objects/sorqry'
810ca84b   Isaac Lewis   wip purchase orde...
33
  require 'syspro/business_objects/portor'
d9a9cb5d   chadzink   Add portoi and co...
34
  require 'syspro/business_objects/portoi'
810ca84b   Isaac Lewis   wip purchase orde...
35
  require 'syspro/business_objects/porqry'
d9a9cb5d   chadzink   Add portoi and co...
36
  require 'syspro/business_objects/comsfm'
fb410806   chadzink   Add INVQRY busine...
37
  require 'syspro/business_objects/invqry'
b0dddc7f   Isaac Lewis   change from sorqb...
38
  
810ca84b   Isaac Lewis   wip purchase orde...
39
  require 'syspro/business_objects/models/sor'
b0dddc7f   Isaac Lewis   change from sorqb...
40
  require 'syspro/business_objects/models/sor_detail'
0e38c117   Chad Zink   Finished POR pars...
41
  require 'syspro/business_objects/models/por_detail'
fb410806   chadzink   Add INVQRY busine...
42
  require 'syspro/business_objects/models/inv_qry_options'
d9a9cb5d   chadzink   Add portoi and co...
43
44
45
46
47
48
49
  require 'syspro/business_objects/models/purchase_order'
  require 'syspro/business_objects/models/purchase_orders/header'
  require 'syspro/business_objects/models/purchase_orders/order_details'
  require 'syspro/business_objects/models/purchase_orders/stock_line'
  require 'syspro/business_objects/models/purchase_orders/freight_line'
  require 'syspro/business_objects/models/purchase_orders/misc_charge_line'
  require 'syspro/business_objects/models/purchase_orders/comment_line'
d9a9cb5d   chadzink   Add portoi and co...
50
  require 'syspro/business_objects/models/comsfm_item'
fb410806   chadzink   Add INVQRY busine...
51
  require 'syspro/business_objects/models/inv'
d9a9cb5d   chadzink   Add portoi and co...
52
  
dc8aa5b6   Joe Weakley   Rubocop corrections
53
54
55
  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...
56
  require 'syspro/business_objects/parsers/sorqry_parser'
810ca84b   Isaac Lewis   wip purchase orde...
57
  require 'syspro/business_objects/parsers/portor_parser'
d9a9cb5d   chadzink   Add portoi and co...
58
59
  require 'syspro/business_objects/parsers/portoi_parser'
  require 'syspro/business_objects/parsers/comsfm_parser'
fb410806   chadzink   Add INVQRY busine...
60
  require 'syspro/business_objects/parsers/invqry_parser'
dc8aa5b6   Joe Weakley   Rubocop corrections
61
62
  
  # Main Module
31f9a345   Isaac Lewis   init; some tests
63
  module Syspro
db76748d   Isaac Lewis   cop a bunch of St...
64
65
66
67
68
69
70
71
72
73
74
    # 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...
75
76
77
78
79
    # Delegate old deprecated configuration
    class << self
      def configure
        yield configuration
      end
51fb5579   Isaac Lewis   add client test, ...
80
  
701afa86   Samuel J Clopton   Move configuratio...
81
82
      def configuration
        Configuration.instance
db76748d   Isaac Lewis   cop a bunch of St...
83
      end
db76748d   Isaac Lewis   cop a bunch of St...
84
  
701afa86   Samuel J Clopton   Move configuratio...
85
86
87
      def api_base
        @api_base || "#{configuration.server_url}/SYSPROWCFService/Rest"
      end
db76748d   Isaac Lewis   cop a bunch of St...
88
  
701afa86   Samuel J Clopton   Move configuratio...
89
90
91
92
      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...
93
  
701afa86   Samuel J Clopton   Move configuratio...
94
95
96
97
98
99
      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...
100
  
701afa86   Samuel J Clopton   Move configuratio...
101
102
103
104
      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...
105
106
    end
  
701afa86   Samuel J Clopton   Move configuratio...
107
108
109
110
111
    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
112
  end