-
Notifications
You must be signed in to change notification settings - Fork 5
/
WhatsappApiFactory.java
70 lines (56 loc) · 2.1 KB
/
WhatsappApiFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.whatsapp.api;
import com.whatsapp.api.impl.WhatsappBusinessCloudApi;
import com.whatsapp.api.impl.WhatsappBusinessManagementApi;
import com.whatsapp.api.impl.WhatsappEngagelabApi;
import com.whatsapp.api.impl.WhatsappEngagelabBspApi;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
/**
* A factory for creating Whatsapp api client objects.
*/
public class WhatsappApiFactory {
private WhatsappApiFactory() {
}
/**
* New instance whatsapp api factory.
*
* @return the whatsapp api factory
*/
public static WhatsappApiFactory newInstance() {
return new WhatsappApiFactory();
}
/**
* Creates a new synchronous/blocking Whatsapp business cloud api client
* @param token the token
* @return the whatsapp business cloud api
*/
public WhatsappBusinessCloudApi newBusinessCloudApi(String token) {
return new WhatsappBusinessCloudApi(token);
}
/**
* Creates a new synchronous/blocking Whatsapp business management api client
* @param token the token
* @return the whatsapp business management api
*/
public WhatsappBusinessManagementApi newBusinessManagementApi(String token) {
return new WhatsappBusinessManagementApi(token);
}
/**
* Creates a new synchronous/blocking Engagela api client
* @param devKey the devKey
* @param devSecret the devSecret
* @return the whatsapp business cloud api
*/
public WhatsappEngagelabApi newEngagelabApi(String devKey, String devSecret) {
return new WhatsappEngagelabApi(Base64.getEncoder().encodeToString((devKey + ":" + devSecret).getBytes(StandardCharsets.UTF_8)));
}
/**
* Creates a new synchronous/blocking Engagela BSP api client
* @param devKey the devKey
* @param devSecret the devSecret
* @return the whatsapp business cloud api
*/
public WhatsappEngagelabBspApi newEngagelabBspApi(String devKey, String devSecret) {
return new WhatsappEngagelabBspApi(Base64.getEncoder().encodeToString((devKey + ":" + devSecret).getBytes(StandardCharsets.UTF_8)));
}
}