11import * as Utils from '../lib/utils' ;
22import Stack from '../stack' ;
33import Query from './query' ;
4- < << << << HEAD
5- = === ===
64
75const _extend = function ( type ) {
86 return function ( ) {
@@ -33,44 +31,11 @@ const _extend = function (type) {
3331 }
3432 } ;
3533} ;
36- > >>> >>> 5 f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
3734/**
3835 * @summary Creates an instance of `Asset`.
3936 * @description An initializer is responsible for creating Asset object.
4037 * @param {String } uid - uid of the asset
4138 * @example
42- <<<<<<< HEAD
43- * let Entry = Contentstack.Stack().Asset('bltsomething123');
44- * @returns {Asset }
45- * @ignore
46- */
47- export default class Asset {
48- constructor ( ) {
49- this . _query = { } ;
50- return this ;
51- }
52-
53- setCacheProvider ( provider ) {
54- if ( provider && typeof provider === 'object' ) {
55- this . provider = provider ;
56-
57- }
58- return this ;
59- }
60-
61- setCachePolicy ( policy ) {
62- if ( typeof policy === 'number' && policy >= - 1 && policy < 4 ) {
63- if ( ! this . _query ) {
64- this . cachePolicy = policy ;
65- } else {
66- this . queryCachePolicy = policy ;
67- }
68- } else {
69- console . error ( "Kindly provide the valid policy" ) ;
70- }
71- return this ;
72- }
73- === === =
7439 * let Entry = Contentstack.Stack().Assets('bltsomething123');
7540 * @returns {Asset }
7641 * @ignore
@@ -96,34 +61,19 @@ export default class Asset {
9661 this . only = _extend ( 'only' ) ;
9762 return this ;
9863 }
99- >>> >>> > 5 f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
10064
10165 /**
10266 * @method Query
10367 * @description Query instance to provide support for all search queries.
10468 * @example Assets().Query()
10569 * @returns {Query }
10670 */
107- < << << << HEAD
108- Query ( ) {
109- = === ===
11071 Query ( ) {
111- >>> > >>> 5 f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
11272 let query = new Query ( ) ;
11373 return Utils . merge ( query , this ) ;
11474 }
11575
11676 /**
117- <<<<<<< HEAD
118- * @method toJSON
119- * @description This method is used to convert the result in to plain javascript object.
120- * @example
121- * blogEntry
122- * .toJSON()
123- * .then(function (result) {
124- * let value = result.get(field_uid)
125- * },function (error) {
126- =======
12777 * @method addQuery
12878 * @description This method is used to add query to Entry object.
12979 * @param {String } key - key of the query
@@ -149,50 +99,22 @@ export default class Asset {
14999 * .then(function (result) {
150100 * let value = result.get(field_uid)
151101 * },function (error) {
152- >>>>>>> 5f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
153102 * // error function
154103 * })
155104 * @returns {Object }
156105 */
157- << < << << HEAD
158- toJSON ( ) {
159- === = ===
160106 toJSON ( ) {
161- >>> > >>> 5 f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
162107 this . tojson = true ;
163108 return this ;
164109 }
165110
166- << << << < HEAD
167- = === ===
168111
169- >>> >>> > 5f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
170112 /**
171- * @method fetch
172- * @description fetch asset obhect of requested Asset uid of defined query if present.
173- * @example
174- < << << << HEAD
175- * Stack . Asset ( 'bltsomething123' ) . fetch ( )
176- * /
177- fetch ( ) {
178- if ( this . asset_uid ) {
179- this . requestParams = {
180- method : 'POST' ,
181- headers : this . headers ,
182- url : this . config . protocol + "://" + this . config . host + ':' + this . config . port + '/' + this . config . version + this . config . urls . assets + this . asset_uid ,
183- body : {
184- _method : 'GET' ,
185- query : this . _query
186- }
187- }
188- return Utils . sendRequest ( this ) ;
189- } else {
190- console . error ( "Kindly provide an asset uid. e.g. .Asset('bltsomething123')" ) ;
191- }
192- }
193- === === =
194- * Stack . Assets ( 'bltsomething123' ) . fetch ( )
195- * /
113+ * @method fetch
114+ * @description fetch asset obhect of requested Asset uid of defined query if present.
115+ * @example
116+ * Stack.Assets('bltsomething123').fetch()
117+ */
196118 fetch ( ) {
197119 if ( this . asset_uid ) {
198120 this . requestParams = {
@@ -209,5 +131,4 @@ export default class Asset {
209131 console . error ( "Kindly provide an asset uid. e.g. .Assets('bltsomething123')" ) ;
210132 }
211133 }
212- >>> >>> > 5 f8e4cdd88f31d7d7d2c98debc826c27c1942e2f
213134}
0 commit comments