Blame view

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