Blame view

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