Commit 52c0fa78 authored by Aurel's avatar Aurel

coding style + use of clearroad code

parent 3c0a2748
function ClearRoadBillingPeriodRegistration() {
if (!(this instanceof ClearRoadBillingPeriodRegistration)) {
return new ClearRoadBillingPeriodRegistration();
}
// cleanup the local storage before each run
var DATABASE = "cr-billing-period-registration";
// indexedDB.deleteDatabase('jio:' + DATABASE);
this.jio = jIO.createJIO({
type: "replicate",
use_remote_post: false,
conflict_handling: 1,
check_local_modification: false,
check_local_creation: true,
check_local_deletion: false,
check_remote_modification: false,
check_remote_creation: false,
check_remote_deletion: false,
local_sub_storage: {
type: "mapping",
map_id: ["equalSubProperty", "reference"],
sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "memory",
database: DATABASE
}
}
}
},
remote_sub_storage: {
type: "mapping",
map_id: ["equalSubProperty", "reference"],
mapping_dict: {"portal_type": ["equalValue", "Billing Period Message"],
"parent_relative_url": ["equalValue", "billing_period_message_module"]},
sub_storage: {
type: "erp5",
url: "https://softinst69465.host.vifib.net/erp5/web_site_module/hateoas",
default_view_reference: "jio_view"
}
}
});
}
ClearRoadBillingPeriodRegistration.prototype = new ClearRoadBillingPeriodRegistration();
ClearRoadBillingPeriodRegistration.prototype.constructor = ClearRoadBillingPeriodRegistration;
ClearRoadBillingPeriodRegistration.prototype.post = function(){
return this.jio.post.apply(this.jio, arguments);
};
ClearRoadBillingPeriodRegistration.prototype.sync = function(){
return this.jio.repair.apply(this.jio, arguments);
};
module.exports = ClearRoadBillingPeriodRegistration
// server.js
// where your node app starts
URI = require("uri-js");
RSVP = require('rsvp');
UriTemplate = require("uritemplate");
moment = require('moment');
navigator = require('navigator');
Rusha = require('rusha');
FormData = require('formdata');
atob = require('atob');
FileReader = require("FileReader");
Blob = require("Blob");
localStorage = require('node-localstorage');
window = global;
sessionStorage = {};
"use strict"
global.URI = require("uri-js");
global.RSVP = require('rsvp');
global.UriTemplate = require("uritemplate");
global.moment = require('moment');
global.navigator = require('navigator');
global.Rusha = require('rusha');
global.FormData = require('formdata');
global.atob = require('atob');
global.FileReader = require("FileReader");
global.Blob = require("Blob");
global.localStorage = require('node-localstorage');
global.btoa = require('btoa');
global.XMLHttpRequest = require('w3c-xmlhttprequest').XMLHttpRequest
global.window = global;
global.sessionStorage = {};
var jIO = require('jio');
var ClearRoadBillingPeriodRegistration = require("clearroad");
var cr = new ClearRoadBillingPeriodRegistration();
console.log("init");
cr.post({
"reference" : "Q42",
"start_date" : "2017-02-01T00:00:00Z",
"stop_date" : "2017-03-01T00:00:00Z"
}).push(function (){
console.log("start sync...");
return cr.sync();
}).push(function (){
console.info("Sync done");
}, function (error) {
console.info("Error :");
console.warn(error.stack)
console.warn(error);
});
// init project
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment