-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathterritories.js
116 lines (95 loc) · 2.7 KB
/
territories.js
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const Route4Me = require("route4me-node");
const apiKey = "11111111111111111111111111111111";
const route4me = new Route4Me(apiKey);
/////////////////////////////////////////////////////////
// Create a Territory
// a) Create a new territory with a circular shape
//
const data = {
territory_name: "Test Circle Territory",
territory_color: "ff0000",
territory: {
type: "circle",
data: ["37.569752822786455,-77.47833251953125", "5000"]
}
};
route4me.Territories.create(data, (err, data) => {
console.log(data);
});
// b) Create a new territory with a polygon shape
//
// const data = {
// territory_name: "Test Polygon Territory",
// territory_color: "ff0000",
// territory: {
// type: "poly",
// data: [
// "37.769752822786455,-77.67833251953125",
// "37.75886716305343,-77.68974800109863",
// "37.74763966054455,-77.6917221069336",
// "37.74655084306813,-77.68863220214844",
// "37.7502255383101,-77.68125076293945",
// "37.74797991274437,-77.67498512268066",
// "37.73327960206065,-77.6411678314209",
// "37.74430510679532,-77.63172645568848",
// "37.76641925847049,-77.66846199035645"
// ]
// }
// };
// route4me.Territories.create(data, (err, data) => {
// console.log(data);
// });
// c) Create a new territory with a rectangular shape
//
// const data = {
// territory_name: "Test Rect Territory",
// territory_color: "ff0000",
// territory: {
// type: "rect",
// data: [
// "43.51668853502909,-109.3798828125",
// "46.98025235521883,-101.865234375"
// ]
// }
// };
// route4me.Territories.create(data, (err, data) => {
// console.log(data);
// });
/////////////////////////////////////////////////////////
// Get a Territory
//
// const territory_id = "B3952ADA31C520D6D43F6DE3E8AAA2AC";
// const options = {
// includeAddresses: true,
// includeOrders: true
// };
// route4me.Territories.get(territory_id, options, (err, data) => {
// console.log(data);
// });
/////////////////////////////////////////////////////////
// Get Multiple Territories
//
// route4me.Territories.get((err, data) => {
// console.log(data);
// });
/////////////////////////////////////////////////////////
// Remove a Territory
//
// const territory_id = "B3952ADA31C520D6D43F6DE3E8AAA2AC";
// route4me.Territories.remove(territory_id, (err, data) => {
// console.log(data);
// });
/////////////////////////////////////////////////////////
// Update a Territory
//
// const territory_id = "B3952ADA31C520D6D43F6DE3E8AAA2AC";
// const data = {
// territory_name: "Test Territory",
// territory: {
// type: "circle",
// data: ["37.569752822786455,-77.47833251953125", "5000"]
// }
// };
// route4me.Territories.update(territory_id, data, (err, data) => {
// console.log(data);
// });