Skip to content

Instantly share code, notes, and snippets.

@slavahatnuke
Created December 15, 2015 13:42
Show Gist options
  • Save slavahatnuke/fa686c058fa83ccd807d to your computer and use it in GitHub Desktop.
Save slavahatnuke/fa686c058fa83ccd807d to your computer and use it in GitHub Desktop.
var url = "http://connect.bookt.com/ws/?apikey=" + key + "&method=" + method + "&entity=" + entity;
var moment = require('moment');
var request = require('request');
request({url: url}, function (error, response, body) {
console.log('>> booking',body);
var date = new Date();
var checkIn = moment(date).add(2, 'weeks');
var checkOut = moment(checkIn).add(2, 'days');
var data = {
PropertyID: 197688,
Renter: {
FirstName: 'TEST FIRSTNAME',
LastName: 'TEST LASTNAME',
PrimaryEmail: 'test@test.com'
},
CheckIn: checkIn.format('YYYY-MM-DD'),
CheckOut: checkOut.format('YYYY-MM-DD')
};
console.log('>> payload', data);
var url = "http://connect.bookt.com/ws/?method=save&entity=booking&apikey=" + key;
request.post(url, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
data: JSON.stringify(data)
}
}, function (error, response, body) {
console.log('save >> ', body);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment