11package com .callfire .api .client .api .contacts ;
22
33import com .callfire .api .client .*;
4+ import com .callfire .api .client .api .common .model .Page ;
5+ import com .callfire .api .client .api .contacts .model .DoNotContact ;
6+ import com .callfire .api .client .api .contacts .model .UniversalDnc ;
7+ import com .callfire .api .client .api .contacts .model .request .CreateDncsRequest ;
8+ import com .callfire .api .client .api .contacts .model .request .FindDncNumbersRequest ;
9+ import com .callfire .api .client .api .contacts .model .request .FindUniversalDncsRequest ;
10+ import com .callfire .api .client .api .contacts .model .request .UpdateDncRequest ;
11+ import org .apache .commons .lang3 .Validate ;
12+
13+ import java .util .List ;
14+
15+ import static com .callfire .api .client .ClientConstants .PLACEHOLDER ;
16+ import static com .callfire .api .client .ModelType .*;
417
518/**
619 * Represents /contacts/dncs endpoint
922 */
1023public class DncApi {
1124
12- // TODO vmalinovskiy: uncomment when dnc apis will be tested and available on docs site
13- /*private static final String DNC_PATH = "/contacts/dncs";
25+ private static final String DNC_PATH = "/contacts/dncs" ;
1426 private static final String DNC_SOURCES_PATH = "/contacts/dncs/sources/{}" ;
1527 private static final String UNIVERSAL_DNC_PATH = "/contacts/dncs/universals/{}" ;
1628 private static final String DNC_NUMBER_PATH = "/contacts/dncs/{}" ;
@@ -21,7 +33,7 @@ public DncApi(RestApiClient client) {
2133 this .client = client ;
2234 }
2335
24- */ /**
36+ /**
2537 * Find all Do Not Contact (DNC) objects created by the user.
2638 * These DoNotContact entries only affect calls/texts/campaigns on this account.
2739 *
@@ -34,12 +46,12 @@ public DncApi(RestApiClient client) {
3446 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
3547 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
3648 * @throws CallfireClientException in case error has occurred in client.
37- */ /*
49+ */
3850 public Page <DoNotContact > find (FindDncNumbersRequest request ) {
3951 return client .get (DNC_PATH , pageOf (DoNotContact .class ), request );
4052 }
4153
42- */ /**
54+ /**
4355 * Get do not contact (dnc).
4456 *
4557 * @param number DNC number to get dnc for
@@ -51,12 +63,12 @@ public Page<DoNotContact> find(FindDncNumbersRequest request) {
5163 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
5264 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
5365 * @throws CallfireClientException in case error has occurred in client.
54- */ /*
66+ */
5567 public DoNotContact get (String number ) {
5668 return client .get (DNC_NUMBER_PATH .replaceFirst (PLACEHOLDER , number ), of (DoNotContact .class ));
5769 }
5870
59- */ /**
71+ /**
6072 * Add Do Not Contact (DNC) entries.
6173 *
6274 * @param request DNC items to create
@@ -67,12 +79,12 @@ public DoNotContact get(String number) {
6779 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
6880 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
6981 * @throws CallfireClientException in case error has occurred in client.
70- */ /*
82+ */
7183 public void create (CreateDncsRequest request ) {
7284 client .post (DNC_PATH , null , request );
7385 }
7486
75- */ /**
87+ /**
7688 * Update a Do Not Contact (DNC) value. Can toggle whether the DNC is enabled for calls/texts.
7789 *
7890 * @param request DNC update request
@@ -83,12 +95,12 @@ public void create(CreateDncsRequest request) {
8395 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
8496 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
8597 * @throws CallfireClientException in case error has occurred in client.
86- */ /*
98+ */
8799 public void update (UpdateDncRequest request ) {
88100 client .put (DNC_NUMBER_PATH .replaceFirst (PLACEHOLDER , request .getNumber ()), null , request );
89101 }
90102
91- */ /**
103+ /**
92104 * Delete a Do Not Contact (DNC) value.
93105 *
94106 * @param number DNC number to remove dnc for
@@ -99,13 +111,13 @@ public void update(UpdateDncRequest request) {
99111 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
100112 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
101113 * @throws CallfireClientException in case error has occurred in client.
102- */ /*
114+ */
103115 public void delete (String number ) {
104116 Validate .notNull (number , "number cannot be null" );
105117 client .delete (DNC_NUMBER_PATH .replaceFirst (PLACEHOLDER , number ));
106118 }
107119
108- */ /**
120+ /**
109121 * Find universal do not contacts (udnc) associated with toNumber
110122 *
111123 * @param request find request with different properties to filter
@@ -117,12 +129,12 @@ public void delete(String number) {
117129 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
118130 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
119131 * @throws CallfireClientException in case error has occurred in client.
120- */ /*
132+ */
121133 public List <UniversalDnc > findUniversalDncs (FindUniversalDncsRequest request ) {
122134 return client .get (UNIVERSAL_DNC_PATH .replaceFirst (PLACEHOLDER , request .getToNumber ()), listHolderOf (UniversalDnc .class ), request ).getItems ();
123135 }
124136
125- */ /**
137+ /**
126138 * Delete do not contact (dnc) numbers contained in source.
127139 *
128140 * @param source Source associated with Do Not Contact (DNC) entry.
@@ -133,10 +145,10 @@ public List<UniversalDnc> findUniversalDncs(FindUniversalDncsRequest request) {
133145 * @throws InternalServerErrorException in case HTTP response code is 500 - Internal Server Error.
134146 * @throws CallfireApiException in case HTTP response code is something different from codes listed above.
135147 * @throws CallfireClientException in case error has occurred in client.
136- */ /*
148+ */
137149 public void deleteDncsFromSource (String source ) {
138150 Validate .notNull (source , "number cannot be null" );
139151 client .delete (DNC_SOURCES_PATH .replaceFirst (PLACEHOLDER , source ));
140- }*/
152+ }
141153
142154}
0 commit comments