From 07a0cb5f9c4e1987f57a87b11c5e9e41f018c434 Mon Sep 17 00:00:00 2001 From: Denys Kovalenko Date: Tue, 25 May 2021 10:57:22 +0300 Subject: [PATCH] [COL-1351] ability to add additional headers to client with user token --- lib/mixduty/client.ex | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lib/mixduty/client.ex b/lib/mixduty/client.ex index 414ea8c..6f24574 100644 --- a/lib/mixduty/client.ex +++ b/lib/mixduty/client.ex @@ -14,12 +14,22 @@ defmodule Mixduty.Client do Mixduty.Client.new("myauthtoken") """ def new(auth) do + new(auth, headers: []) + end + + @doc """ + Create the client with additional headers + #### Example + Mixduty.Client.new("myauthtoken", [headers: [{"X-EARLY-ACCESS", "business-impact-early-access"}]) + """ + def new(auth, headers: additional_headers) do %Client{ - headers: [ - {"Accept", "application/vnd.pagerduty+json;version=2"}, - {"Authorization", "Token token=#{auth}"}, - {"Content-type", "application/json"} - ] + headers: + [ + {"Accept", "application/vnd.pagerduty+json;version=2"}, + {"Authorization", "Token token=#{auth}"}, + {"Content-type", "application/json"} + ] ++ additional_headers } end