@@ -327,24 +327,42 @@ public CompletableFuture<FlagrightHttpResponse<BatchResponse>> createConsumerUse
327327
328328 public CompletableFuture <FlagrightHttpResponse <BatchResponse >> createConsumerUsers (
329329 UserBatchRequest request , RequestOptions requestOptions ) {
330- HttpUrl httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
330+ HttpUrl . Builder httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
331331 .newBuilder ()
332- .addPathSegments ("batch/consumer/users" )
333- .build ();
332+ .addPathSegments ("batch/consumer/users" );
333+ if (request .getLockCraRiskLevel ().isPresent ()) {
334+ QueryStringMapper .addQueryParameter (
335+ httpUrl ,
336+ "lockCraRiskLevel" ,
337+ request .getLockCraRiskLevel ().get ().toString (),
338+ false );
339+ }
340+ if (request .getLockKycRiskLevel ().isPresent ()) {
341+ QueryStringMapper .addQueryParameter (
342+ httpUrl ,
343+ "lockKycRiskLevel" ,
344+ request .getLockKycRiskLevel ().get ().toString (),
345+ false );
346+ }
347+ Map <String , Object > properties = new HashMap <>();
348+ if (request .getBatchId ().isPresent ()) {
349+ properties .put ("batchId" , request .getBatchId ());
350+ }
351+ properties .put ("data" , request .getData ());
334352 RequestBody body ;
335353 try {
336354 body = RequestBody .create (
337- ObjectMappers .JSON_MAPPER .writeValueAsBytes (request ), MediaTypes .APPLICATION_JSON );
338- } catch (JsonProcessingException e ) {
339- throw new FlagrightException ( "Failed to serialize request" , e );
355+ ObjectMappers .JSON_MAPPER .writeValueAsBytes (properties ), MediaTypes .APPLICATION_JSON );
356+ } catch (Exception e ) {
357+ throw new RuntimeException ( e );
340358 }
341- Request okhttpRequest = new Request .Builder ()
342- .url (httpUrl )
359+ Request . Builder _requestBuilder = new Request .Builder ()
360+ .url (httpUrl . build () )
343361 .method ("POST" , body )
344362 .headers (Headers .of (clientOptions .headers (requestOptions )))
345363 .addHeader ("Content-Type" , "application/json" )
346- .addHeader ("Accept" , "application/json" )
347- .build ();
364+ .addHeader ("Accept" , "application/json" );
365+ Request okhttpRequest = _requestBuilder .build ();
348366 OkHttpClient client = clientOptions .httpClient ();
349367 if (requestOptions != null && requestOptions .getTimeout ().isPresent ()) {
350368 client = clientOptions .httpClientWithTimeout (requestOptions );
@@ -407,24 +425,42 @@ public CompletableFuture<FlagrightHttpResponse<BatchResponse>> createBusinessUse
407425
408426 public CompletableFuture <FlagrightHttpResponse <BatchResponse >> createBusinessUsers (
409427 BusinessBatchRequest request , RequestOptions requestOptions ) {
410- HttpUrl httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
428+ HttpUrl . Builder httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
411429 .newBuilder ()
412- .addPathSegments ("batch/business/users" )
413- .build ();
430+ .addPathSegments ("batch/business/users" );
431+ if (request .getLockCraRiskLevel ().isPresent ()) {
432+ QueryStringMapper .addQueryParameter (
433+ httpUrl ,
434+ "lockCraRiskLevel" ,
435+ request .getLockCraRiskLevel ().get ().toString (),
436+ false );
437+ }
438+ if (request .getLockKycRiskLevel ().isPresent ()) {
439+ QueryStringMapper .addQueryParameter (
440+ httpUrl ,
441+ "lockKycRiskLevel" ,
442+ request .getLockKycRiskLevel ().get ().toString (),
443+ false );
444+ }
445+ Map <String , Object > properties = new HashMap <>();
446+ if (request .getBatchId ().isPresent ()) {
447+ properties .put ("batchId" , request .getBatchId ());
448+ }
449+ properties .put ("data" , request .getData ());
414450 RequestBody body ;
415451 try {
416452 body = RequestBody .create (
417- ObjectMappers .JSON_MAPPER .writeValueAsBytes (request ), MediaTypes .APPLICATION_JSON );
418- } catch (JsonProcessingException e ) {
419- throw new FlagrightException ( "Failed to serialize request" , e );
453+ ObjectMappers .JSON_MAPPER .writeValueAsBytes (properties ), MediaTypes .APPLICATION_JSON );
454+ } catch (Exception e ) {
455+ throw new RuntimeException ( e );
420456 }
421- Request okhttpRequest = new Request .Builder ()
422- .url (httpUrl )
457+ Request . Builder _requestBuilder = new Request .Builder ()
458+ .url (httpUrl . build () )
423459 .method ("POST" , body )
424460 .headers (Headers .of (clientOptions .headers (requestOptions )))
425461 .addHeader ("Content-Type" , "application/json" )
426- .addHeader ("Accept" , "application/json" )
427- .build ();
462+ .addHeader ("Accept" , "application/json" );
463+ Request okhttpRequest = _requestBuilder .build ();
428464 OkHttpClient client = clientOptions .httpClient ();
429465 if (requestOptions != null && requestOptions .getTimeout ().isPresent ()) {
430466 client = clientOptions .httpClientWithTimeout (requestOptions );
@@ -488,24 +524,42 @@ public CompletableFuture<FlagrightHttpResponse<BatchResponse>> createConsumerUse
488524
489525 public CompletableFuture <FlagrightHttpResponse <BatchResponse >> createConsumerUserEvents (
490526 ConsumerUserEventBatchRequest request , RequestOptions requestOptions ) {
491- HttpUrl httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
527+ HttpUrl . Builder httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
492528 .newBuilder ()
493- .addPathSegments ("batch/events/consumer/user" )
494- .build ();
529+ .addPathSegments ("batch/events/consumer/user" );
530+ if (request .getLockCraRiskLevel ().isPresent ()) {
531+ QueryStringMapper .addQueryParameter (
532+ httpUrl ,
533+ "lockCraRiskLevel" ,
534+ request .getLockCraRiskLevel ().get ().toString (),
535+ false );
536+ }
537+ if (request .getLockKycRiskLevel ().isPresent ()) {
538+ QueryStringMapper .addQueryParameter (
539+ httpUrl ,
540+ "lockKycRiskLevel" ,
541+ request .getLockKycRiskLevel ().get ().toString (),
542+ false );
543+ }
544+ Map <String , Object > properties = new HashMap <>();
545+ if (request .getBatchId ().isPresent ()) {
546+ properties .put ("batchId" , request .getBatchId ());
547+ }
548+ properties .put ("data" , request .getData ());
495549 RequestBody body ;
496550 try {
497551 body = RequestBody .create (
498- ObjectMappers .JSON_MAPPER .writeValueAsBytes (request ), MediaTypes .APPLICATION_JSON );
499- } catch (JsonProcessingException e ) {
500- throw new FlagrightException ( "Failed to serialize request" , e );
552+ ObjectMappers .JSON_MAPPER .writeValueAsBytes (properties ), MediaTypes .APPLICATION_JSON );
553+ } catch (Exception e ) {
554+ throw new RuntimeException ( e );
501555 }
502- Request okhttpRequest = new Request .Builder ()
503- .url (httpUrl )
556+ Request . Builder _requestBuilder = new Request .Builder ()
557+ .url (httpUrl . build () )
504558 .method ("POST" , body )
505559 .headers (Headers .of (clientOptions .headers (requestOptions )))
506560 .addHeader ("Content-Type" , "application/json" )
507- .addHeader ("Accept" , "application/json" )
508- .build ();
561+ .addHeader ("Accept" , "application/json" );
562+ Request okhttpRequest = _requestBuilder .build ();
509563 OkHttpClient client = clientOptions .httpClient ();
510564 if (requestOptions != null && requestOptions .getTimeout ().isPresent ()) {
511565 client = clientOptions .httpClientWithTimeout (requestOptions );
@@ -569,24 +623,42 @@ public CompletableFuture<FlagrightHttpResponse<BatchResponse>> createBusinessUse
569623
570624 public CompletableFuture <FlagrightHttpResponse <BatchResponse >> createBusinessUserEvents (
571625 BusinessUserEventBatchRequest request , RequestOptions requestOptions ) {
572- HttpUrl httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
626+ HttpUrl . Builder httpUrl = HttpUrl .parse (this .clientOptions .environment ().getUrl ())
573627 .newBuilder ()
574- .addPathSegments ("batch/events/business/user" )
575- .build ();
628+ .addPathSegments ("batch/events/business/user" );
629+ if (request .getLockCraRiskLevel ().isPresent ()) {
630+ QueryStringMapper .addQueryParameter (
631+ httpUrl ,
632+ "lockCraRiskLevel" ,
633+ request .getLockCraRiskLevel ().get ().toString (),
634+ false );
635+ }
636+ if (request .getLockKycRiskLevel ().isPresent ()) {
637+ QueryStringMapper .addQueryParameter (
638+ httpUrl ,
639+ "lockKycRiskLevel" ,
640+ request .getLockKycRiskLevel ().get ().toString (),
641+ false );
642+ }
643+ Map <String , Object > properties = new HashMap <>();
644+ if (request .getBatchId ().isPresent ()) {
645+ properties .put ("batchId" , request .getBatchId ());
646+ }
647+ properties .put ("data" , request .getData ());
576648 RequestBody body ;
577649 try {
578650 body = RequestBody .create (
579- ObjectMappers .JSON_MAPPER .writeValueAsBytes (request ), MediaTypes .APPLICATION_JSON );
580- } catch (JsonProcessingException e ) {
581- throw new FlagrightException ( "Failed to serialize request" , e );
651+ ObjectMappers .JSON_MAPPER .writeValueAsBytes (properties ), MediaTypes .APPLICATION_JSON );
652+ } catch (Exception e ) {
653+ throw new RuntimeException ( e );
582654 }
583- Request okhttpRequest = new Request .Builder ()
584- .url (httpUrl )
655+ Request . Builder _requestBuilder = new Request .Builder ()
656+ .url (httpUrl . build () )
585657 .method ("POST" , body )
586658 .headers (Headers .of (clientOptions .headers (requestOptions )))
587659 .addHeader ("Content-Type" , "application/json" )
588- .addHeader ("Accept" , "application/json" )
589- .build ();
660+ .addHeader ("Accept" , "application/json" );
661+ Request okhttpRequest = _requestBuilder .build ();
590662 OkHttpClient client = clientOptions .httpClient ();
591663 if (requestOptions != null && requestOptions .getTimeout ().isPresent ()) {
592664 client = clientOptions .httpClientWithTimeout (requestOptions );
0 commit comments