class VismaEaccounting::Request
Constants
- DEFAULT_API_ENVIRONMENT
- DEFAULT_OPEN_TIMEOUT
- DEFAULT_TIMEOUT
Attributes
api_endpoint[RW]
api_environment[RW]
debug[RW]
faraday_adapter[RW]
logger[RW]
open_timeout[RW]
proxy[RW]
symbolize_keys[RW]
timeout[RW]
token[RW]
api_endpoint[RW]
api_environment[RW]
debug[RW]
faraday_adapter[RW]
logger[RW]
open_timeout[RW]
proxy[RW]
symbolize_keys[RW]
timeout[RW]
token[RW]
Public Class Methods
new(token: nil, api_environment: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 9 def initialize(token: nil, api_environment: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil) @path_parts = [] @token = token || self.class.token @token = @token.strip if @token @api_environment = api_environment || self.class.api_environment || DEFAULT_API_ENVIRONMENT @api_endpoint = api_endpoint || self.class.api_endpoint @timeout = timeout || self.class.timeout || DEFAULT_TIMEOUT @open_timeout = open_timeout || self.class.open_timeout || DEFAULT_OPEN_TIMEOUT @proxy = proxy || self.class.proxy || ENV['VISMA_PROXY_URL'] @faraday_adapter = faraday_adapter || Faraday.default_adapter @symbolize_keys = symbolize_keys || self.class.symbolize_keys || false @debug = debug || self.class.debug || false @logger = logger || self.class.logger || ::Logger.new(STDOUT) end
Protected Class Methods
method_missing(sym, *args, &block)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 81 def method_missing(sym, *args, &block) new(token: self.token, api_environment: self.api_environment, api_endpoint: self.api_endpoint, timeout: self.timeout, open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter, symbolize_keys: self.symbolize_keys, debug: self.debug, proxy: self.proxy, logger: self.logger).send(sym, *args, &block) end
respond_to_missing?(method_name, include_private = false)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 85 def respond_to_missing?(method_name, include_private = false) true end
Public Instance Methods
create(params: nil, headers: nil, body: nil)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 48 def create(params: nil, headers: nil, body: nil) APIRequest.new(builder: self).post(params: params, headers: headers, body: body) ensure reset end
delete(params: nil, headers: nil)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 66 def delete(params: nil, headers: nil) APIRequest.new(builder: self).delete(params: params, headers: headers) ensure reset end
method_missing(method, *args)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 24 def method_missing(method, *args) # To support underscores, we replace them with hyphens when calling the API @path_parts << method.to_s.gsub("_", "-").downcase @path_parts << args if args.length > 0 @path_parts.flatten! self end
path()
click to toggle source
# File lib/visma_eaccounting/request.rb, line 44 def path @path_parts.join('/') end
respond_to_missing?(method_name, include_private = false)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 32 def respond_to_missing?(method_name, include_private = false) true end
retrieve(params: nil, headers: nil)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 60 def retrieve(params: nil, headers: nil) APIRequest.new(builder: self).get(params: params, headers: headers) ensure reset end
send(*args)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 36 def send(*args) if args.length == 0 method_missing(:send, args) else __send__(*args) end end
update(params: nil, headers: nil, body: nil)
click to toggle source
# File lib/visma_eaccounting/request.rb, line 54 def update(params: nil, headers: nil, body: nil) APIRequest.new(builder: self).put(params: params, headers: headers, body: body) ensure reset end
Protected Instance Methods
reset()
click to toggle source
# File lib/visma_eaccounting/request.rb, line 74 def reset @path_parts = [] end