{"_id":"@car-co-uk/api-client","_rev":"1-192e57954fa26b87ee191a53beee2717","name":"@car-co-uk/api-client","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@car-co-uk/api-client","version":"0.0.1","scripts":{"lint":"eslint . --ext .js --ext .jsx","lint:fix":"yarn lint -- --fix","lint:quiet":"yarn lint -- --quiet","prettier":"prettier './**/*.js' --write --single-quote","prettier:write":"yarn prettier -- --write","prettier:check":"yarn prettier -- --list-different"},"dependencies":{"@bugsnag/js":"^6.5.0","@bugsnag/plugin-react":"^6.5.0","cross-fetch":"^3.0.0","query-string":"^6.2.0"},"devDependencies":{"@babel/cli":"^7.7.4","@babel/core":"^7.7.4","@babel/plugin-proposal-class-properties":"^7.7.4","@babel/plugin-proposal-optional-chaining":"^7.7.4","@babel/plugin-syntax-dynamic-import":"^7.7.4","@babel/plugin-transform-react-constant-elements":"^7.7.4","@babel/plugin-transform-react-inline-elements":"^7.7.4","@babel/plugin-transform-runtime":"^7.7.4","@babel/preset-env":"^7.7.4","@babel/preset-react":"^7.7.4","@babel/plugin-proposal-object-rest-spread":"7.7.4","@babel/register":"7.7.4","@babel/runtime":"7.7.4","eslint":"^6.0.0","prettier":"^1.18.2","babel-eslint":"^10.0.1","eslint-config-airbnb":"^17.1.0","eslint-config-prettier":"^4.1.0","eslint-plugin-import":"^2.16.0","eslint-plugin-jsx-a11y":"^6.2.1","eslint-plugin-prettier":"^3.0.1","eslint-plugin-react":"^7.12.4"},"description":"Allows asynchronous requests to Car.co.uk REST API and get results with native Promise or async/await.","_id":"@car-co-uk/api-client@0.0.1","_nodeVersion":"11.15.0","_npmVersion":"6.7.0","dist":{"integrity":"sha512-SpDGE6KkJXHb2ZXJ6zFce94kEu6ruTbnRNx8UCLd3j2M83OY0m8G4A7303d/dZfekJnAOBT7YyYnHd2EYS6vxA==","shasum":"e98825fd02f6bb78e458e8bd9928b46fc59a24aa","tarball":"https://registry.npmjs.org/@car-co-uk/api-client/-/api-client-0.0.1.tgz","fileCount":38,"unpackedSize":34283,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJehV2vCRA9TVsSAnZWagAAXZIP/1ncPzBYFSqMq0zeH37r\n9h/+kvxwhkMgSwUH8IZ0aBw+NjsR60iM8rugt3+S7gfxZ046kDFCAO/AirDq\nJDiZRwtfVwEKv1/RWI8+0J84n8rHF0qR8BTFMcmEMQUz3ZskHe+cwztJruew\n6VdOnEriZv3QekmKNN1WHK2QUmpkBLbb/VsFqpIKg1xrmVkbcBY6bcY/4kgb\nYer04PDughgYg/wBwW8F76hdOD+klC2yueMV3hzgVbPzNn75zJIjoe4yuCJ5\nrYtGgJqlGBZVBEDyjnCKoX1kmwxOBEejJJgNKxXzPtPzsaajUsmbJTsLFcb3\neQnvPr0r2QGwQkaceX0JklFpvRGvJBQSxn5P5ZVDDrxvXgyiYdvlLsikSrBm\nszpuEgWpIVkYkW1z/IVyZLh7dCOq3yUIqSsZhb+uhx/tBNUN061PrjVFFnUm\n5lc6fLWLZ4LcerNAL67FUJ9uClK0oQKG61bhvacu8Z/aWedHHLN5hEyvRV0+\n8Is26Le047pbOfivt+4JZdkyihYZszW4RSAj8h8aYgplsP2LK1/mSc9AEsTB\nAsn+kch2kzrPD/IxygKLA0e1jA1LKabRZffhxNpeULkyEh2zHX/4WYn4RVu9\nkhv9HDEakPu9sBc9vmZR7yL2/CsNcFuWDiocPO1gjOw/1/Ia12qhUaTBz1Gn\nVNDD\r\n=GKu4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDB7NOV92DAgDdbmkaZEQ9TtrZjkHjBWj9+ANgRDCisvAIgcbIx8XAL3g4y95sHYlzWS9W06wQ60opGiMrwSs9BYTI="}]},"maintainers":[{"name":"lgh06","email":"liugehuan@gmail.com"}],"_npmUser":{"name":"lgh06","email":"liugehuan@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/api-client_0.0.1_1585798574961_0.696474712875667"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-02T03:36:14.724Z","0.0.1":"2020-04-02T03:36:15.107Z","modified":"2022-04-04T21:47:17.292Z"},"maintainers":[{"name":"lgh06","email":"liugehuan@gmail.com"}],"description":"Allows asynchronous requests to Car.co.uk REST API and get results with native Promise or async/await.","readme":"# Car.co.uk API client library\n\nAllows asynchronous requests to Car.co.uk REST API and get results with native Promise or async/await.\n\n## Initialize\n\n```javascript\nimport APIClient from '@car-co-uk/api-client';\n\nconst api = new APIClient({\n  apiUrl: 'https://website.com/api/v1',\n  apiToken: '<token>'\n});\n```\n\n## Usage\n\n```javascript\n// fetch all auctions with await\nconst auctionsResponse = await api.auctions.list();\nconst auctions = auctionsResponse.json;\nfor(const car of auctions){\n  console.log(car.name)\n}\n\n// fetch all auctions with Promise\napi.auctions.list().then(({status, json}) => {\n    const auctions = json;\n    for(const car of auctions){\n      console.log(car.name)\n    }\n});\n\n// create a car\napi.auctions.create({ name: 'My Awesome Auction' }).then(({status, json}) => {\n    const carId = json.id;\n});\n```\n\n##  Error Handling\n\n```javascript\n// with await\ntry {\n  const createResult = await api.auctions.create({ name: 'My Awesome Auction' });\n  const newcar = createResult.json;\n} catch(e) {\n  console.log(e);\n}\n\n// with Promise\napi.auctions.create({ name: 'My Awesome Auction' })\n.then(({status, json}) => {\n  if(status === 200) {\n    // success\n    const newcar = json;\n  } else {\n    // 404 or bad request\n  }\n})\n.catch(err => {\n  console.log(err)\n});\n```\n\n## Methods\n\n* `api.authorize(baseUrl, user, pass)`\n","readmeFilename":"README.md"}