11import cloneDeep from 'lodash/cloneDeep'
2- import { App } from '.. /app'
3- import { Installation } from '../app /installation'
2+ import { App } from './app'
3+ import { Installation } from './installation'
44import error from '../core/contentstackError'
55import { fetchAll } from '../entity'
6- import { AppRequest } from '../app /request'
6+ import { AppRequest } from './request'
77
88export function Marketplace ( http , data ) {
99 http . defaults . versioningStrategy = undefined
@@ -16,21 +16,59 @@ export function Marketplace (http, data) {
1616 }
1717
1818 /**
19- * @description Oauth will allow to get, update auth and get scopes .
20- * @memberof App
21- * @func oauth
22- * @returns {Promise<AppOAuth > }
23- * @returns {Oauth }
19+ * @description App will allow to App instance .
20+ * @memberof Marketplace
21+ * @func app
22+ * @returns {Promise<App > }
23+ * @returns {App }
2424 *
2525 * @example
2626 * import * as contentstack from '@contentstack/management'
2727 * const client = contentstack.client({ authtoken: 'TOKEN'})
28- * client.organization('organization_uid').app('manifest_uid').oauth( )
28+ * client.organization('organization_uid').marketplace(). app('manifest_uid')
2929 */
3030 this . app = ( uid = null ) => {
3131 return new App ( http , uid !== null ? { data : { uid, organization_uid : this . uid } } : { organization_uid : this . uid } )
3232 }
3333
34+ /**
35+ * @description The Installation will allow you to fetch, update and delete of the app installation.
36+ * @memberof Marketplace
37+ * @func installation
38+ * @param {String } uid Installation uid
39+ * @returns Installation
40+ *
41+ * @example
42+ * import * as contentstack from '@contentstack/management'
43+ * const client = contentstack.client({ authtoken: 'TOKEN'})
44+ * client.organization('organization_uid').app('manifest_uid').installation().findAll()
45+ * .then((installations) => console.log(installations))
46+ *
47+ * @example
48+ * import * as contentstack from '@contentstack/management'
49+ * const client = contentstack.client({ authtoken: 'TOKEN'})
50+ * client.organization('organization_uid').marketplace().installation('installation_uid').fetch()
51+ * .then((installation) => console.log(installation))
52+ */
53+ this . installation = ( installationUid = null ) => {
54+ return new Installation ( http , installationUid ? { data : { uid : installationUid } } : { data : { } } , this . params )
55+ }
56+
57+ /**
58+ * @description The Create request call is used to create a app request for an app.
59+ * @returns Request
60+ *
61+ * @example
62+ * import * as contentstack from '@contentstack/management'
63+ * const client = contentstack.client({ authtoken: 'TOKEN'})
64+ *
65+ * client.organization('organization_uid').marketplace().requests()
66+ *
67+ */
68+ this . appRequests = ( ) => {
69+ return new AppRequest ( http , { organization_uid : this . uid } )
70+ }
71+
3472 /**
3573 * @description The findAllApps call is used to fetch all the apps in your Contentstack organization.
3674 * @memberof Marketplace
@@ -79,44 +117,6 @@ export function Marketplace (http, data) {
79117 return error ( err )
80118 }
81119 }
82-
83- /**
84- * @description The Installation will allow you to fetch, update and delete of the app installation.
85- * @memberof Marketplace
86- * @func installation
87- * @param {String } uid Installation uid
88- * @returns Installation
89- *
90- * @example
91- * import * as contentstack from '@contentstack/management'
92- * const client = contentstack.client({ authtoken: 'TOKEN'})
93- * client.organization('organization_uid').app('manifest_uid').installation().findAll()
94- * .then((installations) => console.log(installations))
95- *
96- * @example
97- * import * as contentstack from '@contentstack/management'
98- * const client = contentstack.client({ authtoken: 'TOKEN'})
99- * client.organization('organization_uid').marketplace().installation('installation_uid').fetch()
100- * .then((installation) => console.log(installation))
101- */
102- this . installation = ( installationUid = null ) => {
103- return new Installation ( http , installationUid ? { data : { installationUid } } : { } , this . params )
104- }
105-
106- /**
107- * @description The Create request call is used to create a app request for an app.
108- * @returns Request
109- *
110- * @example
111- * import * as contentstack from '@contentstack/management'
112- * const client = contentstack.client({ authtoken: 'TOKEN'})
113- *
114- * client.organization('organization_uid').marketplace().requests()
115- *
116- */
117- this . requests = ( ) => {
118- return new AppRequest ( http , { organization_uid : this . uid } )
119- }
120120 }
121121 return this
122122}
0 commit comments