merchi_sdk_js 0.0.51 → 0.0.53

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merchi_sdk_js",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "main": "src/merchi.js",
6
6
  "module": "src/merchi.js",
package/src/draft.js CHANGED
@@ -5,6 +5,7 @@ import { Job } from './job.js';
5
5
  import { User } from './user.js';
6
6
  import { DraftComment } from './draft_comment.js';
7
7
  import { MerchiFile } from './merchi_file.js';
8
+ import { DraftTemplate } from './draft_template.js';
8
9
 
9
10
  export function Draft() {
10
11
  this.resource = '/drafts';
@@ -15,6 +16,7 @@ export function Draft() {
15
16
  addPropertyTo(this, 'sharedWithJob', Job);
16
17
  addPropertyTo(this, 'designer', User);
17
18
  addPropertyTo(this, 'file', MerchiFile);
19
+ addPropertyTo(this, 'draftTemplates', DraftTemplate);
18
20
  addPropertyTo(this, 'date');
19
21
  addPropertyTo(this, 'accepted');
20
22
  addPropertyTo(this, 'changesRequested');
@@ -0,0 +1,35 @@
1
+ import { addPropertyTo, serialise, create, enumerateFiles,
2
+ fromJson } from './model.js';
3
+ import { MerchiFile } from './merchi_file.js';
4
+ import { Product } from './product.js';
5
+ import { DraftTemplate } from './draft_template.js';
6
+
7
+ export function DraftPreview() {
8
+ this.resource = '/draft_previews';
9
+ this.json = 'draftPreview';
10
+
11
+ addPropertyTo(this, 'id');
12
+ addPropertyTo(this, 'file', MerchiFile);
13
+ addPropertyTo(this, 'product', Product);
14
+ addPropertyTo(this, 'description');
15
+ addPropertyTo(this, 'name');
16
+ addPropertyTo(this, 'date');
17
+ addPropertyTo(this, 'height');
18
+ addPropertyTo(this, 'width');
19
+ addPropertyTo(this, 'draftTemplates', DraftTemplate);
20
+
21
+ this.create = function (options) {
22
+ var data = serialise(this),
23
+ self = this;
24
+ function handleResponse(result) {
25
+ options.success(fromJson(self, result[self.json]));
26
+ }
27
+ create({resource: this.resource,
28
+ parameters: data[0],
29
+ files: enumerateFiles(data[1]),
30
+ success: handleResponse,
31
+ as_domain: options.as_domain,
32
+ error: options.error,
33
+ embed: options.embed});
34
+ };
35
+ }
@@ -13,10 +13,10 @@ export function DraftTemplate() {
13
13
  addPropertyTo(this, 'id');
14
14
  addPropertyTo(this, 'product', Product);
15
15
  addPropertyTo(this, 'file', MerchiFile);
16
+ addPropertyTo(this, 'design', MerchiFile);
16
17
  addPropertyTo(this, 'job', Job);
17
18
  addPropertyTo(this, 'selectedByVariationFieldOptions', VariationFieldsOption);
18
19
  addPropertyTo(this, 'editedByVariationFields', VariationField);
19
- addPropertyTo(this, 'draftPreviews', MerchiFile);
20
20
  addPropertyTo(this, 'date');
21
21
  addPropertyTo(this, 'name');
22
22
  addPropertyTo(this, 'description');