Skip to content

Commit fd2ef08

Browse files
Examples fixed
1 parent f1a1c97 commit fd2ef08

11 files changed

+217
-181
lines changed

api/src/main/java/com/messagebird/objects/integrations/Template.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ public void setLanguage(String language) {
4444
this.language = language;
4545
}
4646

47-
public String getWabaID() {
47+
public String getWABAID() {
4848
return wabaID;
4949
}
5050

51-
public void setWabaID(String wabaID) {
51+
public void setWABAID(String wabaID) {
5252
this.wabaID = wabaID;
5353
}
5454

api/src/test/java/com/messagebird/TestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public static Template createWhatsAppTemplate(final String templateName, final S
335335
components.add(createHSMComponentButton());
336336
template.setComponents(components);
337337

338-
template.setWabaID("testWABAID");
338+
template.setWABAID("testWABAID");
339339

340340
return template;
341341
}

examples/src/main/java/ExampleCreateTemplate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public static void main(String[] args) {
8484

8585
template.setName(args[1]);
8686
template.setLanguage("en_US");
87-
template.setWABAID(args[2])
87+
template.setWABAID(args[2]);
8888
template.setComponents(components);
8989
template.setCategory(HSMCategory.ACCOUNT_UPDATE);
9090

examples/src/main/java/ExampleFetchTemplateByNameAndLanguage.java

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -39,74 +39,3 @@ public static void main(String[] args) {
3939
}
4040
}
4141
}
42-
43-
/**
44-
* Fetch template by name and language by WABA ID
45-
*
46-
* @see <a href="https://developers.messagebird.com/api/integrations/#fetch-template-by-name-and-language">Fetch template by name and language by WABA ID</a>
47-
* @author ssk910
48-
*/
49-
public class ExampleFetchTemplateByNameAndLanguage {
50-
51-
public static void main(String[] args) {
52-
if (args.length < 4) {
53-
System.out.println("Please specify your access key, template name, language and WABA ID example : java -jar <this jar file> test_accesskey \"My template name\" \"Template language\" \"WABA ID\"");
54-
return;
55-
}
56-
57-
// First create your service object
58-
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
59-
60-
// Add the service to the client
61-
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
62-
63-
// template name, language and waba ID from input
64-
final String templateName = args[1];
65-
final String language = args[2];
66-
final String wabaID = args[3];
67-
68-
try {
69-
System.out.println("Fetching WhatsApp Template list by {name: " + templateName + ", language: " + language + ", wabaID: " + wabaID + "}");
70-
final TemplateResponse template = messageBirdClient.fetchWhatsAppTemplateBy(templateName, language, wabaID, null);
71-
System.out.println(template.toString());
72-
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
73-
exception.printStackTrace();
74-
}
75-
}
76-
}
77-
78-
/**
79-
* Fetch template by name and language for Channel ID
80-
*
81-
* @see <a href="https://developers.messagebird.com/api/integrations/#fetch-template-by-name-and-language">Fetch template by name and language for Channel ID</a>
82-
* @author ssk910
83-
*/
84-
public class ExampleFetchTemplateByNameAndLanguage {
85-
86-
public static void main(String[] args) {
87-
if (args.length < 4) {
88-
System.out.println("Please specify your access key, template name, language and Channel ID example : java -jar <this jar file> test_accesskey \"My template name\" \"Template language\" \"Channel ID\"");
89-
return;
90-
}
91-
92-
// First create your service object
93-
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
94-
95-
// Add the service to the client
96-
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
97-
98-
// template name, language and the channel ID from input
99-
final String templateName = args[1];
100-
final String language = args[2];
101-
final String channelID = args[3];
102-
103-
// Will return a template only if the channel belongs to the same WABA that the template belongs to.
104-
try {
105-
System.out.println("Fetching WhatsApp Template list by {name: " + templateName + ", language: " + language + ", channelID: " + channelID + "}");
106-
final TemplateResponse template = messageBirdClient.fetchWhatsAppTemplateBy(templateName, language, null, channelID);
107-
System.out.println(template.toString());
108-
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
109-
exception.printStackTrace();
110-
}
111-
}
112-
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import com.messagebird.MessageBirdClient;
2+
import com.messagebird.MessageBirdService;
3+
import com.messagebird.MessageBirdServiceImpl;
4+
import com.messagebird.exceptions.GeneralException;
5+
import com.messagebird.exceptions.NotFoundException;
6+
import com.messagebird.exceptions.UnauthorizedException;
7+
import com.messagebird.objects.integrations.TemplateResponse;
8+
9+
/**
10+
* Fetch template by name and language by WABA ID
11+
*
12+
* @see <a href="https://developers.messagebird.com/api/integrations/#fetch-template-by-name-and-language">Fetch template by name and language by WABA ID</a>
13+
* @author ssk910
14+
*/
15+
public class ExampleFetchTemplateByNameAndLanguageAndWABAID {
16+
17+
public static void main(String[] args) {
18+
if (args.length < 4) {
19+
System.out.println("Please specify your access key, template name, language and WABA ID example : java -jar <this jar file> test_accesskey \"My template name\" \"Template language\" \"WABA ID\"");
20+
return;
21+
}
22+
23+
// First create your service object
24+
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
25+
26+
// Add the service to the client
27+
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
28+
29+
// template name, language and waba ID from input
30+
final String templateName = args[1];
31+
final String language = args[2];
32+
final String wabaID = args[3];
33+
34+
try {
35+
System.out.println("Fetching WhatsApp Template list by {name: " + templateName + ", language: " + language + ", wabaID: " + wabaID + "}");
36+
final TemplateResponse template = messageBirdClient.fetchWhatsAppTemplateBy(templateName, language, wabaID, null);
37+
System.out.println(template.toString());
38+
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
39+
exception.printStackTrace();
40+
}
41+
}
42+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import com.messagebird.MessageBirdClient;
2+
import com.messagebird.MessageBirdService;
3+
import com.messagebird.MessageBirdServiceImpl;
4+
import com.messagebird.exceptions.GeneralException;
5+
import com.messagebird.exceptions.NotFoundException;
6+
import com.messagebird.exceptions.UnauthorizedException;
7+
import com.messagebird.objects.integrations.TemplateResponse;
8+
9+
/**
10+
* Fetch template by name and language for Channel ID
11+
*
12+
* @see <a href="https://developers.messagebird.com/api/integrations/#fetch-template-by-name-and-language">Fetch template by name and language for Channel ID</a>
13+
* @author ssk910
14+
*/
15+
public class ExampleFetchTemplateByNameAndLanguageForChannelID {
16+
17+
public static void main(String[] args) {
18+
if (args.length < 4) {
19+
System.out.println("Please specify your access key, template name, language and Channel ID example : java -jar <this jar file> test_accesskey \"My template name\" \"Template language\" \"Channel ID\"");
20+
return;
21+
}
22+
23+
// First create your service object
24+
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
25+
26+
// Add the service to the client
27+
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
28+
29+
// template name, language and the channel ID from input
30+
final String templateName = args[1];
31+
final String language = args[2];
32+
final String channelID = args[3];
33+
34+
// Will return a template only if the channel belongs to the same WABA that the template belongs to.
35+
try {
36+
System.out.println("Fetching WhatsApp Template list by {name: " + templateName + ", language: " + language + ", channelID: " + channelID + "}");
37+
final TemplateResponse template = messageBirdClient.fetchWhatsAppTemplateBy(templateName, language, null, channelID);
38+
System.out.println(template.toString());
39+
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
40+
exception.printStackTrace();
41+
}
42+
}
43+
}

examples/src/main/java/ExampleListTemplatesByName.java

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -39,76 +39,3 @@ public static void main(String[] args) {
3939
}
4040
}
4141
}
42-
43-
/**
44-
* List templates by name and WABA ID
45-
*
46-
* @see <a href="https://developers.messagebird.com/api/integrations/#list-templates-by-name">List templates by name and WABA ID</a>
47-
* @author ssk910
48-
*/
49-
public class ExampleListTemplatesByNameAndWABAID {
50-
51-
public static void main(String[] args) {
52-
if (args.length < 3) {
53-
System.out.println("Please specify your access key, template name and WABA ID example : java -jar <this jar file> test_accesskey \"My template name\" \"WABA ID\"");
54-
return;
55-
}
56-
57-
// First create your service object
58-
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
59-
60-
// Add the service to the client
61-
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
62-
63-
// template name from input
64-
final String templateName = args[1];
65-
66-
// WABA ID from input
67-
final String wabaID = args[2];
68-
69-
try {
70-
System.out.println("Retrieving WhatsApp Template list by name '" + templateName + "' and WABA ID '" + wabaID + "'");
71-
final List<TemplateResponse> templateList = messageBirdClient.getWhatsAppTemplatesBy(templateName, wabaID, null);
72-
System.out.println(templateList.toString());
73-
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
74-
exception.printStackTrace();
75-
}
76-
}
77-
}
78-
79-
/**
80-
* List templates by name and for channel ID
81-
*
82-
* @see <a href="https://developers.messagebird.com/api/integrations/#list-templates-by-name">List templates by name and for channel ID</a>
83-
* @author ssk910
84-
*/
85-
public class ExampleListTemplatesByNameAndForChannelID {
86-
87-
public static void main(String[] args) {
88-
if (args.length < 3) {
89-
System.out.println("Please specify your access key, template name and channel ID example : java -jar <this jar file> test_accesskey \"My template name\" \"Channel ID\"");
90-
return;
91-
}
92-
93-
// First create your service object
94-
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
95-
96-
// Add the service to the client
97-
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
98-
99-
// template name from input
100-
final String templateName = args[1];
101-
102-
// Channel ID from input
103-
final String channelID = args[2];
104-
105-
// Will return templates only if the channel belongs to the same WABA that the templates belongs to.
106-
try {
107-
System.out.println("Retrieving WhatsApp Template list by name '" + templateName + "' and channel ID '" + channelID + "'");
108-
final List<TemplateResponse> templateList = messageBirdClient.getWhatsAppTemplatesBy(templateName, null, channelID);
109-
System.out.println(templateList.toString());
110-
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
111-
exception.printStackTrace();
112-
}
113-
}
114-
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import com.messagebird.MessageBirdClient;
2+
import com.messagebird.MessageBirdService;
3+
import com.messagebird.MessageBirdServiceImpl;
4+
import com.messagebird.exceptions.GeneralException;
5+
import com.messagebird.exceptions.NotFoundException;
6+
import com.messagebird.exceptions.UnauthorizedException;
7+
import com.messagebird.objects.integrations.TemplateResponse;
8+
import java.util.List;
9+
10+
/**
11+
* List templates by name and for channel ID
12+
*
13+
* @see <a href="https://developers.messagebird.com/api/integrations/#list-templates-by-name">List templates by name and for channel ID</a>
14+
* @author ssk910
15+
*/
16+
public class ExampleListTemplatesByNameAndForChannelID {
17+
18+
public static void main(String[] args) {
19+
if (args.length < 3) {
20+
System.out.println("Please specify your access key, template name and channel ID example : java -jar <this jar file> test_accesskey \"My template name\" \"Channel ID\"");
21+
return;
22+
}
23+
24+
// First create your service object
25+
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
26+
27+
// Add the service to the client
28+
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
29+
30+
// template name from input
31+
final String templateName = args[1];
32+
33+
// Channel ID from input
34+
final String channelID = args[2];
35+
36+
// Will return templates only if the channel belongs to the same WABA that the templates belongs to.
37+
try {
38+
System.out.println("Retrieving WhatsApp Template list by name '" + templateName + "' and channel ID '" + channelID + "'");
39+
final List<TemplateResponse> templateList = messageBirdClient.getWhatsAppTemplatesBy(templateName, null, channelID);
40+
System.out.println(templateList.toString());
41+
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
42+
exception.printStackTrace();
43+
}
44+
}
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import com.messagebird.MessageBirdClient;
2+
import com.messagebird.MessageBirdService;
3+
import com.messagebird.MessageBirdServiceImpl;
4+
import com.messagebird.exceptions.GeneralException;
5+
import com.messagebird.exceptions.NotFoundException;
6+
import com.messagebird.exceptions.UnauthorizedException;
7+
import com.messagebird.objects.integrations.TemplateResponse;
8+
import java.util.List;
9+
10+
/**
11+
* List templates by name and WABA ID
12+
*
13+
* @see <a href="https://developers.messagebird.com/api/integrations/#list-templates-by-name">List templates by name and WABA ID</a>
14+
* @author ssk910
15+
*/
16+
public class ExampleListTemplatesByNameAndWABAID {
17+
18+
public static void main(String[] args) {
19+
if (args.length < 3) {
20+
System.out.println("Please specify your access key, template name and WABA ID example : java -jar <this jar file> test_accesskey \"My template name\" \"WABA ID\"");
21+
return;
22+
}
23+
24+
// First create your service object
25+
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
26+
27+
// Add the service to the client
28+
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
29+
30+
// template name from input
31+
final String templateName = args[1];
32+
33+
// WABA ID from input
34+
final String wabaID = args[2];
35+
36+
try {
37+
System.out.println("Retrieving WhatsApp Template list by name '" + templateName + "' and WABA ID '" + wabaID + "'");
38+
final List<TemplateResponse> templateList = messageBirdClient.getWhatsAppTemplatesBy(templateName, wabaID, null);
39+
System.out.println(templateList.toString());
40+
} catch (GeneralException | UnauthorizedException | NotFoundException | IllegalArgumentException exception) {
41+
exception.printStackTrace();
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)