Skip to content

Commit

Permalink
feat: add a new error MISSING_ORDERNUMBER in case there is no ordernu…
Browse files Browse the repository at this point in the history
…mber

* Add MISSING_ORDERUMBER / Fix README link

* Fix links in README / add new link / add new docs item
  • Loading branch information
janmarkuslanger authored and apertureless committed Nov 18, 2018
1 parent a1beb8a commit 4a03567
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ Find the [docs here](https://apertureless.github.io/shopware-api-client/#/) *con
## API Reference

- Shopware
- [new Shopware([object])](#new_shopware)
- [.version([callback])](#version) 🔀 `Promise`
- [.getArticles([callback])](#getArticles) 🔀 `Promise`
- .getArticleByOrdernumber(ordernumber, [callback]) 🔀 `Promise`
- [.getArticle(id, [callback])](#getArticle) 🔀 `Promise`
- [.deleteArticle(id, [callback])](#deleteArticle) 🔀 `Promise`
- [.deleteArticles(ids, [callback])](#deleteArticles) 🔀 `Promise`
- [.createArticle(article, [callback])](#createArticle) 🔀 `Promise`
- [.updateArticle(id, article, [callback])](#updateArticle) 🔀 `Promise`
- [new Shopware([object])](https://github.com/apertureless/shopware-api-client/tree/master/docs#new_shopware)
- [.version([callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#version) 🔀 `Promise`
- [.getArticles([callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#getArticles) 🔀 `Promise`
- [.getArticleByOrdernumber(ordernumber, [callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#getArticleByOrdernumber) 🔀 `Promise`
- [.getArticle(id, [callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#getArticle) 🔀 `Promise`
- [.deleteArticle(id, [callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#deleteArticle) 🔀 `Promise`
- [.deleteArticles(ids, [callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#deleteArticles) 🔀 `Promise`
- [.createArticle(article, [callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#createArticle) 🔀 `Promise`
- [.updateArticle(id, article, [callback])](https://github.com/apertureless/shopware-api-client/tree/master/docs#updateArticle) 🔀 `Promise`
- .updateArticles(articles, [callback]) 🔀 `Promise`
- .getCategories([callback]) 🔀 `Promise`
- .getCategory(id, [callback]) 🔀 `Promise`
Expand Down
13 changes: 13 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- [.version([callback])](#version) 🔀 `Promise`
- [.getArticles([callback])](#getArticles) 🔀 `Promise`
- [.getArticle(id, [callback])](#getArticle) 🔀 `Promise`
- [.getArticleByOrdernumber(ordernumber, [callback])](#getArticleByOrdernumber) 🔀 `Promise`
- [.deleteArticle(id, [callback])](#deleteArticle) 🔀 `Promise`
- [.deleteArticles(ids, [callback])](#deleteArticles) 🔀 `Promise`
- [.createArticle(article, [callback])](#createArticle) 🔀 `Promise`
Expand Down Expand Up @@ -148,6 +149,18 @@ Returns an object with article data.

<a name="deleteArticle"></a>

### shop.getArticleByOrdernumber(ordernumber, [callback]) ⇒ <code>Promise</code>
Returns an object with article data.

**See**: https://developers.shopware.com/developers-guide/rest-api/api-resource-article/

| Param | Type | Description |
| --- | --- | --- |
| ordernumber | <code>string</code> | Article ordernumber |
| [callback] | <code>function</code> | Callback will be called with `(err, articles)` |

<a name="getArticleByOrdernumber"></a>

### shop.deleteArticle(id, [callback]) ⇒ <code>Promise</code>
Deletes an article and returns it's data.

Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const ERROR = {
MISSING_BODY: {
code: 'missing_body',
message: 'Missing a proper `body` parameter'
},
MISSING_ORDERNUMBER: {
code: 'missing_ordernumber',
message: 'Missing `ordernumber` parameter'
}
}

Expand Down Expand Up @@ -80,7 +84,7 @@ class Shopware {

getArticleByOrdernumber(ordernumber) {
if (!ordernumber) {
return handleError(ERROR.MISSING_ID)
return handleError(ERROR.MISSING_ORDERNUMBER)
}

return this.handleRequest({
Expand Down

0 comments on commit 4a03567

Please sign in to comment.