Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | /* eslint no-unused-vars: 0 */ // Interfaces are empty, disable for whole file
/** @module interfaces */
/**
* A generic interface for API based or web-scraping ecommerce Connectors.
*
* @interface
*/
export class CommerceConnector {
/**
* Get the default headers that are sent with every request.
*
* @return {Object.<String, String>}
*/
getDefaultHeaders() {
throw new Error('Not implemented')
}
/**
* Set the default headers that are sent with every request.
*
* @param {Object.<String, String>} headers
*/
setDefaultHeaders(headers) {
throw new Error('Not implemented')
}
/**
* Log a customer in and return their details.
*
* On backends which support "guest login", credentials can be omitted to
* give you a guest session.
*
* @param {String} username
* @param {String} password
* @return {Promise<module:types/Customer>}.
*
* @throws {module:errors/InvalidArgumentError} Will throw an error if the username or password aren't provided for type registered.
* @throws {module:errors/ForbiddenError} Will throw an error if the customer credentials are incorrect.
*/
login(username, password) {
throw new Error('Not implemented')
}
/**
* Log a custmer out.
*
* @return {Promise<undefined>}
*
* @throws {module:errors/ServerError} Will throw an error if there was a server-side error.
*/
logout() {
throw new Error('Not implemented')
}
/**
* Refresh a session token, on backends that support refresh.
*
* @return {Promise<module:types/Customer>}
*
* @throws {module:errors/ForbiddenError} Will throw an error if authorization credentials are incorrect
*/
refreshSession() {
throw new Error('Not implemented')
}
/**
* Return a customer's details by id.
*
* @param {String} id Customer Id
* @param {Object} [opts] Options object
* @return {Promise<module:types.Customer>}
*
* @throws {module:errors/ServerError} Throw generic error if server has error.
*/
getCustomer(id, opts = {}) {
throw new Error('Not implemented')
}
/**
* Search for products, given a productSearchRequest object.
*
* @param {module:types.ProductSearchRequest} productSearchRequest Search query
* @param {Object} [opts] Options object
* @return {Promise<module:types.ProductSearch>}
*/
searchProducts(productSearchRequest, opts = {}) {
throw new Error('Not implemented')
}
/**
* Get a single product by id.
*
* @param {String} id The product id.
* @param {Object} [opts] Options object
* @return {Promise<module:types.Product>}.
*/
getProduct(id, opts = {}) {
throw new Error('Not implemented')
}
/**
* Get multiple products by their ids.
*
* On supported backends this method will retrieve products in a single network
* call. Others may make a call per id to emulate the same behaviour.
*
* Invalid ids are ignored and results are not guaranteed to be returned in the
* order requested.
*
* @param {Array<String>} ids The product ids.
* @param {Object} [opts] Options object
* @return {Promise<module:types.ProductList>}.
*/
getProducts(ids, opts = {}) {
throw new Error('Not implemented')
}
/**
* Get a Store (ie. a physical retail-outlet) by id. Includes addresses, opening
* hours, etc.
*
* @param {String} id The id of the store
* @param {Object} [opts] Options object
*
* @return {Promise<module:types.Store>}.
*/
getStore(id, opts = {}) {
throw new Error('Not implemented')
}
/**
* Get a product Category by id.
*
* @param {String} id
* @param {Object} [opts] object
* @returns {Promise<module:types.Category>}
*/
getCategory(id, opts = {}) {
throw new Error('Not implemented')
}
/**
* Returns multiple product Categories by their ids.
*
* On supported backends this method will retrieve Categories in a single network
* call. Others may make a call per id to emulate the same behaviour.
*
* Invalid ids are ignored and results are not guaranteed to be returned in the
* order requested.
*
* @param {Array<String>} ids
* @param {Object} [opts] object
* @returns {Promise<module:types.CategoryList>}
*/
getCategories(ids, opts = {}) {
throw new Error('Not implemented')
}
/**
* Searches for Stores (ie. physical retail-outlets).
*
* @param {module:types.StoreSearchRequest} storeSearchRequest
* @param {Object} [opts] Options object
* @returns {Promise<module:types.StoreSearchResult>}
*/
searchStores(storeSearchRequest, opts = {}) {
throw new Error('Not implemented')
}
/**
* Creates a new cart with an optional cart object.
*
* @param {module:types.Cart} oldCcart The cart you'd like to migrate to the new cart
* @param {Object} [opts] object
* @return {Promise<module:types.Cart>}
*
* @throws Could not create cart.
*/
createCart(oldCart, opts = {}) {
throw new Error('Not implemented')
}
/**
* Retrieve cart by id.
*
* @param {String} cartId The id of the cart you want to retrieve
* @param {Object} [opts] object
* @returns {Promise<module:types.Cart>}
*/
getCart(cartId, opts = {}) {
throw new Error('Not implemented')
}
/**
* Deletes the given cart
*
* @param {String} cartId The id of the cart you want to delete.
* @param {Object} [opts] object
*
* @throws Could not delete cart.
*/
deleteCart(cartId) {
throw new Error('Not implemented')
}
/**
* Adds a cart item to cart.
* @param {module:types.Cart} cart The cart to add the cart item to.
* @param {module:types.CartItem} cartItem The cart item to add.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
addCartItem(cart, cartItem, opts = {}) {
throw new Error('Not implemented')
}
/**
* Remove a cart item from the cart.
* @param {module:types.Cart} cart The cart to remove the cart item from.
* @param {String} cartItemId The id of the cart item to remove.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
removeCartItem(cart, cartItemId, opts = {}) {
throw new Error('Not implemented')
}
/**
* Update an existing cart item in the cart.
* @param {module:types.Cart} cart The cart to containing the cart item to update.
* @param {module:types.CartItem} cartItem The cart item to update.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
updateCartItem(cart, cartItem, opts = {}) {
throw new Error('Not implemented')
}
/**
* Set the shipping address on the cart.
* @param {module:types.Cart} cart The cart to update the shipping address for.
* @param {module:types.OrderAddress} shippingAddress The new or modified address.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
setShippingAddress(cart, shippingAddress, opts = {}) {
throw new Error('Not implemented')
}
/**
* Set the billing address on the cart.
* @param {module:types.Cart} cart The cart to update the billing address for.
* @param {module:types.OrderAddress} billingAddress The new or modified address.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
setBillingAddress(cart, billingAddress, opts = {}) {
throw new Error('Not implemented')
}
/**
* Add a supported payment type to the cart
* @param {module:types.Cart} cart The cart to remove the payment from.
* @param {module:types.Payment} payment The payment to add.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
setPayment(cart, payment, opts = {}) {
throw new Error('Not implemented')
}
/**
* Get all the available shipping methods given the cart details.
* @param {module:types.Cart} cart The cart to determinen avaialble shipping methods for.
* @param {Object} opts
* @return {Promise<Array.<module:types.ShippingMethod>>}
*/
getShippingMethods(cart, opts = {}) {
throw new Error('Not implemented')
}
/**
* Set the shipping method for the cart.
* @param {module:types.Cart} cart The cart to set the shipping method for.
* @param {module:types.ShippingMethod} shippingMethod The shipping method to set.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
setShippingMethod(cart, shippingMethod, opts = {}) {
throw new Error('Not implemented')
}
/**
* Set the customer information.
* @param {module:types.Cart} cart The customer's cart.
* @param {module:types.CustomerInformation} customerInformation The new or modified customer information.
* @param {Object} opts
* @return {Promise<module:types.Cart>}
*/
setCustomerInformation(cart, customerInformation, opts = {}) {
throw new Error('Not implemented')
}
/**
* Get the available payment methods for the cart
* @param {module:types.Cart} cart The customer's cart.
* @param {Object} opts
* @return {Promise<Array.module:types.PaymentMethod>}
*/
getPaymentMethods(cart, opts = {}) {
throw new Error('Not implemented')
}
}
/**
* ParserHooks allows user to override/customize parsers on Commerce Connector
* implementations, as needed.
*
* For compatibility, the results returned from overridden methods should be
* valid Commerce Integrations type objects. Typically, adding new properties
* to returned objects is safe, which removing them is *not*.
*
* @interface
*/
export class ParserHooks {
/**
* Parse a customer.
*/
parseCustomer(data) {
throw new Error('Not implemented')
}
/**
* Parse a category.
*/
parseCategory(data) {
throw new Error('Not implemented')
}
/**
* Parse categories.
*/
parseCategories(data) {
throw new Error('Not implemented')
}
/**
* Parse a product search result.
*/
parseSearchProducts(data, searchParams) {
throw new Error('Not implemented')
}
/**
* Parse a product.
*/
parseProduct(data) {
throw new Error('Not implemented')
}
/**
* Parse products.
*/
parseProducts(data) {
throw new Error('Not implemented')
}
/**
* Parse a store.
*/
parseStore(data) {
throw new Error('Not implemented')
}
/**
* Parse a StoreSearchResult
*/
parseSearchStores(data, searchParams) {
throw new Error('Not implemented')
}
/**
* Parse a cart
*/
parseCart(data) {
throw new Error('Not implemented')
}
/**
* Parse a cart item
*/
parseCartItem(data) {
throw new Error('Not implemented')
}
/**
* Parse an order address
*/
parseOrderAddress(data) {
throw new Error('Not implemented')
}
/**
* Parse customer information
*/
parseCustomerInformation(data) {
throw new Error('Not implemented')
}
/**
* Parse a shipping method
*/
parseShippingMethod(data) {
throw new Error('Not implemented')
}
/**
* Parse a payment.
*/
parsePayment(data) {
throw new Error('Not implemented')
}
/**
* Parse a payment method.
*/
parsePaymentMethod(data) {
throw new Error('Not implemented')
}
}
|