@@ -185,8 +185,13 @@ export default {
185185 }
186186 } ,
187187 async getCustomObjectTypes ( ) {
188- const { results } = await this . hubspot . listSchemas ( ) ;
189- return results ?. map ( ( { name } ) => name ) || [ ] ;
188+ const { results } = await this . listSchemas ( ) ;
189+ return results ?. map ( ( {
190+ fullyQualifiedName : value , labels,
191+ } ) => ( {
192+ value,
193+ label : labels . plural ,
194+ } ) ) || [ ] ;
190195 } ,
191196 } ,
192197 async run ( { $ } ) {
@@ -204,8 +209,10 @@ export default {
204209 ...otherProperties
205210 } = this ;
206211
212+ const actualObjectType = customObjectType ?? objectType ;
213+
207214 const schema = await this . hubspot . getSchema ( {
208- objectType,
215+ objectType : actualObjectType ,
209216 } ) ;
210217
211218 if ( ! schema . searchableProperties . includes ( searchProperty ) ) {
@@ -236,20 +243,20 @@ export default {
236243 ] ,
237244 } ;
238245 const { results } = await hubspot . searchCRM ( {
239- object : customObjectType ?? objectType ,
246+ object : actualObjectType ,
240247 data,
241248 $,
242249 } ) ;
243250
244251 if ( ! results ?. length && createIfNotFound ) {
245252 const response = await hubspot . createObject ( {
246253 $,
247- objectType : customObjectType ?? objectType ,
254+ objectType : actualObjectType ,
248255 data : {
249256 properties,
250257 } ,
251258 } ) ;
252- const objectName = hubspot . getObjectTypeName ( customObjectType ?? objectType ) ;
259+ const objectName = hubspot . getObjectTypeName ( actualObjectType ) ;
253260 $ . export ( "$summary" , `Successfully created ${ objectName } ` ) ;
254261 return response ;
255262 }
0 commit comments