3
3
create ,
4
4
update ,
5
5
deleteEntity ,
6
- fetch
6
+ fetch ,
7
+ fetchAll
7
8
} from '../../../entity'
8
9
import error from '../../../core/contentstackError'
9
10
import ContentstackCollection from '../../../contentstackCollection'
@@ -69,9 +70,8 @@ export function PublishRules (http, data = {}) {
69
70
*
70
71
*/
71
72
this . fetch = fetch ( http , 'publishing_rule' )
72
-
73
73
} else {
74
- /**
74
+ /**
75
75
* @description The Create Publish Rules request allows you to create publish rules for the publish rules of a stack.
76
76
* @memberof PublishRules
77
77
* @func create
@@ -96,10 +96,10 @@ export function PublishRules (http, data = {}) {
96
96
* client.stack().publishRules().create({ publishing_rule })
97
97
* .then((publishRules) => console.log(publishRules))
98
98
*/
99
- this . create = create ( { http : http } )
99
+ this . create = create ( { http : http } )
100
100
101
- /**
102
- * @description The Get all Publish Rules request retrieves the details of all the Publish rules of a workflow.
101
+ /**
102
+ * @description The Get all Publish Rules request retrieves the details of all the Publish rules of a workflow.
103
103
* @memberof Publish Rules
104
104
* @func fetchAll
105
105
* @param {String } content_types Enter a comma-separated list of content type UIDs for filtering publish rules on its basis.
@@ -115,34 +115,14 @@ export function PublishRules (http, data = {}) {
115
115
* .then((collection) => console.log(collection))
116
116
*
117
117
*/
118
- this . fetchAll = async ( params ) => {
119
- const headers = { }
120
- if ( this . stackHeaders ) {
121
- headers . headers = this . stackHeaders
122
- }
123
- if ( params ) {
124
- headers . params = {
125
- ...cloneDeep ( params )
126
- }
127
- }
128
- try {
129
- const response = await http . get ( this . urlPath , headers )
130
- if ( response . data ) {
131
- return new ContentstackCollection ( response , http , null , PublishRulesCollection )
132
- } else {
133
- throw error ( response )
134
- }
135
- } catch ( err ) {
136
- throw error ( err )
137
- }
138
- }
139
- }
118
+ this . fetchAll = fetchAll ( http , PublishRulesCollection )
119
+ }
140
120
}
141
121
142
122
export function PublishRulesCollection ( http , data ) {
143
- const obj = cloneDeep ( data . publishing_rules ) || [ ]
144
- const publishRulesollection = obj . map ( ( userdata ) => {
145
- return new PublishRules ( http , { publishing_rule : userdata , stackHeaders : data . stackHeaders } )
146
- } )
147
- return publishRulesollection
123
+ const obj = cloneDeep ( data . publishing_rules ) || [ ]
124
+ const publishRulesollection = obj . map ( ( userdata ) => {
125
+ return new PublishRules ( http , { publishing_rule : userdata , stackHeaders : data . stackHeaders } )
126
+ } )
127
+ return publishRulesollection
148
128
}
0 commit comments