Skip to content

Commit

Permalink
✨ Add shops endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
apertureless committed Feb 22, 2017
1 parent f75c19e commit c0d8201
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 11 deletions.
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ shop.getArticles()
- [x] `/api/manufacturers`
- [x] `/api/orders`
- [x] `/api/propertyGroups`
- [ ] `/api/shops`
- [x] `/api/shops`
- [ ] `/api/translations`
- [x] `/api/variants`
- [x] `/api/version`
Expand Down Expand Up @@ -131,11 +131,16 @@ shop.getArticles()
- .createManufacturer(body, [callback]) 🔀 `Promise`
- .updateManufacturer(id, body, [callback]) 🔀 `Promise`
- .deleteManufacturer(id, [callback]) 🔀 `Promise`
- .getpropertyGroups([callback]) 🔀 `Promise`
- .getpropertyGroup(id, [callback]) 🔀 `Promise`
- .createpropertyGroup(body, [callback]) 🔀 `Promise`
- .updatepropertyGroup(id, body, [callback]) 🔀 `Promise`
- .deletepropertyGroup(id, [callback]) 🔀 `Promise`
- .getPropertyGroups([callback]) 🔀 `Promise`
- .getPropertyGroup(id, [callback]) 🔀 `Promise`
- .createPropertyGroup(body, [callback]) 🔀 `Promise`
- .updatePropertyGroup(id, body, [callback]) 🔀 `Promise`
- .deletePropertyGroup(id, [callback]) 🔀 `Promise`
- .getShops([callback]) 🔀 `Promise`
- .getShop(id, [callback]) 🔀 `Promise`
- .createShop(body, [callback]) 🔀 `Promise`
- .updateShop(id, body, [callback]) 🔀 `Promise`
- .deleteShop(id, [callback]) 🔀 `Promise`

<a name="new_shopware"></a>

Expand Down
67 changes: 62 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,14 +665,14 @@ class Shopware {
})
}

getpropertyGroups() {
getPropertyGroups() {
return this.handleRequest({
url: 'propertyGroups/',
method: 'GET'
}, 'data')
}

getpropertyGroup(id) {
getPropertyGroup(id) {
if (!id) {
return handleError(ERROR.MISSING_ID)
}
Expand All @@ -683,7 +683,7 @@ class Shopware {
}, 'data')
}

createpropertyGroup(body) {
createPropertyGroup(body) {
if (!body) {
return handleError(ERROR.MISSING_BODY)
}
Expand All @@ -695,7 +695,7 @@ class Shopware {
})
}

updatepropertyGroup(id, body) {
updatePropertyGroup(id, body) {
if (!id) {
return handleError(ERROR.MISSING_ID)
}
Expand All @@ -711,7 +711,7 @@ class Shopware {
})
}

deletepropertyGroup(id) {
deletePropertyGroup(id) {
if (!id) {
return handleError(ERROR.MISSING_ID)
}
Expand All @@ -722,6 +722,63 @@ class Shopware {
})
}

getShops() {
return this.handleRequest({
url: 'shops/',
method: 'GET'
}, 'data')
}

getShop(id) {
if (!id) {
return handleError(ERROR.MISSING_ID)
}

return this.handleRequest({
url: `shops/${id}`,
method: 'GET'
}, 'data')
}

createShop(body) {
if (!body) {
return handleError(ERROR.MISSING_BODY)
}

return this.handleRequest({
url: 'shops/',
method: 'POST',
body
})
}

updateShop(id, body) {
if (!id) {
return handleError(ERROR.MISSING_ID)
}

if (!body) {
return handleError(ERROR.MISSING_BODY)
}

return this.handleRequest({
url: `shops/${id}`,
method: 'PUT',
body
})
}

deleteShop(id) {
if (!id) {
return handleError(ERROR.MISSING_ID)
}

return this.handleRequest({
url: `shops/${id}`,
method: 'DELETE'
})
}

}

module.exports = Shopware

0 comments on commit c0d8201

Please sign in to comment.