46
46
import com .messagebird .objects .conversations .ConversationWebhookCreateRequest ;
47
47
import com .messagebird .objects .conversations .ConversationWebhookList ;
48
48
import com .messagebird .objects .conversations .ConversationWebhookUpdateRequest ;
49
- import com .messagebird .objects .integrations .WhatsAppTemplate ;
50
- import com .messagebird .objects .integrations .WhatsAppTemplateList ;
51
- import com .messagebird .objects .integrations .WhatsAppTemplateResponse ;
49
+ import com .messagebird .objects .integrations .Template ;
50
+ import com .messagebird .objects .integrations .TemplateList ;
51
+ import com .messagebird .objects .integrations .TemplateResponse ;
52
52
import com .messagebird .objects .voicecalls .RecordingResponse ;
53
53
import com .messagebird .objects .voicecalls .TranscriptionResponse ;
54
54
import com .messagebird .objects .voicecalls .VoiceCall ;
@@ -122,7 +122,7 @@ public class MessageBirdClient {
122
122
private static final String CONVERSATION_SEND_PATH = "/send" ;
123
123
private static final String CONVERSATION_MESSAGE_PATH = "/messages" ;
124
124
private static final String CONVERSATION_WEBHOOK_PATH = "/webhooks" ;
125
- private static final String INTEGRATIONS_WHATSAPP_PATH = "/platforms/whatsapp" ;
125
+ static final String INTEGRATIONS_WHATSAPP_PATH = "/platforms/whatsapp" ;
126
126
static final String VOICECALLSPATH = "/calls" ;
127
127
static final String LEGSPATH = "/legs" ;
128
128
static final String RECORDINGPATH = "/recordings" ;
@@ -1862,13 +1862,14 @@ public String downloadFile(String id, String filename, String basePath) throws G
1862
1862
/**
1863
1863
* Create a WhatsApp message template through messagebird.
1864
1864
*
1865
- * @param template {@link WhatsAppTemplate} object to be created
1866
- * @return {@link WhatsAppTemplateResponse} response object
1867
- * @throws UnauthorizedException if client is unauthorized
1868
- * @throws GeneralException general exception or invalid template format
1865
+ * @param template {@link Template} object to be created
1866
+ * @return {@link TemplateResponse} response object
1867
+ * @throws UnauthorizedException if client is unauthorized
1868
+ * @throws GeneralException general exception
1869
+ * @throws IllegalArgumentException invalid template format
1869
1870
*/
1870
- public WhatsAppTemplateResponse createWhatsAppTemplate (final WhatsAppTemplate template )
1871
- throws UnauthorizedException , GeneralException {
1871
+ public TemplateResponse createWhatsAppTemplate (final Template template )
1872
+ throws UnauthorizedException , GeneralException , IllegalArgumentException {
1872
1873
template .validate ();
1873
1874
1874
1875
String url = String .format (
@@ -1877,7 +1878,7 @@ public WhatsAppTemplateResponse createWhatsAppTemplate(final WhatsAppTemplate te
1877
1878
INTEGRATIONS_WHATSAPP_PATH ,
1878
1879
TEMPLATES_PATH
1879
1880
);
1880
- return messageBirdService .sendPayLoad (url , template , WhatsAppTemplateResponse .class );
1881
+ return messageBirdService .sendPayLoad (url , template , TemplateResponse .class );
1881
1882
}
1882
1883
1883
1884
/**
@@ -1889,15 +1890,15 @@ public WhatsAppTemplateResponse createWhatsAppTemplate(final WhatsAppTemplate te
1889
1890
* @throws UnauthorizedException if client is unauthorized
1890
1891
* @throws GeneralException general exception
1891
1892
*/
1892
- public WhatsAppTemplateList listWhatsAppTemplates (final int offset , final int limit )
1893
+ public TemplateList listWhatsAppTemplates (final int offset , final int limit )
1893
1894
throws UnauthorizedException , GeneralException {
1894
1895
String url = String .format (
1895
1896
"%s%s%s" ,
1896
1897
INTEGRATIONS_BASE_URL_V3 ,
1897
1898
INTEGRATIONS_WHATSAPP_PATH ,
1898
1899
TEMPLATES_PATH
1899
1900
);
1900
- return messageBirdService .requestList (url , offset , limit , WhatsAppTemplateList .class );
1901
+ return messageBirdService .requestList (url , offset , limit , TemplateList .class );
1901
1902
}
1902
1903
1903
1904
/**
@@ -1907,7 +1908,7 @@ public WhatsAppTemplateList listWhatsAppTemplates(final int offset, final int li
1907
1908
* @throws UnauthorizedException if client is unauthorized
1908
1909
* @throws GeneralException general exception
1909
1910
*/
1910
- public WhatsAppTemplateList listWhatsAppTemplates () throws UnauthorizedException , GeneralException {
1911
+ public TemplateList listWhatsAppTemplates () throws UnauthorizedException , GeneralException {
1911
1912
final int offset = 0 ;
1912
1913
final int limit = 10 ;
1913
1914
@@ -1923,7 +1924,7 @@ public WhatsAppTemplateList listWhatsAppTemplates() throws UnauthorizedException
1923
1924
* @throws GeneralException general exception
1924
1925
* @throws NotFoundException if template name is not found
1925
1926
*/
1926
- public List <WhatsAppTemplateResponse > getWhatsAppTemplatesBy (final String templateName )
1927
+ public List <TemplateResponse > getWhatsAppTemplatesBy (final String templateName )
1927
1928
throws GeneralException , UnauthorizedException , NotFoundException {
1928
1929
if (templateName == null ) {
1929
1930
throw new IllegalArgumentException ("Template name must be specified." );
@@ -1936,8 +1937,7 @@ public List<WhatsAppTemplateResponse> getWhatsAppTemplatesBy(final String templa
1936
1937
TEMPLATES_PATH
1937
1938
);
1938
1939
1939
- final WhatsAppTemplateResponse [] templateResponses = messageBirdService .requestByID (url , templateName , WhatsAppTemplateResponse [].class );
1940
- return Arrays .asList (templateResponses );
1940
+ return messageBirdService .requestByIdAsList (url , templateName , TemplateResponse .class );
1941
1941
}
1942
1942
1943
1943
/**
@@ -1951,7 +1951,7 @@ public List<WhatsAppTemplateResponse> getWhatsAppTemplatesBy(final String templa
1951
1951
* @throws GeneralException general exception
1952
1952
* @throws NotFoundException if template name and language are not found
1953
1953
*/
1954
- public WhatsAppTemplateResponse fetchWhatsAppTemplateBy (final String templateName , final String language )
1954
+ public TemplateResponse fetchWhatsAppTemplateBy (final String templateName , final String language )
1955
1955
throws GeneralException , UnauthorizedException , NotFoundException {
1956
1956
if (templateName == null || language == null ) {
1957
1957
throw new IllegalArgumentException ("Template name and language must be specified." );
@@ -1965,7 +1965,7 @@ public WhatsAppTemplateResponse fetchWhatsAppTemplateBy(final String templateNam
1965
1965
templateName ,
1966
1966
language
1967
1967
);
1968
- return messageBirdService .request (url , WhatsAppTemplateResponse .class );
1968
+ return messageBirdService .request (url , TemplateResponse .class );
1969
1969
}
1970
1970
1971
1971
0 commit comments