How to use @commercetools/csv-parser-price - 2 common examples

To help you get started, we’ve selected a few @commercetools/csv-parser-price examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / nodejs / integration-tests / cli / csv-parser-price.it.js View on Github external
return new Promise(done => {
        const csvFilePath = path.join(samplesFolder, 'sample.csv')
        const csvParserPrice = new CsvParserPrice({ apiConfig })
        const inputStream = fs.createReadStream(csvFilePath)
        const outputStream = streamtest.v2.toText((error, output) => {
          const prices = JSON.parse(output).prices
          const expected = path.join(
            __dirname,
            'expected-output',
            'csv-parser-price.json'
          )
          const expectedArray = JSON.parse(fs.readFileSync(expected, 'utf8'))

          expect(prices).toBeInstanceOf(Array)
          expect(prices).toMatchObject(expectedArray.prices)
          expect(prices).toHaveLength(2)

          // Because customTypeId is dynamic, match it against uuid regex
          expect(isuuid(prices[0].prices[0].custom.type.id)).toBe(true)
github commercetools / nodejs / integration-tests / cli / csv-parser-price.it.js View on Github external
beforeAll(() => {
      const client = createClient({
        middlewares: [
          createAuthMiddlewareForClientCredentialsFlow({ ...apiConfig, fetch }),
          createHttpMiddleware({
            host: CONSTANTS.host.api,
            fetch,
          }),
        ],
      })

      const customTypePayload = {
        key: 'custom-type',
        name: { nl: 'selwyn' },
        resourceTypeIds: ['product-price'],
        fieldDefinitions: [
          {
            type: { name: 'Number' },
            name: 'foo',
            label: { en: 'said the barman' },
            required: true,
          },

@commercetools/csv-parser-price

Converts commercetools price data from CSV to JSON.

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis