-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathContentTypeService.js
697 lines (647 loc) · 27.4 KB
/
ContentTypeService.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
/* global define */
define(["structures/ContentTypeGroupInputStruct", "structures/ContentTypeCreateStruct", "structures/ContentTypeUpdateStruct",
"structures/FieldDefinitionCreateStruct", "structures/FieldDefinitionUpdateStruct", "utils/uriparse"],
function (ContentTypeGroupInputStruct, ContentTypeCreateStruct, ContentTypeUpdateStruct,
FieldDefinitionCreateStruct, FieldDefinitionUpdateStruct, parseUriTemplate) {
"use strict";
/**
* Creates an instance of content type service object. Should be retrieved from CAPI instance (see example).
*
* ## Note on the *callbacks* usage
*
* The **callback** argument of the service methods always take 2 arguments:
*
* * **error** either `false` or {{#crossLink "CAPIError"}}CAPIError{{/crossLink}} object when an error occurred
*
* * **response** the {{#crossLink "Response"}}Response{{/crossLink}} object
*
* Example:
*
* var contentTypeGroupCreateStruct = contentTypeService.newContentTypeGroupInputStruct(
* "new-group-id"
* );
*
* contentTypeService..createContentTypeGroup(
* "/api/ezp/v2/content/typegroups",
* contentTypeGroupCreateStruct,
* function (error, response) {
* if (error) {
* console.log('An error occurred', error);
* } else {
* console.log('Success!', response);
* }
* });
*
* @class ContentTypeService
* @constructor
* @param connectionManager {ConnectionManager} connection manager that will be used to send requests to REST service
* @param discoveryService {DiscoveryService} discovery service is used for urls auto-discovery automation
* @example
* var contentTypeService = jsCAPI.getContentTypeService();
*/
var ContentTypeService = function (connectionManager, discoveryService) {
this._connectionManager = connectionManager;
this._discoveryService = discoveryService;
};
// ******************************
// Structures
// ******************************
/**
* Returns content type group create structure
*
* @method newContentTypeGroupInputStruct
* @param identifier {String} unique content type group identifer (e.g. "my-group")
* @return {ContentTypeGroupInputStruct}
*/
ContentTypeService.prototype.newContentTypeGroupInputStruct = function (identifier) {
return new ContentTypeGroupInputStruct(identifier);
};
/**
* @method newContentTypeCreateStruct
* @param identifier {String} unique content type identifer (e.g. "my-type")
* @param languageCode {String} The language code (eng-GB, fre-FR, ...)
* @param names {Array} Multi language value (see example)
* @return {ContentTypeCreateStruct}
* @example
* var contentTypeCreateStruct = contentTypeService.newContentTypeCreateStruct(
* "some-id", "eng-US", [{
* "_languageCode":"eng-US",
* "#text":"Some Name"
* }]
* );
*/
ContentTypeService.prototype.newContentTypeCreateStruct = function (identifier, languageCode, names) {
return new ContentTypeCreateStruct(identifier, languageCode, names);
};
/**
* @method newContentTypeUpdateStruct
* @return {ContentTypeUpdateStruct}
*/
ContentTypeService.prototype.newContentTypeUpdateStruct = function () {
return new ContentTypeUpdateStruct();
};
/**
* @method newFieldDefinitionCreateStruct
* @param identifier {String} unique field definiton identifer (e.g. "my-field")
* @param fieldType {String} identifier of existing field type (e.g. "ezstring", "ezdate")
* @param fieldGroup {String} identifier of existing field group (e.g. "content", "meta")
* @param names {Array} Multi language value (see example)
* @return {FieldDefinitionCreateStruct}
* @example
* var fieldDefinition = contentTypeService.newFieldDefinitionCreateStruct(
* "my-new-field", "ezstring", "content", [{
* "_languageCode":"eng-US",
* "#text":"Subtitle"
* }]
* );
*/
ContentTypeService.prototype.newFieldDefinitionCreateStruct = function (identifier, fieldType, fieldGroup, names) {
return new FieldDefinitionCreateStruct(identifier, fieldType, fieldGroup, names);
};
/**
* @method newFieldDefinitionUpdateStruct
* @return {FieldDefinitionUpdateStruct}
*/
ContentTypeService.prototype.newFieldDefinitionUpdateStruct = function () {
return new FieldDefinitionUpdateStruct();
};
// ******************************
// Content Types Groups management
// ******************************
/**
* Create a content type group
*
* @method createContentTypeGroup
* @param contentTypeGroups {String} link to root ContentTypeGroups resource (should be auto-discovered)
* @param contentTypeGroupCreateStruct {ContentTypeGroupInputStruct} object describing the new group to be created
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
* @example
*
*
* var contentTypeGroupCreateStruct = contentTypeService.newContentTypeGroupInputStruct(
* "new-group-id"
* );
*
* contentTypeService.createContentTypeGroup(
* "/api/ezp/v2/content/typegroups",
* contentTypeGroupCreateStruct,
* callback
* );
*/
ContentTypeService.prototype.createContentTypeGroup = function (contentTypeGroups, contentTypeGroupCreateStruct, callback) {
this._connectionManager.request(
"POST",
contentTypeGroups,
JSON.stringify(contentTypeGroupCreateStruct.body),
contentTypeGroupCreateStruct.headers,
callback
);
};
/**
* Load all content type groups
*
* @method loadContentTypeGroups
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentTypeGroups = function (callback) {
var that = this;
this._discoveryService.getInfoObject('contentTypeGroups', function (error, xhr) {
if (error) {
callback(error);
return;
}
that._connectionManager.request(
"GET",
xhr._href,
"",
{"Accept": "application/vnd.ez.api.ContentTypeGroupList+json"},
callback
);
});
};
/**
* Load single content type group
*
* @method loadContentTypeGroup
* @param contentTypeGroupId {String} target content type group identifier (e.g. "/api/ezp/v2/content/types/100")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentTypeGroup = function (contentTypeGroupId, callback) {
this._connectionManager.request(
"GET",
contentTypeGroupId,
"",
{"Accept": "application/vnd.ez.api.ContentTypeGroup+json"},
callback
);
};
/**
* Update a content type group
*
* @method updateContentTypeGroup
* @param contentTypeGroupId {String} target content type group identifier (e.g. "/api/ezp/v2/content/types/100")
* @param contentTypeGroupUpdateStruct {ContentTypeGroupInputStruct} object describing changes to the content type group
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.updateContentTypeGroup = function (contentTypeGroupId, contentTypeGroupUpdateStruct, callback) {
this._connectionManager.request(
"PATCH",
contentTypeGroupId,
JSON.stringify(contentTypeGroupUpdateStruct.body),
contentTypeGroupUpdateStruct.headers,
callback
);
};
/**
* Delete content type group
*
* @method deleteContentTypeGroup
* @param contentTypeGroupId {String}
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.deleteContentTypeGroup = function (contentTypeGroupId, callback) {
this._connectionManager.request(
"DELETE",
contentTypeGroupId,
"",
{},
callback
);
};
/**
* Loads Content Types Info or Content Types in a given Content Type Group.
*
* @method loadContentTypes
* @param contentTypeGroupId {String} target content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")
* @param [acceptHeader] {String} Optional accept header value. Set it to
* `application/vnd.ez.api.ContentTypeList+json` to load the Content Types
* otherwise the default accept is used and this methods loads the Content
* Types Info instead.
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentTypes = function (contentTypeGroupId, acceptHeader, callback) {
var that = this;
if ( !callback ) {
callback = acceptHeader;
acceptHeader = null;
}
this.loadContentTypeGroup(
contentTypeGroupId,
function (error, contentTypeGroupResponse) {
if (error) {
callback(error, contentTypeGroupResponse);
return;
}
var contentTypeGroup = contentTypeGroupResponse.document.ContentTypeGroup;
that._connectionManager.request(
"GET",
contentTypeGroup.ContentTypes._href,
"",
{"Accept": acceptHeader ? acceptHeader : contentTypeGroup.ContentTypes["_media-type"]},
callback
);
}
);
};
/**
* @method loadContentTypeGroupByIdentifier
* @param contentTypeGroups {String} link to root ContentTypeGroups resource (should be auto-discovered)
* @param identifier {String} target content type group identifier (e.g. "content")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentTypeGroupByIdentifier = function (contentTypeGroups, identifier, callback) {
this._connectionManager.request(
"GET",
contentTypeGroups + "?identifier=" + identifier,
"",
{"Accept": "application/vnd.ez.api.ContentTypeGroup+json"},
callback
);
};
// ******************************
// Content Types management
// ******************************
/**
* Create a content type
*
* @method createContentType
* @param contentTypeGroupId {String} target content type group identifier (e.g. "/api/ezp/v2/content/typegroups/1")
* @param contentTypeCreateStruct {ContentTypeCreateStruct} object describing the new content type to be created
* @param publish {Boolean} weather the content type should be immediately published or not
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
* @example
*
* var contentTypeCreateStruct, fieldDefinition;
*
* contentTypeCreateStruct = contentTypeService.newContentTypeCreateStruct(
* "some-id", "eng-US", [{
* "_languageCode":"eng-US",
* "#text":"Some Name"
* }]
* );
*
* fieldDefinition = contentTypeService.newFieldDefinitionCreateStruct(
* "my-new-field", "ezstring", "content", [{
* "_languageCode":"eng-US",
* "#text":"Subtitle"
* }]
* );
*
* contentTypeCreateStruct.body.ContentTypeCreate.FieldDefinitions.FieldDefinition.push(fieldDefinition.body.FieldDefinitionCreate);
*
* contentTypeService.createContentType(
* "/api/ezp/v2/content/typegroups/1",
* contentTypeCreateStruct,
* true,
* callback
* );
*/
ContentTypeService.prototype.createContentType = function (contentTypeGroupId, contentTypeCreateStruct, publish, callback) {
var that = this;
this.loadContentTypeGroup(
contentTypeGroupId,
function (error, contentTypeGroupResponse) {
if (error) {
callback(error, contentTypeGroupResponse);
return;
}
var contentTypeGroup = contentTypeGroupResponse.document.ContentTypeGroup,
parameters = (publish === true) ? "?publish=true": "";
that._connectionManager.request(
"POST",
contentTypeGroup.ContentTypes._href + parameters,
JSON.stringify(contentTypeCreateStruct.body),
contentTypeCreateStruct.headers,
callback
);
}
);
};
/**
* Make a copy of the target content type
*
* @method copyContentType
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.copyContentType = function (contentTypeId, callback) {
this._connectionManager.request(
"COPY",
contentTypeId,
"",
{},
callback
);
};
/**
* Load the target content type
*
* @method loadContentType
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentType = function (contentTypeId, callback) {
this._connectionManager.request(
"GET",
contentTypeId,
"",
{"Accept": "application/vnd.ez.api.ContentType+json"},
callback
);
};
/**
* Load content type by the string identifier
*
* @method loadContentTypeByIdentifier
* @param identifier {String} target content type string identifier (e.g. "blog")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentTypeByIdentifier = function (identifier, callback) {
var that = this;
this._discoveryService.getInfoObject(
"contentTypeByIdentifier",
function (error, contentTypeByIdentifier) {
if (error) {
callback(error, contentTypeByIdentifier);
return;
}
that._connectionManager.request(
"GET",
parseUriTemplate(contentTypeByIdentifier._href, {identifier: identifier}),
"",
{"Accept": "application/vnd.ez.api.ContentTypeInfoList+json"},
callback
);
}
);
};
/**
* Delete the target content type
*
* @method deleteContentType
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.deleteContentType = function (contentTypeId, callback) {
this._connectionManager.request(
"DELETE",
contentTypeId,
"",
{},
callback
);
};
/**
* Load content type groups of the target content type
*
* @method loadGroupsOfContentType
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadGroupsOfContentType = function (contentTypeId, callback) {
this._connectionManager.request(
"GET",
contentTypeId + '/groups',
"",
{"Accept": "application/vnd.ez.api.ContentTypeGroupRefList+json"},
callback
);
};
/**
* Assign the target content type to the target content type group
*
* @method assignContentTypeGroup
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param groupId{String} target content type group identifier (e.g. "/api/ezp/v2/content/typegroups/2")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.assignContentTypeGroup = function (contentTypeId, groupId, callback) {
this._connectionManager.request(
"POST",
contentTypeId + "/groups" + "?group=" + groupId,
"",
{},
callback
);
};
/**
* Remove content type assignment to the target content type group
*
* @method unassignContentTypeGroup
* @param contentTypeAssignedGroupId {String} target content type group assignment (e.g. "/api/ezp/v2/content/types/18/groups/1")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.unassignContentTypeGroup = function (contentTypeAssignedGroupId, callback) {
this._connectionManager.request(
"DELETE",
contentTypeAssignedGroupId,
"",
{},
callback
);
};
// ******************************
// Drafts management
// ******************************
/**
* Create a new content type draft based on the target content type
*
* @method createContentTypeDraft
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param contentTypeUpdateStruct {ContentTypeUpdateStruct} object describing changes to the content type
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
* @example
* var contentTypeUpdateStruct = contentTypeService.newContentTypeUpdateStruct();
*
* contentTypeUpdateStruct.names = {};
* contentTypeUpdateStruct.names.value = [{
* "_languageCode":"eng-US",
* "#text":"My changed content type"
* }]
*
* contentTypeService.createContentTypeDraft(
* "/api/ezp/v2/content/types/18",
* contentTypeUpdateStruct,
* callback
* );
*/
ContentTypeService.prototype.createContentTypeDraft = function (contentTypeId, contentTypeUpdateStruct, callback) {
this._connectionManager.request(
"POST",
contentTypeId,
JSON.stringify(contentTypeUpdateStruct.body),
contentTypeUpdateStruct.headers,
callback
);
};
/**
* Load draft of the target content type
*
* @method loadContentTypeDraft
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadContentTypeDraft = function (contentTypeId, callback) {
this._connectionManager.request(
"GET",
contentTypeId + "/draft",
"",
{"Accept": "application/vnd.ez.api.ContentType+json"},
callback
);
};
/**
* Update the target content type draft metadata. This method does not handle field definitions
*
* @method updateContentTypeDraftMetadata
* @param contentTypeDraftId {String} target content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
* @param contentTypeUpdateStruct {ContentTypeUpdateStruct} object describing changes to the draft
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.updateContentTypeDraftMetadata = function (contentTypeDraftId, contentTypeUpdateStruct, callback) {
this._connectionManager.request(
"PATCH",
contentTypeDraftId,
JSON.stringify(contentTypeUpdateStruct.body),
contentTypeUpdateStruct.headers,
callback
);
};
/**
* Publish the target content type draft
*
* @method publishContentTypeDraft
* @param contentTypeDraftId {String} target content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.publishContentTypeDraft = function (contentTypeDraftId, callback) {
this._connectionManager.request(
"PUBLISH",
contentTypeDraftId,
"",
{},
callback
);
};
/**
* Delete the target content type draft
*
* @method deleteContentTypeDraft
* @param contentTypeDraftId {String} target content type draft identifier (e.g. "/api/ezp/v2/content/types/18/draft")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.deleteContentTypeDraft = function (contentTypeDraftId, callback) {
this._connectionManager.request(
"DELETE",
contentTypeDraftId,
"",
{},
callback
);
};
// ******************************
// Field Definitions management
// ******************************
/**
* Add a new field definition to the target Content Type draft
*
* @method addFieldDefinition
* @param contentTypeId {String} target content type identifier (e.g. "/api/ezp/v2/content/types/18")
* @param fieldDefinitionCreateStruct {FieldDefinitionCreateStruct} object describing the new field definition to be created
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.addFieldDefinition = function (contentTypeId, fieldDefinitionCreateStruct, callback) {
var that = this;
this.loadContentTypeDraft(
contentTypeId,
function (error, contentTypeDraftResponse) {
if (error) {
callback(error, contentTypeDraftResponse);
return;
}
var contentTypeDraftFieldDefinitions = contentTypeDraftResponse.document.ContentType.FieldDefinitions;
that._connectionManager.request(
"POST",
contentTypeDraftFieldDefinitions._href,
JSON.stringify(fieldDefinitionCreateStruct.body),
fieldDefinitionCreateStruct.headers,
callback
);
}
);
};
/**
* Load the target field definition
*
* @method loadFieldDefinition
* @param fieldDefinitionId {String} target field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.loadFieldDefinition = function (fieldDefinitionId, callback) {
this._connectionManager.request(
"GET",
fieldDefinitionId,
"",
{"Accept": "application/vnd.ez.api.FieldDefinition+json"},
callback
);
};
/**
* Update the target (existing) field definition
*
* @method updateFieldDefinition
* @param fieldDefinitionId {String} target field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
* @param fieldDefinitionUpdateStruct {FieldDefinitionUpdateStruct} object describing changes to the target field definition
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.updateFieldDefinition = function (fieldDefinitionId, fieldDefinitionUpdateStruct, callback) {
this._connectionManager.request(
"PATCH",
fieldDefinitionId,
JSON.stringify(fieldDefinitionUpdateStruct.body),
fieldDefinitionUpdateStruct.headers,
callback
);
};
/**
* Delete existing field definition
*
* @method deleteFieldDefinition
* @param fieldDefinitionId {String} target field definition identifier (e.g. "/api/ezp/v2/content/types/42/fieldDefinitions/311")
* @param callback {Function} callback executed after performing the request (see
* {{#crossLink "ContentTypeService"}}Note on the callbacks usage{{/crossLink}} for more info)
*/
ContentTypeService.prototype.deleteFieldDefinition = function (fieldDefinitionId, callback) {
this._connectionManager.request(
"DELETE",
fieldDefinitionId,
"",
{},
callback
);
};
return ContentTypeService;
});