11package com .telesign ;
22
33import java .io .IOException ;
4+ import java .io .UnsupportedEncodingException ;
45import java .net .Proxy ;
56import java .security .GeneralSecurityException ;
67import java .util .Map ;
78
9+ import okhttp3 .MediaType ;
10+ import okhttp3 .RequestBody ;
11+ import com .google .gson .Gson ;;
12+
813/**
914 * A set of APIs that deliver deep phone number data attributes that help optimize the end user
1015 * verification process and evaluate risk.
1116 */
1217public class PhoneIdClient extends RestClient {
1318
1419 private static final String PHONEID_RESOURCE = "/v1/phoneid/%s" ;
20+
21+ public static final MediaType JSON = MediaType .parse ("application/json" ); // ; charset=utf-8
1522
1623 public PhoneIdClient (String customerId , String apiKey ) {
1724 super (customerId , apiKey );
@@ -37,10 +44,22 @@ public PhoneIdClient(String customerId,
3744 * The PhoneID API provides a cleansed phone number, phone type, and telecom carrier information to determine the
3845 * best communication method - SMS or voice.
3946 * <p>
40- * See https://developer.telesign.com/docs/phoneid-api for detailed API documentation.
47+ * See https://developer.te
48+ * lesign.com/docs/phoneid-api for detailed API documentation.
4149 */
42- public TelesignResponse phoneid (String phoneNumber , Map <String , String > params ) throws IOException , GeneralSecurityException {
50+ public TelesignResponse phoneid (String phoneNumber , Map <String , ? extends Object > params ) throws IOException , GeneralSecurityException {
4351
4452 return this .post (String .format (PHONEID_RESOURCE , phoneNumber ), params );
45- }
53+ }
54+
55+ @ Override
56+ public RequestBody createRequestBody (Map <String , ? extends Object > params ) throws UnsupportedEncodingException {
57+ String jsonString = (new Gson ()).toJson (params );
58+ return params != null ? RequestBody .create (PhoneIdClient .JSON , jsonString .getBytes ()) : RequestBody .create (PhoneIdClient .JSON , "" );
59+ }
60+
61+ @ Override
62+ protected String getContentType () {
63+ return "application/json" ;
64+ }
4665}
0 commit comments