@@ -49,16 +49,9 @@ impl SendAccessClient {
4949 . identity
5050 . client
5151 . post ( & url)
52- . header (
53- reqwest:: header:: CONTENT_TYPE ,
54- "application/x-www-form-urlencoded; charset=utf-8" ,
55- )
5652 . header ( reqwest:: header:: ACCEPT , "application/json" )
5753 . header ( reqwest:: header:: CACHE_CONTROL , "no-store" )
58- // We can use `serde_urlencoded` to serialize the payload into a URL-encoded string
59- // because we don't have complex nested structures in the payload.
60- // If we had nested structures, we have to use serde_qs::to_string instead.
61- . body ( serde_urlencoded:: to_string ( & payload) . expect ( "Serialize should be infallible" ) ) ;
54+ . form ( & payload) ;
6255
6356 // Because of the ? operator, any errors from sending the request are automatically
6457 // wrapped in SendAccessTokenError::Unexpected as an UnexpectedIdentityError::Reqwest
@@ -164,7 +157,7 @@ mod tests {
164157 // expect the headers we set in the client
165158 . and ( matchers:: header (
166159 reqwest:: header:: CONTENT_TYPE . as_str ( ) ,
167- "application/x-www-form-urlencoded; charset=utf-8 " ,
160+ "application/x-www-form-urlencoded" ,
168161 ) )
169162 . and ( matchers:: header (
170163 reqwest:: header:: ACCEPT . as_str ( ) ,
@@ -234,7 +227,7 @@ mod tests {
234227 // expect the headers we set in the client
235228 . and ( matchers:: header (
236229 reqwest:: header:: CONTENT_TYPE . as_str ( ) ,
237- "application/x-www-form-urlencoded; charset=utf-8 " ,
230+ "application/x-www-form-urlencoded" ,
238231 ) )
239232 . and ( matchers:: header (
240233 reqwest:: header:: ACCEPT . as_str ( ) ,
@@ -298,8 +291,6 @@ mod tests {
298291 otp : otp. into ( ) ,
299292 } ;
300293
301- let email_param = serde_urlencoded:: to_string ( [ ( "email" , email) ] ) . unwrap ( ) ; // "email=valid%40email.com"
302-
303294 let req = SendAccessTokenRequest {
304295 send_id : "valid-send-id" . into ( ) ,
305296 send_access_credentials : Some ( SendAccessCredentials :: EmailOtp (
@@ -312,7 +303,7 @@ mod tests {
312303 // expect the headers we set in the client
313304 . and ( matchers:: header (
314305 reqwest:: header:: CONTENT_TYPE . as_str ( ) ,
315- "application/x-www-form-urlencoded; charset=utf-8 " ,
306+ "application/x-www-form-urlencoded" ,
316307 ) )
317308 . and ( matchers:: header (
318309 reqwest:: header:: ACCEPT . as_str ( ) ,
@@ -330,7 +321,7 @@ mod tests {
330321 ) ) )
331322 . and ( body_string_contains ( format ! ( "scope={}" , scope_str) ) )
332323 . and ( body_string_contains ( format ! ( "send_id={}" , req. send_id) ) )
333- . and ( body_string_contains ( email_param ) )
324+ . and ( body_string_contains ( "email=valid%40email.com" ) )
334325 . and ( body_string_contains ( format ! ( "otp={}" , otp) ) )
335326 // respond with the mock success response
336327 . respond_with ( ResponseTemplate :: new ( 200 ) . set_body_json ( raw_success) ) ;
0 commit comments