-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPokeToWordpress.js
40 lines (28 loc) · 1.19 KB
/
PokeToWordpress.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
function pokeToWordPressOrders(data, user_id) {
console.log("Wordpress " + data);
var encodedAuthInformation = Utilities.base64Encode(apiusername + ":" + apipassword);
var headers = { "Authorization": "Basic " + encodedAuthInformation };
var options = {
'method': 'post',
'contentType': 'application/json',
'headers': headers, // Convert the JavaScript object to a JSON string.
'payload': JSON.stringify(data)
};
apiurl = "https://www." + apidomain + "/wp-json/wc/v3/orders/" + user_id
var response = UrlFetchApp.fetch(apiurl, options);
console.log(response);
}
function pokeToWordPressProducts(data, product_id) {
//console.log("Wordpress " + data);
var encodedAuthInformation = Utilities.base64Encode(apiusername + ":" + apipassword);
var headers = { "Authorization": "Basic " + encodedAuthInformation };
var options = {
'method': 'post',
'contentType': 'application/json',
'headers': headers, // Convert the JavaScript object to a JSON string.
'payload': JSON.stringify(data)
};
apiurl = "https://www." + apidomain + "/wp-json/wc/v3/products/" + product_id
var response = UrlFetchApp.fetch(apiurl, options);
// console.log(response);
}