class OzonLogistics::Request
Constants
- DEFAULT_OPEN_TIMEOUT
- DEFAULT_TIMEOUT
Attributes
access_token[RW]
api_endpoint[RW]
debug[RW]
faraday_adapter[RW]
logger[RW]
open_timeout[RW]
proxy[RW]
symbolize_keys[RW]
test[RW]
timeout[RW]
access_token[RW]
api_endpoint[RW]
debug[RW]
faraday_adapter[RW]
logger[RW]
open_timeout[RW]
proxy[RW]
symbolize_keys[RW]
test[RW]
timeout[RW]
Public Class Methods
new(access_token: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil, test: false)
click to toggle source
# File lib/ozon-logistics/request.rb, line 8 def initialize(access_token: nil, api_endpoint: nil, timeout: nil, open_timeout: nil, proxy: nil, faraday_adapter: nil, symbolize_keys: false, debug: false, logger: nil, test: false) @path_parts = [] @access_token = access_token || self.class.access_token || OzonLogistics.generate_access_token.try(:dig, "access_token") @access_token = @access_token.strip if @access_token @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['OZON_LOGISTICS_PROXY'] @faraday_adapter = faraday_adapter || self.class.faraday_adapter || Faraday.default_adapter @symbolize_keys = symbolize_keys || self.class.symbolize_keys || false @debug = debug || self.class.debug || false @test = test || self.class.test || false @logger = logger || self.class.logger || ::Logger.new(STDOUT) end
Protected Class Methods
method_missing(sym, *args, &block)
click to toggle source
# File lib/ozon-logistics/request.rb, line 85 def method_missing(sym, *args, &block) new(access_token: self.access_token, 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, test: self.test).send(sym, *args, &block) end
respond_to_missing?(method_name, include_private = false)
click to toggle source
# File lib/ozon-logistics/request.rb, line 89 def respond_to_missing?(method_name, include_private = false) true end
Public Instance Methods
create(params: nil, headers: nil, body: {})
click to toggle source
# File lib/ozon-logistics/request.rb, line 46 def create(params: nil, headers: nil, body: {}) 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/ozon-logistics/request.rb, line 70 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/ozon-logistics/request.rb, line 23 def method_missing(method, *args) @path_parts << method.to_s.downcase @path_parts << args if args.length > 0 @path_parts.flatten! self end
path()
click to toggle source
# File lib/ozon-logistics/request.rb, line 42 def path @path_parts.join('/') end
respond_to_missing?(method_name, include_private = false)
click to toggle source
# File lib/ozon-logistics/request.rb, line 30 def respond_to_missing?(method_name, include_private = false) true end
retrieve(params: nil, headers: nil)
click to toggle source
# File lib/ozon-logistics/request.rb, line 64 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/ozon-logistics/request.rb, line 34 def send(*args) if args.length == 0 method_missing(:send, args) else __send__(*args) end end
update(params: nil, headers: nil, body: {})
click to toggle source
# File lib/ozon-logistics/request.rb, line 52 def update(params: nil, headers: nil, body: {}) APIRequest.new(builder: self).patch(params: params, headers: headers, body: body) ensure reset end
upsert(params: nil, headers: nil, body: {})
click to toggle source
# File lib/ozon-logistics/request.rb, line 58 def upsert(params: nil, headers: nil, body: {}) APIRequest.new(builder: self).put(params: params, headers: headers, body: body) ensure reset end
Protected Instance Methods
reset()
click to toggle source
# File lib/ozon-logistics/request.rb, line 78 def reset @path_parts = [] end