lib/mrkt.rb in mrkt-0.9.0 vs lib/mrkt.rb in mrkt-0.10.0
- old
+ new
@@ -11,10 +11,12 @@
require 'mrkt/concerns/import_leads'
require 'mrkt/concerns/import_custom_objects'
require 'mrkt/concerns/crud_custom_objects'
require 'mrkt/concerns/crud_custom_activities'
require 'mrkt/concerns/crud_programs'
+require 'mrkt/concerns/crud_asset_static_lists'
+require 'mrkt/concerns/crud_asset_folders'
module Mrkt
class Client
include Connection
include Authentication
@@ -26,10 +28,12 @@
include ImportLeads
include ImportCustomObjects
include CrudCustomObjects
include CrudCustomActivities
include CrudPrograms
+ include CrudAssetStaticLists
+ include CrudAssetFolders
attr_accessor :debug
def initialize(options = {})
@host = options.fetch(:host)
@@ -47,16 +51,22 @@
@log_options = options[:log_options]
@options = options
end
- %i(get post delete).each do |http_method|
- define_method(http_method) do |path, payload = {}, &block|
+ def merge_params(params, optional)
+ params.merge(optional.keep_if { |_key, value| value })
+ end
+
+ %i[get post delete].each do |http_method|
+ define_method(http_method) do |path, params = {}, optional = {}, &block|
authenticate!
+ payload = merge_params(params, optional)
+
resp = connection.send(http_method, path, payload) do |req|
add_authorization(req)
- block.call(req) unless block.nil?
+ block&.call(req)
end
resp.body
end
end