11package com .resend .core .net ;
22
3+ import java .util .Collections ;
4+ import java .util .HashMap ;
5+ import java .util .Map ;
6+
37/**
48 * Represents a request to create a request options.
59 */
610public class RequestOptions {
711 private final String idempotencyKey ;
12+ private final Map <String , String > additionalHeaders ;
813
914 /**
1015 * Constructs a RequestOptions object using the provided builder.
@@ -13,6 +18,7 @@ public class RequestOptions {
1318 */
1419 public RequestOptions (Builder builder ) {
1520 this .idempotencyKey = builder .idempotencyKey ;
21+ this .additionalHeaders = Collections .unmodifiableMap (new HashMap <>(builder .additionalHeaders ));
1622 }
1723
1824 /**
@@ -24,6 +30,15 @@ public String getIdempotencyKey() {
2430 return idempotencyKey ;
2531 }
2632
33+ /**
34+ * Get the additional headers map.
35+ *
36+ * @return An unmodifiable map of additional headers.
37+ */
38+ public Map <String , String > getAdditionalHeaders () {
39+ return additionalHeaders ;
40+ }
41+
2742 /**
2843 * Create a new builder instance for constructing RequestOptions objects.
2944 *
@@ -38,6 +53,14 @@ public static Builder builder() {
3853 */
3954 public static class Builder {
4055 private String idempotencyKey ;
56+ private final Map <String , String > additionalHeaders ;
57+
58+ /**
59+ * Constructs a new Builder with empty additional headers map.
60+ */
61+ public Builder () {
62+ this .additionalHeaders = new HashMap <>();
63+ }
4164
4265 /**
4366 * Set the idempotencyKey.
@@ -50,6 +73,28 @@ public Builder setIdempotencyKey(String idempotencyKey) {
5073 return this ;
5174 }
5275
76+ /**
77+ * Add a custom header to the additional headers map.
78+ *
79+ * @param name The header name.
80+ * @param value The header value.
81+ * @return The builder instance.
82+ */
83+ public Builder add (String name , String value ) {
84+ this .additionalHeaders .put (name , value );
85+ return this ;
86+ }
87+
88+ /**
89+ * Add multiple custom headers to the additional headers map.
90+ *
91+ * @param headers A map of headers to add.
92+ * @return The builder instance.
93+ */
94+ public Builder addAll (Map <String , String > headers ) {
95+ this .additionalHeaders .putAll (headers );
96+ return this ;
97+ }
5398
5499 /**
55100 * Build a new RequestOptions object.
@@ -60,4 +105,4 @@ public RequestOptions build() {
60105 return new RequestOptions (this );
61106 }
62107 }
63- }
108+ }
0 commit comments