forked from lob/lob-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPostCardTests.java
More file actions
57 lines (47 loc) · 2.17 KB
/
Copy pathPostCardTests.java
File metadata and controls
57 lines (47 loc) · 2.17 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
48
49
50
51
52
53
54
55
56
57
import java.util.HashMap;
import java.util.Map;
import com.lob.Lob;
import com.lob.exception.LobException;
import com.lob.model.Postcard;
import com.lob.model.PostcardCollection;
public class PostCardTests {
@SuppressWarnings("deprecation")
public static void main(String[] args) {
Lob.apiKey = "test_0dc8d51e0acffcb1880e0f19c79b2f5b0cc:";
String id = "psc_5c002b86ce47537a";
try {
Postcard p1 = Postcard.retrieve(id, Lob.apiKey);
System.out.println(p1);
Map<String, java.lang.Object> ObjectMap = new HashMap<String, java.lang.Object>();
ObjectMap.put("name", "Demo Postcard job");
ObjectMap.put("to[name]", "Harry Zhang");
ObjectMap.put("to[address_line1]", "123 Test Street");
ObjectMap.put("to[address_city]", "Mountain View");
ObjectMap.put("to[address_state]", "CA");
ObjectMap.put("to[address_zip]", "94041");
ObjectMap.put("to[address_country]", "US");
ObjectMap.put("from[name]", "Harry Zhang");
ObjectMap.put("from[address_line1]", "123 Test Avenue");
ObjectMap.put("from[address_city]", "Seattle");
ObjectMap.put("from[address_state]", "WA");
ObjectMap.put("from[address_zip]", "94041");
ObjectMap.put("from[address_country]", "US");
ObjectMap.put("front", "@C:/Data/Lob/postcardfront.pdf");
ObjectMap.put("back", "https://www.lob.com/postcardback.pdf");
Postcard p2 = Postcard.create(ObjectMap, Lob.apiKey);
System.out.println(p2);
Map<String, java.lang.Object> listParams = new HashMap<String, java.lang.Object>();
listParams.put("count", 2);
listParams.put("offset", 3);
PostcardCollection ac = Postcard.all(listParams, Lob.apiKey);
System.out.println(ac);
} catch (LobException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}