Sha256: ff3f87a11e43167a525e23672c41de2224d2b8ffe5745ab2164a1fe485e4124e
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
module Workarea module MailChimp class BogusRequest def initialize(*) @path_parts = [] end 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 def respond_to_missing?(method_name, include_private = false) true end def send(*args) if args.length == 0 method_missing(:send, args) else __send__(*args) end end def path @path_parts.join('/') end def create(params: nil, headers: nil, body: nil) BogusAPIRequest.new(builder: self).post(params: params, headers: headers, body: body) reset end def update(params: nil, headers: nil, body: nil) BogusAPIRequest.new(builder: self).patch(params: params, headers: headers, body: body) reset end def upsert(params: nil, headers: nil, body: nil) BogusAPIRequest.new(builder: self).put(params: params, headers: headers, body: body) reset end def retrieve(params: nil, headers: nil) BogusAPIRequest.new(builder: self).get(params: params, headers: headers) reset end def delete(params: nil, headers: nil) BogusAPIRequest.new(builder: self).delete(params: params, headers: headers) reset end protected def reset @path_parts = [] end class << self attr_accessor :api_key, :timeout, :open_timeout, :api_endpoint, :proxy, :faraday_adapter, :symbolize_keys, :debug, :logger def method_missing(sym, *args, &block) new.send(sym, *args, &block) end def respond_to_missing?(method_name, include_private = false) true end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-mail_chimp-3.0.3 | lib/integrations/workarea/mail_chimp/bogus_request.rb |
workarea-mail_chimp-3.0.2 | lib/integrations/workarea/mail_chimp/bogus_request.rb |