Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add shipping_set and shipping_available_list #9

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions src/ViURShopClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export class ViURShopClient {
// --- Shipping -----------------------------------------------------------

/**
* Lists available shipping options for a (sub)cart
* Lists shipping options for a (sub)cart
* @param {string} cart_key Key of the parent cart
* @returns {Promise<Response>} List of ShippingsSkels
*/
Expand All @@ -455,7 +455,48 @@ export class ViURShopClient {
} = {}) {
return request(`${this.shop_api_url}/shipping_list`, {
method: 'GET',
params: {cart_key},
params: this.removeUndefinedValues({
cart_key,
})
})
.then(req => req.json());
}

/**
* Lists available shipping options for a (sub)cart
* @param {string} cart_key Key of the parent cart
* @returns {Promise<Response>} List of ShippingsSkels
*/
shipping_available_list({
cart_key,
} = {}) {
return request(`${this.shop_api_url}/shipping_available_list`, {
method: 'GET',
params: this.removeUndefinedValues({
cart_key,
})
})
.then(req => req.json());
}

/**
* Set the shipping for the cart.
* If no shipping key is set the cheapest will be added.
* If no cart key is set the current cart will be used.
* @param {string} cart_key Key of Cart
* @param {string} shipping_key Key of the shipping
* @returns {Promise<Response>} List of ShippingsSkels
*/
shipping_set({
cart_key,
shipping_key,
} = {}) {
return request(`${this.shop_api_url}/shipping_set`, {
method: 'GET',
params: this.removeUndefinedValues({
cart_key,
shipping_key,
}),
})
.then(req => req.json());
}
Expand Down