@journeyapps-solutions/cc-util-sync-collective 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -90,7 +90,7 @@ class SyncCollective {
90
90
  let _header = SyncUtilMaster.buildHeader(options.endpoint.api_user, options.endpoint.api_pass);
91
91
  let _body = SyncUtilMaster.buildJsonBody(_object, options.endpoint.collective().name);
92
92
 
93
- console.log(`${NAME} - Syncing Object [id:${objectToSync.id}]`);
93
+ console.log(`${NAME} - Syncing Object [id:${options.objectToSync.id}]`);
94
94
  console.log(`${NAME} - URL - ` + _url);
95
95
  console.log(`${NAME} - HEADER - ` + JSON.stringify(_header));
96
96
  console.log(`${NAME} - METHOD - ` + operation);
@@ -136,7 +136,7 @@ class SyncCollective {
136
136
  let _header = SyncUtilSlave.buildHeader(_this2.config.api_user, _this2.config.api_pass);
137
137
  let _body = SyncUtilSlave.buildJsonBody(_object, _this2.config.collective);
138
138
 
139
- console.log(`${NAME} - Syncing Object [id:${objectToSync.id}]`);
139
+ console.log(`${NAME} - Syncing Object [id:${options.objectToSync}]`);
140
140
  console.log(`${NAME} - URL - ` + _url);
141
141
  console.log(`${NAME} - HEADER - ` + JSON.stringify(_header));
142
142
  console.log(`${NAME} - METHOD - ` + operation);
package/lib/sync-util.js CHANGED
@@ -12,7 +12,7 @@ class SyncUtil {
12
12
  * @return String of the url for the endpoint
13
13
  */
14
14
  buildUrl(object, url, collective) {
15
- return `${url}/objects/` + buildTableName(object, collective) + `/${object.id}.json`;
15
+ return `${url}/objects/` + this.buildTableName(object, collective) + `/${object.id}.json`;
16
16
  }
17
17
 
18
18
  /**
@@ -24,10 +24,11 @@ class SyncUtil {
24
24
  * @return Object in correct format for v4 API
25
25
  */
26
26
  buildJsonBody(object, collective) {
27
- var new_object = {};
28
- mapChoiceObjects(object);
29
- removePhotosAttachments(object);
30
- new_object[buildTableName(object, collective)] = object;
27
+ this.mapChoiceObjects(object);
28
+ this.removePhotosAttachments(object);
29
+
30
+ let new_object = {};
31
+ new_object[this.buildTableName(object, collective)] = object;
31
32
  return new_object;
32
33
  }
33
34
 
@@ -75,8 +76,9 @@ class SyncUtil {
75
76
  * @return Array with header data
76
77
  */
77
78
  buildHeader(api_user, api_pass) {
78
- header = 'Basic ' + base64.encode(this.username + ":" + this.password), header['Content-Type'] = 'application/json';
79
- return header;
79
+ let _header = {};
80
+ _header['Authorization'] = 'Basic ' + base64.encode(this.username + ":" + this.password), _header['Content-Type'] = 'application/json';
81
+ return _header;
80
82
  }
81
83
 
82
84
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@journeyapps-solutions/cc-util-sync-collective",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Sync Data between projects. Either Directly, or via Slave & Master Configuration",
5
5
  "main": "./index.js",
6
6
  "scripts": {