UNPKG

@shopify/shopify-api

Version:

Shopify API Library for Node - accelerate development with support for authentication, graphql proxy, webhooks

1 lines 4.33 kB
{"version":3,"file":"collection.mjs","sources":["../../../../../../../rest/admin/2023-01/collection.ts"],"sourcesContent":["/***********************************************************************************************************************\n* This file is auto-generated. If you have an issue, please create a GitHub issue. *\n***********************************************************************************************************************/\n\nimport {Base} from '../../base';\nimport {ResourcePath, ResourceNames} from '../../types';\nimport {Session} from '../../../lib/session/session';\nimport {ApiVersion} from '../../../lib/types';\n\nimport {Image} from './image';\n\ninterface FindArgs {\n session: Session;\n id: number | string;\n fields?: unknown;\n}\ninterface ProductsArgs {\n [key: string]: unknown;\n session: Session;\n id: number | string;\n limit?: unknown;\n}\n\nexport class Collection extends Base {\n public static apiVersion = ApiVersion.January23;\n\n protected static hasOne: {[key: string]: typeof Base} = {\n \"image\": Image\n };\n protected static hasMany: {[key: string]: typeof Base} = {};\n protected static paths: ResourcePath[] = [\n {\"http_method\": \"get\", \"operation\": \"get\", \"ids\": [\"id\"], \"path\": \"collections/<id>.json\"},\n {\"http_method\": \"get\", \"operation\": \"products\", \"ids\": [\"id\"], \"path\": \"collections/<id>/products.json\"}\n ];\n protected static resourceNames: ResourceNames[] = [\n {\n \"singular\": \"collection\",\n \"plural\": \"collections\"\n }\n ];\n\n public static async find(\n {\n session,\n id,\n fields = null\n }: FindArgs\n ): Promise<Collection | null> {\n const result = await this.baseFind<Collection>({\n session: session,\n requireIds: true,\n urlIds: {\"id\": id},\n params: {\"fields\": fields},\n });\n return result.data ? result.data[0] : null;\n }\n\n public static async products(\n {\n session,\n id,\n limit = null,\n ...otherArgs\n }: ProductsArgs\n ): Promise<unknown> {\n const response = await this.request<Collection>({\n http_method: \"get\",\n operation: \"products\",\n session: session,\n urlIds: {\"id\": id},\n params: {\"limit\": limit, ...otherArgs},\n body: {},\n entity: null,\n });\n\n return response ? response.body : null;\n }\n\n public title: string | null;\n public body_html: string | null;\n public handle: string | null;\n public id: string | null;\n public image: Image | null | {[key: string]: any};\n public published_at: string | null;\n public published_scope: string | null;\n public sort_order: string | null;\n public template_suffix: string | null;\n public updated_at: string | null;\n}\n"],"names":[],"mappings":";;;;AAAA;;AAEwH;AAqBlH,MAAO,UAAW,SAAQ,IAAI,CAAA;AAC3B,IAAA,OAAO,UAAU,GAAG,UAAU,CAAC,SAAS;IAErC,OAAO,MAAM,GAAiC;AACtD,QAAA,OAAO,EAAE;KACV;AACS,IAAA,OAAO,OAAO,GAAiC,EAAE;IACjD,OAAO,KAAK,GAAmB;AACvC,QAAA,EAAC,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAC;AAC1F,QAAA,EAAC,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,gCAAgC;KACxG;IACS,OAAO,aAAa,GAAoB;AAChD,QAAA;AACE,YAAA,UAAU,EAAE,YAAY;AACxB,YAAA,QAAQ,EAAE;AACX;KACF;AAEM,IAAA,aAAa,IAAI,CACtB,EACE,OAAO,EACP,EAAE,EACF,MAAM,GAAG,IAAI,EACJ,EAAA;AAEX,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAa;AAC7C,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,UAAU,EAAE,IAAI;AAChB,YAAA,MAAM,EAAE,EAAC,IAAI,EAAE,EAAE,EAAC;AAClB,YAAA,MAAM,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAC;AAC3B,SAAA,CAAC;AACF,QAAA,OAAO,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI;IAC5C;AAEO,IAAA,aAAa,QAAQ,CAC1B,EACE,OAAO,EACP,EAAE,EACF,KAAK,GAAG,IAAI,EACZ,GAAG,SAAS,EACC,EAAA;AAEf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