dc8aa5b6
Joe Weakley
Rubocop corrections
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# frozen_string_literal: true
require 'cgi'
require 'faraday'
require 'json'
require 'logger'
require 'openssl'
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...
|
24
|
require 'syspro/api_operations/transaction'
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
25
26
27
28
|
require 'syspro/business_objects/combrw'
require 'syspro/business_objects/comfch'
require 'syspro/business_objects/comfnd'
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
29
|
require 'syspro/business_objects/sorqry'
|
810ca84b
Isaac Lewis
wip purchase orde...
|
30
31
|
require 'syspro/business_objects/portor'
require 'syspro/business_objects/porqry'
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
32
|
|
810ca84b
Isaac Lewis
wip purchase orde...
|
33
|
require 'syspro/business_objects/models/sor'
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
34
|
require 'syspro/business_objects/models/sor_detail'
|
810ca84b
Isaac Lewis
wip purchase orde...
|
35
|
require 'syspro/business_objects/models/por'
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
36
37
38
39
|
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...
|
40
|
require 'syspro/business_objects/parsers/sorqry_parser'
|
810ca84b
Isaac Lewis
wip purchase orde...
|
41
|
require 'syspro/business_objects/parsers/portor_parser'
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
42
43
|
# Main Module
|
31f9a345
Isaac Lewis
init; some tests
|
44
|
module Syspro
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
45
|
@api_base = 'http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest'
|
db76748d
Isaac Lewis
cop a bunch of St...
|
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
@open_timeout = 30
@read_timeout = 80
@log_level = nil
@logger = nil
@max_network_retries = 0
@max_network_retry_delay = 2
@initial_network_retry_delay = 0.5
class << self
attr_accessor :api_base, :open_timeout, :read_timeout
end
# 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
# When set prompts the library to log some extra information to $stdout and
# $stderr about what it's doing. For example, it'll produce information about
# requests, responses, and errors that are received. Valid log levels are
# `debug` and `info`, with `debug` being a little more verbose in places.
|
51fb5579
Isaac Lewis
add client test, ...
|
76
|
#
|
db76748d
Isaac Lewis
cop a bunch of St...
|
77
78
79
80
81
|
# Use of this configuration is only useful when `.logger` is _not_ set. When
# it is, the decision what levels to print is entirely deferred to the logger.
def self.log_level
@log_level
end
|
51fb5579
Isaac Lewis
add client test, ...
|
82
|
|
db76748d
Isaac Lewis
cop a bunch of St...
|
83
84
|
def self.log_level=(val)
# Backwards compatibility for values that we briefly allowed
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
85
86
|
val = LEVEL_DEBUG if val == 'debug'
val = LEVEL_INFO if val == 'info'
|
db76748d
Isaac Lewis
cop a bunch of St...
|
87
|
if !val.nil? && ![LEVEL_DEBUG, LEVEL_ERROR, LEVEL_INFO].include?(val)
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
88
89
90
91
|
raise(
ArgumentError,
'log_level should only be set to `nil`, `debug` or `info`'
)
|
db76748d
Isaac Lewis
cop a bunch of St...
|
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
end
@log_level = val
end
# Sets a logger to which logging output will be sent. The logger should
# support the same interface as the `Logger` class that's part of Ruby's
# standard library (hint, anything in `Rails.logger` will likely be
# suitable).
#
# If `.logger` is set, the value of `.log_level` is ignored. The decision on
# what levels to print is entirely deferred to the logger.
def self.logger
@logger
end
def self.logger=(val)
@logger = val
end
def self.max_network_retries
@max_network_retries
|
51fb5579
Isaac Lewis
add client test, ...
|
113
|
end
|
db76748d
Isaac Lewis
cop a bunch of St...
|
114
115
116
117
118
|
def self.max_network_retries=(val)
@max_network_retries = val.to_i
end
|
dc8aa5b6
Joe Weakley
Rubocop corrections
|
119
|
Syspro.log_level = ENV['SYSPRO_LOG'] unless ENV['SYSPRO_LOG'].nil?
|
31f9a345
Isaac Lewis
init; some tests
|
120
|
end
|