From 50bf0184513e11b27b846eafaf0facdc18d40df9 Mon Sep 17 00:00:00 2001 From: Ian Nance Date: Fri, 3 Apr 2020 10:25:21 -0700 Subject: [PATCH] allow headers option --- lib/woocommerce_api.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/woocommerce_api.rb b/lib/woocommerce_api.rb index 4ef29b2..5ee832b 100644 --- a/lib/woocommerce_api.rb +++ b/lib/woocommerce_api.rb @@ -132,11 +132,12 @@ def do_request method, endpoint, data = {} options = options.merge(@httparty_args) # Set headers. - options[:headers] = { + default_headers = { "User-Agent" => "WooCommerce API Client-Ruby/#{WooCommerce::VERSION}", "Accept" => "application/json" } - options[:headers]["Content-Type"] = "application/json;charset=utf-8" if !data.empty? + options[:headers] = default_headers.merge(options[:headers] || {}) + options[:headers]["Content-Type"] ||= "application/json;charset=utf-8" if !data.empty? # Set basic authentication. if @is_ssl