@@ -58,19 +58,20 @@ module Post
5858 protected
5959
6060 include HttpClient
61- # Performs a POST call to the Nylas API.
62- #
63- # @param path [String] Destination path for the call.
64- # @param query_params [Hash, {}] Query params to pass to the call.
65- # @param request_body [Hash, nil] Request body to pass to the call.
66- # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
61+ # Performs a POST call to the Nylas API.
62+ #
63+ # @param path [String] Destination path for the call.
64+ # @param query_params [Hash, {}] Query params to pass to the call.
65+ # @param request_body [Hash, nil] Request body to pass to the call.
66+ # Defaults to {} when nil to ensure Content-Type: application/json is sent.
67+ # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
6768 # @return [Array(Hash, String, Hash)] Nylas data object, API Request ID, and response headers.
6869 def post ( path :, query_params : { } , request_body : nil , headers : { } )
6970 response = execute (
7071 method : :post ,
7172 path : path ,
7273 query : query_params ,
73- payload : request_body ,
74+ payload : request_body || { } ,
7475 headers : headers ,
7576 api_key : api_key ,
7677 timeout : timeout
@@ -85,19 +86,20 @@ module Put
8586 protected
8687
8788 include HttpClient
88- # Performs a PUT call to the Nylas API.
89- #
90- # @param path [String] Destination path for the call.
91- # @param query_params [Hash, {}] Query params to pass to the call.
92- # @param request_body [Hash, nil] Request body to pass to the call.
93- # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
89+ # Performs a PUT call to the Nylas API.
90+ #
91+ # @param path [String] Destination path for the call.
92+ # @param query_params [Hash, {}] Query params to pass to the call.
93+ # @param request_body [Hash, nil] Request body to pass to the call.
94+ # Defaults to {} when nil to ensure Content-Type: application/json is sent.
95+ # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
9496 # @return Nylas data object and API Request ID.
9597 def put ( path :, query_params : { } , request_body : nil , headers : { } )
9698 response = execute (
9799 method : :put ,
98100 path : path ,
99101 query : query_params ,
100- payload : request_body ,
102+ payload : request_body || { } ,
101103 headers : headers ,
102104 api_key : api_key ,
103105 timeout : timeout
@@ -112,19 +114,20 @@ module Patch
112114 protected
113115
114116 include HttpClient
115- # Performs a PATCH call to the Nylas API.
116- #
117- # @param path [String] Destination path for the call.
118- # @param query_params [Hash, {}] Query params to pass to the call.
119- # @param request_body [Hash, nil] Request body to pass to the call.
120- # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
117+ # Performs a PATCH call to the Nylas API.
118+ #
119+ # @param path [String] Destination path for the call.
120+ # @param query_params [Hash, {}] Query params to pass to the call.
121+ # @param request_body [Hash, nil] Request body to pass to the call.
122+ # Defaults to {} when nil to ensure Content-Type: application/json is sent.
123+ # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
121124 # @return Nylas data object and API Request ID.
122125 def patch ( path :, query_params : { } , request_body : nil , headers : { } )
123126 response = execute (
124127 method : :patch ,
125128 path : path ,
126129 query : query_params ,
127- payload : request_body ,
130+ payload : request_body || { } ,
128131 headers : headers ,
129132 api_key : api_key ,
130133 timeout : timeout
@@ -139,25 +142,27 @@ module Delete
139142 protected
140143
141144 include HttpClient
142- # Performs a DELETE call to the Nylas API.
143- #
144- # @param path [String] Destination path for the call.
145- # @param query_params [Hash, {}] Query params to pass to the call.
146- # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
147- # @return Nylas data object and API Request ID.
148- def delete ( path :, query_params : { } , headers : { } )
149- response = execute (
150- method : :delete ,
151- path : path ,
152- query : query_params ,
153- headers : headers ,
154- payload : nil ,
155- api_key : api_key ,
156- timeout : timeout
157- )
158-
159- [ response [ :data ] , response [ :request_id ] ]
160- end
145+ # Performs a DELETE call to the Nylas API.
146+ #
147+ # @param path [String] Destination path for the call.
148+ # @param query_params [Hash, {}] Query params to pass to the call.
149+ # @param request_body [Hash, nil] Optional request body (e.g. cancellation_reason for bookings).
150+ # Defaults to {} to ensure Content-Type: application/json is sent.
151+ # @param headers [Hash, {}] Additional HTTP headers to include in the payload.
152+ # @return Nylas data object and API Request ID.
153+ def delete ( path :, query_params : { } , request_body : nil , headers : { } )
154+ response = execute (
155+ method : :delete ,
156+ path : path ,
157+ query : query_params ,
158+ headers : headers ,
159+ payload : request_body || { } ,
160+ api_key : api_key ,
161+ timeout : timeout
162+ )
163+
164+ [ response [ :data ] , response [ :request_id ] ]
165+ end
161166 end
162167 end
163168end
0 commit comments