-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathExampleReadHlr.java
More file actions
47 lines (38 loc) · 1.68 KB
/
ExampleReadHlr.java
File metadata and controls
47 lines (38 loc) · 1.68 KB
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
import com.messagebird.MessageBirdClient;
import com.messagebird.MessageBirdService;
import com.messagebird.MessageBirdServiceImpl;
import com.messagebird.exceptions.NotFoundException;
import com.messagebird.objects.Hlr;
import com.messagebird.exceptions.GeneralException;
import com.messagebird.exceptions.UnauthorizedException;
import java.math.BigInteger;
/**
* Created by rvt on 1/7/15.
*/
public class ExampleReadHlr {
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("Please specify your access key and phone in that order example : java -jar <this jar file> test_accesskey 31612345678");
return;
}
// First create your service object
final MessageBirdService wsr = new MessageBirdServiceImpl(args[0]);
// Add the service to the client
final MessageBirdClient messageBirdClient = new MessageBirdClient(wsr);
try {
// Get Hlr using msgId and msisdn
System.out.println("Retrieving HLR:");
final Hlr hlr1 = messageBirdClient.getRequestHlr(new BigInteger(args[1]), "ExampleReadHlr reference");
System.out.println(hlr1.toString());
// Get Hlr using the id only
System.out.println("Now using returned id to get Hlr:");
final Hlr hlr2 = messageBirdClient.getViewHlr(hlr1.getId());
System.out.println(hlr2.toString());
} catch (UnauthorizedException | GeneralException | NotFoundException exception) {
if (exception.getErrors() != null) {
System.out.println(exception.getErrors().toString());
}
exception.printStackTrace();
}
}
}