Blame view

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