Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commercetools/csv-parser-orders

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools/csv-parser-orders

Module that parses orders csv to json

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-98.28%
Maintainers
1
Weekly downloads
 
Created
Source

commercetools logo

CSV Parser Orders

Travis Build Status Codecov Coverage Status David Dependencies Status David devDependencies Status

Convert commercetools orders CSV data to JSON

This module is update actions based. Update actions currently supported is:

Usage

npm install @commercetools/csv-parser-orders -g

CLI

Usage: csvparserorders [options]
Convert commercetools orders CSV data to JSON.

Options:
  --help, -h        Show help text.                                    [boolean]
  --version, -v     Show version number.                               [boolean]
  --type, -t        Predefined type of csv
                             [required] [choices: "lineitemstate", "returninfo"]
  --inputFile, -i   Path to CSV file.                         [default: "stdin"]
  --outputFile, -o  Input CSV file.                          [default: "stdout"]
  --batchSize, -b   Number of CSV rows to handle simultaneously.  [default: 100]
  --delimiter, -d   Used CSV delimiter.                           [default: ","]
  --strictMode, -s  Parse CSV strictly.                          [default: true]
  --projectKey, -p  API project key.                                  [required]
  --host            HTTP client host parameter.
  --protocol        HTTP client protocol parameter.
  --accessToken     HTTP client access token.
  --logLevel        Logging level: error, warn, info or verbose.
                                                               [default: "info"]

When running with --outputFile set, logging information is shown directly otherwise it goes to csvparserorders.log with the exception of fatal errors.

JS

You can also use this tool as a required module

import { LineItemStateCsvParser } from '@commercetools/csv-parser-orders'
import fs from 'fs'

const apiCredentials = {
    project_key: process.env.CM_PROJECT_KEY,
    client_id: '*********',
    client_secret: '*********'
};

const lineitemstate = new LineItemStateCsvParser(
  {
    config: apiCredentials,
    access_token: <access_token>,
  },
  {
    error: console.error,
    warn: console.warn,
    info: console.log,
    verbose: console.log,
  },
  {
    strictMode: true
  }
)

lineItemState.parse(
  fs.createReadStream('./input.csv'),
  fs.createWriteStream('./output.json')
);

Errors on the level error come from events that are fatal and thus stop the stream of data

Data is exported in JSON in this format

[{
  "orderNumber": "234",
  "lineItems": [{
    "state": [{
      "quantity": 10,
      "fromState": "processing",
      "toState": "shipped"
    }]
  }]
}]

Configuration

CsvParserOrders main methods accepts three objects as arguments:

  • API client config (required)
  • Logger takes object with four functions (optional)
  • Config (optional)
    • batchSize: number of CSV rows to handle simultaneously. (default: 100)
    • delimiter: the used CSV delimiter (default: ,)
    • strictMode: whether to parse the CSV strictly (default: true)

Contributing

See CONTRIBUTING.md for info on contributing to eslint-config

Keywords

FAQs

Package last updated on 22 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc