Best JavaScript code snippet using playwright-internal
api.js
Source:api.js
...11class CLApi {1213 // Address14 listAddresses(filter, options) {15 return request(client.newRequest('/api/addresses').setParams(filter).setOptions(options));16 }1718 retrieveAddress(id, filter, options) {19 return request(client.newRequest(`/api/addresses/${id}`).setParams(filter).setOptions(options));20 }2122 createAddress(address, filter, options) {23 return request(client.newRequest('/api/addresses', 'post').setBody(address).setParams(filter).setOptions(options));24 }2526 updateAddress(id, address, filter, options) {27 return request(client.newRequest(`/api/addresses/${id}`, 'patch').setBody(address).setParams(filter).setOptions(options));28 }2930 deleteAddress(id) {31 return request(client.newRequest(`/api/addresses/${id}`, 'delete'));32 }3334 allAddresses(filter, options) {35 return all(this.listAddresses, filter, options);36 }37383940 // Credit Card41 listCreditCards(filter, options) {42 return request(client.newRequest('/api/credit_cards').setParams(filter).setOptions(options));43 }4445 retrieveCreditCard(id, filter, options) {46 return request(client.newRequest(`/api/credit_cards/${id}`).setParams(filter).setOptions(options));47 }4849 createCreditCard(credit_card, filter, options) {50 return request(client.newRequest('/api/credit_cards', 'post').setBody(credit_card).setParams(filter).setOptions(options));51 }5253 updateCreditCard(id, credit_card, filter, options) {54 return request(client.newRequest(`/api/credit_cards/${id}`, 'patch').setBody(credit_card).setParams(filter).setOptions(options));55 }5657 deleteCreditCard(id) {58 return request(client.newRequest(`/api/credit_cards/${id}`, 'delete'));59 }6061 allCreditCards(filter, options) {62 return all(this.listCreditCards, filter, options);63 }64656667 // Customer Address68 listCustomerAddresses(filter, options) {69 return request(client.newRequest('/api/customer_addresses').setParams(filter).setOptions(options));70 }7172 retrieveCustomerAddress(id, filter, options) {73 return request(client.newRequest(`/api/customer_addresses/${id}`).setParams(filter).setOptions(options));74 }7576 createCustomerAddress(customer_address, filter, options) {77 return request(client.newRequest('/api/customer_addresses', 'post').setBody(customer_address).setParams(filter).setOptions(options));78 }7980 updateCustomerAddress(id, customer_address, filter, options) {81 return request(client.newRequest(`/api/customer_addresses/${id}`, 'patch').setBody(customer_address).setParams(filter).setOptions(options));82 }8384 deleteCustomerAddress(id) {85 return request(client.newRequest(`/api/customer_addresses/${id}`, 'delete'));86 }8788 allCustomerAddresses(filter, options) {89 return all(this.listCustomerAddresses, filter, options);90 }91929394 // Customer Group95 listCustomerGroups(filter, options) {96 return request(client.newRequest('/api/customer_groups').setParams(filter).setOptions(options));97 }9899 retrieveCustomerGroup(id, filter, options) {100 return request(client.newRequest(`/api/customer_groups/${id}`).setParams(filter).setOptions(options));101 }102103 createCustomerGroup(customer_group, filter, options) {104 return request(client.newRequest('/api/customer_groups', 'post').setBody(customer_group).setParams(filter).setOptions(options));105 }106107 updateCustomerGroup(id, customer_group, filter, options) {108 return request(client.newRequest(`/api/customer_groups/${id}`, 'patch').setBody(customer_group).setParams(filter).setOptions(options));109 }110111 deleteCustomerGroup(id) {112 return request(client.newRequest(`/api/customer_groups/${id}`, 'delete'));113 }114115 allCustomerGroups(filter, options) {116 return all(this.listCustomerGroups, filter, options);117 }118119120121 // Customer Password Reset122 listCustomerPasswordResets(filter, options) {123 return request(client.newRequest('/api/customer_password_resets').setParams(filter).setOptions(options));124 }125126 retrieveCustomerPasswordReset(id, filter, options) {127 return request(client.newRequest(`/api/customer_password_resets/${id}`).setParams(filter).setOptions(options));128 }129130 createCustomerPasswordReset(customer_password_reset, filter, options) {131 return request(client.newRequest('/api/customer_password_resets', 'post').setBody(customer_password_reset).setParams(filter).setOptions(options));132 }133134 updateCustomerPasswordReset(id, customer_password_reset, filter, options) {135 return request(client.newRequest(`/api/customer_password_resets/${id}`, 'patch').setBody(customer_password_reset).setParams(filter).setOptions(options));136 }137138 deleteCustomerPasswordReset(id) {139 return request(client.newRequest(`/api/customer_password_resets/${id}`, 'delete'));140 }141142 allCustomerPasswordResets(filter, options) {143 return all(this.listCustomerPasswordResets, filter, options);144 }145146147148 // Customer Payment Source149 listCustomerPaymentSources(filter, options) {150 return request(client.newRequest('/api/customer_payment_sources').setParams(filter).setOptions(options));151 }152153 retrieveCustomerPaymentSource(id, filter, options) {154 return request(client.newRequest(`/api/customer_payment_sources/${id}`).setParams(filter).setOptions(options));155 }156157 createCustomerPaymentSource(customer_payment_source, filter, options) {158 return request(client.newRequest('/api/customer_payment_sources', 'post').setBody(customer_payment_source).setParams(filter).setOptions(options));159 }160161 updateCustomerPaymentSource(id, customer_payment_source, filter, options) {162 return request(client.newRequest(`/api/customer_payment_sources/${id}`, 'patch').setBody(customer_payment_source).setParams(filter).setOptions(options));163 }164165 deleteCustomerPaymentSource(id) {166 return request(client.newRequest(`/api/customer_payment_sources/${id}`, 'delete'));167 }168169 allCustomerPaymentSources(filter, options) {170 return all(this.listCustomerPaymentSources, filter, options);171 }172173174175 // Customer Subscription176 listCustomerSubscriptions(filter, options) {177 return request(client.newRequest('/api/customer_subscriptions').setParams(filter).setOptions(options));178 }179180 retrieveCustomerSubscription(id, filter, options) {181 return request(client.newRequest(`/api/customer_subscriptions/${id}`).setParams(filter).setOptions(options));182 }183184 createCustomerSubscription(customer_subscription, filter, options) {185 return request(client.newRequest('/api/customer_subscriptions', 'post').setBody(customer_subscription).setParams(filter).setOptions(options));186 }187188 updateCustomerSubscription(id, customer_subscription, filter, options) {189 return request(client.newRequest(`/api/customer_subscriptions/${id}`, 'patch').setBody(customer_subscription).setParams(filter).setOptions(options));190 }191192 deleteCustomerSubscription(id) {193 return request(client.newRequest(`/api/customer_subscriptions/${id}`, 'delete'));194 }195196 allCustomerSubscriptions(filter, options) {197 return all(this.listCustomerSubscriptions, filter, options);198 }199200201202 // Customer203 listCustomers(filter, options) {204 return request(client.newRequest('/api/customers').setParams(filter).setOptions(options));205 }206207 retrieveCustomer(id, filter, options) {208 return request(client.newRequest(`/api/customers/${id}`).setParams(filter).setOptions(options));209 }210211 createCustomer(customer, filter, options) {212 return request(client.newRequest('/api/customers', 'post').setBody(customer).setParams(filter).setOptions(options));213 }214215 updateCustomer(id, customer, filter, options) {216 return request(client.newRequest(`/api/customers/${id}`, 'patch').setBody(customer).setParams(filter).setOptions(options));217 }218219 deleteCustomer(id) {220 return request(client.newRequest(`/api/customers/${id}`, 'delete'));221 }222223 allCustomers(filter, options) {224 return all(this.listCustomers, filter, options);225 }226227228229 // Delivery Lead Time230 listDeliveryLeadTimes(filter, options) {231 return request(client.newRequest('/api/delivery_lead_times').setParams(filter).setOptions(options));232 }233234 retrieveDeliveryLeadTime(id, filter, options) {235 return request(client.newRequest(`/api/delivery_lead_times/${id}`).setParams(filter).setOptions(options));236 }237238 createDeliveryLeadTime(delivery_lead_time, filter, options) {239 return request(client.newRequest('/api/delivery_lead_times', 'post').setBody(delivery_lead_time).setParams(filter).setOptions(options));240 }241242 updateDeliveryLeadTime(id, delivery_lead_time, filter, options) {243 return request(client.newRequest(`/api/delivery_lead_times/${id}`, 'patch').setBody(delivery_lead_time).setParams(filter).setOptions(options));244 }245246 deleteDeliveryLeadTime(id) {247 return request(client.newRequest(`/api/delivery_lead_times/${id}`, 'delete'));248 }249250 allDeliveryLeadTimes(filter, options) {251 return all(this.listDeliveryLeadTimes, filter, options);252 }253254255256 // Import257 listImports(filter, options) {258 return request(client.newRequest('/api/imports').setParams(filter).setOptions(options));259 }260261 retrieveImport(id, filter, options) {262 return request(client.newRequest(`/api/imports/${id}`).setParams(filter).setOptions(options));263 }264265 createImport(import_, filter, options) {266 return request(client.newRequest('/api/imports', 'post').setBody(import_).setParams(filter).setOptions(options));267 }268269 updateImport(id, import_, filter, options) {270 return request(client.newRequest(`/api/imports/${id}`, 'patch').setBody(import_).setParams(filter).setOptions(options));271 }272273 deleteImport(id) {274 return request(client.newRequest(`/api/imports/${id}`, 'delete'));275 }276277 allImports(filter, options) {278 return all(this.listImports, filter, options);279 }280281282283 // Inventory Model284 listInventoryModels(filter, options) {285 return request(client.newRequest('/api/inventory_models').setParams(filter).setOptions(options));286 }287288 retrieveInventoryModel(id, filter, options) {289 return request(client.newRequest(`/api/inventory_models/${id}`).setParams(filter).setOptions(options));290 }291292 createInventoryModel(inventory_model, filter, options) {293 return request(client.newRequest('/api/inventory_models', 'post').setBody(inventory_model).setParams(filter).setOptions(options));294 }295296 updateInventoryModel(id, inventory_model, filter, options) {297 return request(client.newRequest(`/api/inventory_models/${id}`, 'patch').setBody(inventory_model).setParams(filter).setOptions(options));298 }299300 deleteInventoryModel(id) {301 return request(client.newRequest(`/api/inventory_models/${id}`, 'delete'));302 }303304 allInventoryModels(filter, options) {305 return all(this.listInventoryModels, filter, options);306 }307308309310 // Line Item Option311 listLineItemOptions(filter, options) {312 return request(client.newRequest('/api/line_item_options').setParams(filter).setOptions(options));313 }314315 retrieveLineItemOption(id, filter, options) {316 return request(client.newRequest(`/api/line_item_options/${id}`).setParams(filter).setOptions(options));317 }318319 createLineItemOption(line_item_option, filter, options) {320 return request(client.newRequest('/api/line_item_options', 'post').setBody(line_item_option).setParams(filter).setOptions(options));321 }322323 updateLineItemOption(id, line_item_option, filter, options) {324 return request(client.newRequest(`/api/line_item_options/${id}`, 'patch').setBody(line_item_option).setParams(filter).setOptions(options));325 }326327 deleteLineItemOption(id) {328 return request(client.newRequest(`/api/line_item_options/${id}`, 'delete'));329 }330331 allLineItemOptions(filter, options) {332 return all(this.listLineItemOptions, filter, options);333 }334335336337 // Line Item338 listLineItems(filter, options) {339 return request(client.newRequest('/api/line_items').setParams(filter).setOptions(options));340 }341342 retrieveLineItem(id, filter, options) {343 return request(client.newRequest(`/api/line_items/${id}`).setParams(filter).setOptions(options));344 }345346 createLineItem(line_item, filter, options) {347 return request(client.newRequest('/api/line_items', 'post').setBody(line_item).setParams(filter).setOptions(options));348 }349350 updateLineItem(id, line_item, filter, options) {351 return request(client.newRequest(`/api/line_items/${id}`, 'patch').setBody(line_item).setParams(filter).setOptions(options));352 }353354 deleteLineItem(id) {355 return request(client.newRequest(`/api/line_items/${id}`, 'delete'));356 }357358 allLineItems(filter, options) {359 return all(this.listLineItems, filter, options);360 }361362363364 // Market365 listMarkets(filter, options) {366 return request(client.newRequest('/api/markets').setParams(filter).setOptions(options));367 }368369 retrieveMarket(id, filter, options) {370 return request(client.newRequest(`/api/markets/${id}`).setParams(filter).setOptions(options));371 }372373 createMarket(market, filter, options) {374 return request(client.newRequest('/api/markets', 'post').setBody(market).setParams(filter).setOptions(options));375 }376377 updateMarket(id, market, filter, options) {378 return request(client.newRequest(`/api/markets/${id}`, 'patch').setBody(market).setParams(filter).setOptions(options));379 }380381 deleteMarket(id) {382 return request(client.newRequest(`/api/markets/${id}`, 'delete'));383 }384385 allMarkets(filter, options) {386 return all(this.listMarkets, filter, options);387 }388389390391 // Merchant392 listMerchants(filter, options) {393 return request(client.newRequest('/api/merchants').setParams(filter).setOptions(options));394 }395396 retrieveMerchant(id, filter, options) {397 return request(client.newRequest(`/api/merchants/${id}`).setParams(filter).setOptions(options));398 }399400 createMerchant(merchant, filter, options) {401 return request(client.newRequest('/api/merchants', 'post').setBody(merchant).setParams(filter).setOptions(options));402 }403404 updateMerchant(id, merchant, filter, options) {405 return request(client.newRequest(`/api/merchants/${id}`, 'patch').setBody(merchant).setParams(filter).setOptions(options));406 }407408 deleteMerchant(id) {409 return request(client.newRequest(`/api/merchants/${id}`, 'delete'));410 }411412 allMerchants(filter, options) {413 return all(this.listMerchants, filter, options);414 }415416417418 // Order419 listOrders(filter, options) {420 return request(client.newRequest('/api/orders').setParams(filter).setOptions(options));421 }422423 retrieveOrder(id, filter, options) {424 return request(client.newRequest(`/api/orders/${id}`).setParams(filter).setOptions(options));425 }426427 createOrder(order, filter, options) {428 return request(client.newRequest('/api/orders', 'post').setBody(order).setParams(filter).setOptions(options));429 }430431 updateOrder(id, order, filter, options) {432 return request(client.newRequest(`/api/orders/${id}`, 'patch').setBody(order).setParams(filter).setOptions(options));433 }434435 deleteOrder(id) {436 return request(client.newRequest(`/api/orders/${id}`, 'delete'));437 }438439 allOrders(filter, options) {440 return all(this.listOrders, filter, options);441 }442443444445 // Parcel446 listParcels(filter, options) {447 return request(client.newRequest('/api/parcels').setParams(filter).setOptions(options));448 }449450 retrieveParcel(id, filter, options) {451 return request(client.newRequest(`/api/parcels/${id}`).setParams(filter).setOptions(options));452 }453454 createParcel(parcel, filter, options) {455 return request(client.newRequest('/api/parcels', 'post').setBody(parcel).setParams(filter).setOptions(options));456 }457458 updateParcel(id, parcel, filter, options) {459 return request(client.newRequest(`/api/parcels/${id}`, 'patch').setBody(parcel).setParams(filter).setOptions(options));460 }461462 deleteParcel(id) {463 return request(client.newRequest(`/api/parcels/${id}`, 'delete'));464 }465466 allParcels(filter, options) {467 return all(this.listParcels, filter, options);468 }469470471472 // Payment Method473 listPaymentMethods(filter, options) {474 return request(client.newRequest('/api/payment_methods').setParams(filter).setOptions(options));475 }476477 retrievePaymentMethod(id, filter, options) {478 return request(client.newRequest(`/api/payment_methods/${id}`).setParams(filter).setOptions(options));479 }480481 createPaymentMethod(payment_method, filter, options) {482 return request(client.newRequest('/api/payment_methods', 'post').setBody(payment_method).setParams(filter).setOptions(options));483 }484485 updatePaymentMethod(id, payment_method, filter, options) {486 return request(client.newRequest(`/api/payment_methods/${id}`, 'patch').setBody(payment_method).setParams(filter).setOptions(options));487 }488489 deletePaymentMethod(id) {490 return request(client.newRequest(`/api/payment_methods/${id}`, 'delete'));491 }492493 allPaymentMethods(filter, options) {494 return all(this.listPaymentMethods, filter, options);495 }496497498499 // Paypal Payment500 listPaypalPayments(filter, options) {501 return request(client.newRequest('/api/paypal_payments').setParams(filter).setOptions(options));502 }503504 retrievePaypalPayment(id, filter, options) {505 return request(client.newRequest(`/api/paypal_payments/${id}`).setParams(filter).setOptions(options));506 }507508 createPaypalPayment(paypal_payment, filter, options) {509 return request(client.newRequest('/api/paypal_payments', 'post').setBody(paypal_payment).setParams(filter).setOptions(options));510 }511512 updatePaypalPayment(id, paypal_payment, filter, options) {513 return request(client.newRequest(`/api/paypal_payments/${id}`, 'patch').setBody(paypal_payment).setParams(filter).setOptions(options));514 }515516 deletePaypalPayment(id) {517 return request(client.newRequest(`/api/paypal_payments/${id}`, 'delete'));518 }519520 allPaypalPayments(filter, options) {521 return all(this.listPaypalPayments, filter, options);522 }523524525526 // Price List527 listPriceLists(filter, options) {528 return request(client.newRequest('/api/price_lists').setParams(filter).setOptions(options));529 }530531 retrievePriceList(id, filter, options) {532 return request(client.newRequest(`/api/price_lists/${id}`).setParams(filter).setOptions(options));533 }534535 createPriceList(price_list, filter, options) {536 return request(client.newRequest('/api/price_lists', 'post').setBody(price_list).setParams(filter).setOptions(options));537 }538539 updatePriceList(id, price_list, filter, options) {540 return request(client.newRequest(`/api/price_lists/${id}`, 'patch').setBody(price_list).setParams(filter).setOptions(options));541 }542543 deletePriceList(id) {544 return request(client.newRequest(`/api/price_lists/${id}`, 'delete'));545 }546547 allPriceLists(filter, options) {548 return all(this.listPriceLists, filter, options);549 }550551552553 // Price554 listPrices(filter, options) {555 return request(client.newRequest('/api/prices').setParams(filter).setOptions(options));556 }557558 retrievePrice(id, filter, options) {559 return request(client.newRequest(`/api/prices/${id}`).setParams(filter).setOptions(options));560 }561562 createPrice(price, filter, options) {563 return request(client.newRequest('/api/prices', 'post').setBody(price).setParams(filter).setOptions(options));564 }565566 updatePrice(id, price, filter, options) {567 return request(client.newRequest(`/api/prices/${id}`, 'patch').setBody(price).setParams(filter).setOptions(options));568 }569570 deletePrice(id) {571 return request(client.newRequest(`/api/prices/${id}`, 'delete'));572 }573574 allPrices(filter, options) {575 return all(this.listPrices, filter, options);576 }577578579580 // Shipment581 listShipments(filter, options) {582 return request(client.newRequest('/api/shipments').setParams(filter).setOptions(options));583 }584585 retrieveShipment(id, filter, options) {586 return request(client.newRequest(`/api/shipments/${id}`).setParams(filter).setOptions(options));587 }588589 createShipment(shipment, filter, options) {590 return request(client.newRequest('/api/shipments', 'post').setBody(shipment).setParams(filter).setOptions(options));591 }592593 updateShipment(id, shipment, filter, options) {594 return request(client.newRequest(`/api/shipments/${id}`, 'patch').setBody(shipment).setParams(filter).setOptions(options));595 }596597 deleteShipment(id) {598 return request(client.newRequest(`/api/shipments/${id}`, 'delete'));599 }600601 allShipments(filter, options) {602 return all(this.listShipments, filter, options);603 }604605606607 // Shipping Category608 listShippingCategories(filter, options) {609 return request(client.newRequest('/api/shipping_categories').setParams(filter).setOptions(options));610 }611612 retrieveShippingCategory(id, filter, options) {613 return request(client.newRequest(`/api/shipping_categories/${id}`).setParams(filter).setOptions(options));614 }615616 createShippingCategory(shipping_category, filter, options) {617 return request(client.newRequest('/api/shipping_categories', 'post').setBody(shipping_category).setParams(filter).setOptions(options));618 }619620 updateShippingCategory(id, shipping_category, filter, options) {621 return request(client.newRequest(`/api/shipping_categories/${id}`, 'patch').setBody(shipping_category).setParams(filter).setOptions(options));622 }623624 deleteShippingCategory(id) {625 return request(client.newRequest(`/api/shipping_categories/${id}`, 'delete'));626 }627628 allShippingCategories(filter, options) {629 return all(this.listShippingCategories, filter, options);630 }631632633634 // Shipping Method635 listShippingMethods(filter, options) {636 return request(client.newRequest('/api/shipping_methods').setParams(filter).setOptions(options));637 }638639 retrieveShippingMethod(id, filter, options) {640 return request(client.newRequest(`/api/shipping_methods/${id}`).setParams(filter).setOptions(options));641 }642643 createShippingMethod(shipping_method, filter, options) {644 return request(client.newRequest('/api/shipping_methods', 'post').setBody(shipping_method).setParams(filter).setOptions(options));645 }646647 updateShippingMethod(id, shipping_method, filter, options) {648 return request(client.newRequest(`/api/shipping_methods/${id}`, 'patch').setBody(shipping_method).setParams(filter).setOptions(options));649 }650651 deleteShippingMethod(id) {652 return request(client.newRequest(`/api/shipping_methods/${id}`, 'delete'));653 }654655 allShippingMethods(filter, options) {656 return all(this.listShippingMethods, filter, options);657 }658659660661 // Shipping Zone662 listShippingZones(filter, options) {663 return request(client.newRequest('/api/shipping_zones').setParams(filter).setOptions(options));664 }665666 retrieveShippingZone(id, filter, options) {667 return request(client.newRequest(`/api/shipping_zones/${id}`).setParams(filter).setOptions(options));668 }669670 createShippingZone(shipping_zone, filter, options) {671 return request(client.newRequest('/api/shipping_zones', 'post').setBody(shipping_zone).setParams(filter).setOptions(options));672 }673674 updateShippingZone(id, shipping_zone, filter, options) {675 return request(client.newRequest(`/api/shipping_zones/${id}`, 'patch').setBody(shipping_zone).setParams(filter).setOptions(options));676 }677678 deleteShippingZone(id) {679 return request(client.newRequest(`/api/shipping_zones/${id}`, 'delete'));680 }681682 allShippingZones(filter, options) {683 return all(this.listShippingZones, filter, options);684 }685686687688 // Sku Option689 listSkuOptions(filter, options) {690 return request(client.newRequest('/api/sku_options').setParams(filter).setOptions(options));691 }692693 retrieveSkuOption(id, filter, options) {694 return request(client.newRequest(`/api/sku_options/${id}`).setParams(filter).setOptions(options));695 }696697 createSkuOption(sku_option, filter, options) {698 return request(client.newRequest('/api/sku_options', 'post').setBody(sku_option).setParams(filter).setOptions(options));699 }700701 updateSkuOption(id, sku_option, filter, options) {702 return request(client.newRequest(`/api/sku_options/${id}`, 'patch').setBody(sku_option).setParams(filter).setOptions(options));703 }704705 deleteSkuOption(id) {706 return request(client.newRequest(`/api/sku_options/${id}`, 'delete'));707 }708709 allSkuOptions(filter, options) {710 return all(this.listSkuOptions, filter, options);711 }712713714715 // Sku716 listSkus(filter, options) {717 return request(client.newRequest('/api/skus').setParams(filter).setOptions(options));718 }719720 retrieveSku(id, filter, options) {721 return request(client.newRequest(`/api/skus/${id}`).setParams(filter).setOptions(options));722 }723724 createSku(sku, filter, options) {725 return request(client.newRequest('/api/skus', 'post').setBody(sku).setParams(filter).setOptions(options));726 }727728 updateSku(id, sku, filter, options) {729 return request(client.newRequest(`/api/skus/${id}`, 'patch').setBody(sku).setParams(filter).setOptions(options));730 }731732 deleteSku(id) {733 return request(client.newRequest(`/api/skus/${id}`, 'delete'));734 }735736 allSkus(filter, options) {737 return all(this.listSkus, filter, options);738 }739740741742 // Stock Item743 listStockItems(filter, options) {744 return request(client.newRequest('/api/stock_items').setParams(filter).setOptions(options));745 }746747 retrieveStockItem(id, filter, options) {748 return request(client.newRequest(`/api/stock_items/${id}`).setParams(filter).setOptions(options));749 }750751 createStockItem(stock_item, filter, options) {752 return request(client.newRequest('/api/stock_items', 'post').setBody(stock_item).setParams(filter).setOptions(options));753 }754755 updateStockItem(id, stock_item, filter, options) {756 return request(client.newRequest(`/api/stock_items/${id}`, 'patch').setBody(stock_item).setParams(filter).setOptions(options));757 }758759 deleteStockItem(id) {760 return request(client.newRequest(`/api/stock_items/${id}`, 'delete'));761 }762763 allStockItems(filter, options) {764 return all(this.listStockItems, filter, options);765 }766767768769 // Stock Level770 listStockLevels(filter, options) {771 return request(client.newRequest('/api/stock_levels').setParams(filter).setOptions(options));772 }773774 retrieveStockLevel(id, filter, options) {775 return request(client.newRequest(`/api/stock_levels/${id}`).setParams(filter).setOptions(options));776 }777778 createStockLevel(stock_level, filter, options) {779 return request(client.newRequest('/api/stock_levels', 'post').setBody(stock_level).setParams(filter).setOptions(options));780 }781782 updateStockLevel(id, stock_level, filter, options) {783 return request(client.newRequest(`/api/stock_levels/${id}`, 'patch').setBody(stock_level).setParams(filter).setOptions(options));784 }785786 deleteStockLevel(id) {787 return request(client.newRequest(`/api/stock_levels/${id}`, 'delete'));788 }789790 allStockLevels(filter, options) {791 return all(this.listStockLevels, filter, options);792 }793794795796 // Stock Location797 listStockLocations(filter, options) {798 return request(client.newRequest('/api/stock_locations').setParams(filter).setOptions(options));799 }800801 retrieveStockLocation(id, filter, options) {802 return request(client.newRequest(`/api/stock_locations/${id}`).setParams(filter).setOptions(options));803 }804805 createStockLocation(stock_location, filter, options) {806 return request(client.newRequest('/api/stock_locations', 'post').setBody(stock_location).setParams(filter).setOptions(options));807 }808809 updateStockLocation(id, stock_location, filter, options) {810 return request(client.newRequest(`/api/stock_locations/${id}`, 'patch').setBody(stock_location).setParams(filter).setOptions(options));811 }812813 deleteStockLocation(id) {814 return request(client.newRequest(`/api/stock_locations/${id}`, 'delete'));815 }816817 allStockLocations(filter, options) {818 return all(this.listStockLocations, filter, options);819 }820821822823 // Webhook824 listWebhooks(filter, options) {825 return request(client.newRequest('/api/webhooks').setParams(filter).setOptions(options));826 }827828 retrieveWebhook(id, filter, options) {829 return request(client.newRequest(`/api/webhooks/${id}`).setParams(filter).setOptions(options));830 }831832 createWebhook(webhook, filter, options) {833 return request(client.newRequest('/api/webhooks', 'post').setBody(webhook).setParams(filter).setOptions(options));834 }835836 updateWebhook(id, webhook, filter, options) {837 return request(client.newRequest(`/api/webhooks/${id}`, 'patch').setBody(webhook).setParams(filter).setOptions(options));838 }839840 deleteWebhook(id) {841 return request(client.newRequest(`/api/webhooks/${id}`, 'delete'));842 }843844 allWebhooks(filter, options) {845 return all(this.listWebhooks, filter, options);846 }847848849850 // Wire Transfer851 listWireTransfers(filter, options) {852 return request(client.newRequest('/api/wire_transfers').setParams(filter).setOptions(options));853 }854855 retrieveWireTransfer(id, filter, options) {856 return request(client.newRequest(`/api/wire_transfers/${id}`).setParams(filter).setOptions(options));857 }858859 createWireTransfer(wire_transfer, filter, options) {860 return request(client.newRequest('/api/wire_transfers', 'post').setBody(wire_transfer).setParams(filter).setOptions(options));861 }862863 updateWireTransfer(id, wire_transfer, filter, options) {864 return request(client.newRequest(`/api/wire_transfers/${id}`, 'patch').setBody(wire_transfer).setParams(filter).setOptions(options));865 }866867 deleteWireTransfer(id) {868 return request(client.newRequest(`/api/wire_transfers/${id}`, 'delete'));869 }870871 allWireTransfers(filter, options) {872 return all(this.listWireTransfers, filter, options);873 }874875876}877878879var api = new CLApi();880881module.exports.clapi = api;882
...
recruiter.js
Source:recruiter.js
1import { splice, del } from 'immutable-arrays'2import type { Action } from '../../types/actions'3import type { RecruiterState as State } from '../../types/states'4const initialState = {5 newRequest: {6 editInfoTab: true,7 editFullTab: true,8 openSelectorEmployeesModal: false,9 employees: [],10 activeMilestone: null,11 milestonesTemplate: [],12 selectMilestonesTemplate: [],13 currentMilestonesTemplate: null,14 milestones: [],15 milestonesGroups: [],16 currentMilestonesGroup: null,17 selectRecruiterRole: [],18 selectGeneralRecruiterRole: [],19 selectManagerRecruiterRole: [],20 },21}22function getRecruiterRoleInfoResFunc(state, payload) {23 const selectRecruiterRole = payload.map(e => ({24 label: `${e.full_name}`,25 value: e.id,26 }))27 const newRequest = {28 ...state.newRequest,29 selectRecruiterRole,30 }31 return { ...state, newRequest }32}33function getRecruiterManagerRoleInfoResFunc(state, payload) {34 const selectManagerRecruiterRole = payload.map(e => ({35 label: `${e.full_name}`,36 value: e.id,37 }))38 const newRequest = {39 ...state.newRequest,40 selectManagerRecruiterRole,41 }42 return { ...state, newRequest }43}44function getRecruiterGeneralRoleInfoResFunc(state, payload) {45 const selectGeneralRecruiterRole = payload.map(e => ({46 label: `${e.full_name}`,47 value: e.id,48 }))49 const newRequest = {50 ...state.newRequest,51 selectGeneralRecruiterRole,52 }53 return { ...state, newRequest }54}55function changeMilestonesGroupsFunc(state, payload) {56 const milestones = state.newRequest.milestones.map(e => ({57 ...e,58 vacancy_stage_group_id: e.position === payload.position ? payload.value.id : e.vacancy_stage_group_id,59 }))60 const newRequest = {61 ...state.newRequest,62 milestones,63 currentMilestonesGroup: payload.value,64 }65 return { ...state, newRequest }66}67function changeMilestoneEvaluationFunc(state, payload) {68 const milestones = state.newRequest.milestones.map(e => ({69 ...e,70 evaluation_of_candidate: e.position === payload.position ? payload.value : e.evaluation_of_candidate,71 }))72 const newRequest = {73 ...state.newRequest,74 milestones,75 }76 return { ...state, newRequest }77}78function changeMilestoneNotificationFunc(state, payload) {79 const milestones = state.newRequest.milestones.map((e, idx) => ({80 ...e,81 position: idx,82 need_notification: e.position === payload.position ? payload.value : e.need_notification,83 }))84 const newRequest = {85 ...state.newRequest,86 milestones,87 }88 return { ...state, newRequest }89}90function getMilestonesTemplateFunc(state, payload) {91 const selectMilestonesTemplate = payload.map(e => ({ value: e.id, label: e.name }))92 const newRequest = {93 ...state.newRequest,94 milestonesTemplate: payload,95 selectMilestonesTemplate,96 }97 return { ...state, newRequest }98}99function setMilestonesTemplateFunc(state, payload) {100 const { milestonesTemplate } = state.newRequest101 const milestones = milestonesTemplate102 .find(e => e.id === payload)103 .vacancy_stages104 .map((item, idx) => ({...item, position: idx}))105 return { ...state, newRequest: { ...state.newRequest, milestones } }106}107function setMilestones(state, payload) {108 return { ...state, newRequest: { ...state.newRequest, milestones: payload.map((item, idx) => ({...item, position: idx})) } }109}110function resetMilestones(state) {111 return {112 ...state,113 newRequest: {114 ...state.newRequest,115 milestones: initialState.newRequest.milestones,116 currentMilestonesTemplate: initialState.newRequest.currentMilestonesTemplate,117 },118 }119}120function addEmployeesFunc(state, payload) {121 const employees = state.newRequest.employees122 employees.push(payload)123 return { ...state, newRequest: { ...state.newRequest, employees } }124}125function changeMilestonesFunc(state, payload) {126 const id = payload.find((e, i) => e.active && i)127 const newRequest = {128 ...state.newRequest,129 milestones: payload.map((item, idx) => ({...item, position: idx})),130 activeMilestone: id,131 }132 return { ...state, newRequest }133}134function selectMilestonesFunc(state, payload) {135 const { milestones } = state.newRequest136 const newMilestones = milestones.map((e, i) => ({ ...e, active: i === payload.position }))137 const currentMilestonesGroup = state.newRequest.milestonesGroups.find(138 e => e.id === payload.value.vacancy_stage_group_id139 )140 const newRequest = {141 ...state.newRequest,142 milestones: newMilestones,143 activeMilestone: payload.position,144 currentMilestonesGroup,145 }146 return { ...state, newRequest }147}148function renameMilestonesTitleFunc(state, payload) {149 const { milestones, activeMilestone } = state.newRequest150 const newMilestones = milestones.map((e, i) => ({151 ...e,152 name: i === activeMilestone ? payload.value : e.name,153 }))154 const newRequest = { ...state.newRequest, milestones: newMilestones }155 return { ...state, newRequest }156}157function addLeftMilestonesFunc(state, { milestone }) {158 const milestones = [...state.newRequest.milestones]159 const newActiveMilestone = milestone.position + 1160 milestones.splice(milestone.position, 0, {161 active: false,162 can_create_left: true,163 can_create_right: true,164 editable: true,165 evaluation_of_candidate: false,166 group_name: 'new',167 must_be_last: false,168 name: `ÐовÑй ÑÑап ${milestone.position}`,169 need_notification: false,170 template_stage_id: 1,171 type_of_rating: 'passing',172 vacancy_id: null,173 vacancy_stage_group_id: milestone.vacancy_stage_group_id,174 })175 return {176 ...state,177 newRequest: {178 ...state.newRequest,179 milestones: milestones.map((e, i) => ({ ...e, position: i, active: i === newActiveMilestone - 1 })),180 activeMilestone: newActiveMilestone,181 },182 }183}184function addRightMilestonesFunc(state, { milestone }) {185 const milestones = [...state.newRequest.milestones]186 const newActiveMilestone = milestone.position + 1187 milestones.splice(milestone.position + 1, 0, {188 active: false,189 can_create_left: true,190 can_create_right: true,191 editable: true,192 evaluation_of_candidate: false,193 group_name: 'new',194 must_be_last: false,195 name: `ÐовÑй ÑÑап ${milestone.position}`,196 need_notification: false,197 template_stage_id: 1,198 type_of_rating: 'passing',199 vacancy_id: null,200 vacancy_stage_group_id: milestone.vacancy_stage_group_id,201 })202 return {203 ...state,204 newRequest: {205 ...state.newRequest,206 milestones: milestones.map((e, i) => ({ ...e, position: i, active: i === newActiveMilestone })),207 activeMilestone: newActiveMilestone,208 },209 }210}211function deleteMilestonesFunc(state) {212 const { milestones, activeMilestone } = state.newRequest213 const newActiveMilestone = activeMilestone - 1214 const delMilestones = del(milestones, activeMilestone)215 const newMilestones = delMilestones.map((e, i) => ({ ...e, active: i === newActiveMilestone, position: i }))216 return {217 ...state,218 newRequest: {219 ...state.newRequest,220 milestones: newMilestones,221 activeMilestone: newActiveMilestone,222 },223 }224}225function createVacancyFunc(state) {226 const newRequest = {227 ...state.newRequest,228 currentMilestonesTemplate: null,229 currentMilestonesGroup: null,230 }231 return { ...state, newRequest }232}233export default (state = initialState, action) => {234 const { payload } = action235 switch (action.type) {236 case 'EDIT_NEW_REQUIEST_INFO_TAB':237 return { ...state, newRequest: { ...state.newRequest, editInfoTab: true } }238 case 'SAVE_NEW_REQUIEST_INFO_TAB':239 return { ...state, newRequest: { ...state.newRequest, editInfoTab: false } }240 case 'EDIT_NEW_REQUIEST_FULL_TAB':241 return { ...state, newRequest: { ...state.newRequest, editFullTab: true } }242 case 'SAVE_NEW_REQUIEST_FULL_TAB':243 return { ...state, newRequest: { ...state.newRequest, editFullTab: false } }244 case 'OPEN_SELECTOR_EMPLOYEES_MODAL':245 return { ...state, newRequest: { ...state.newRequest, openSelectorEmployeesModal: true } }246 case 'CLOSE_SELECTOR_EMPLOYEES_MODAL':247 return { ...state, newRequest: { ...state.newRequest, openSelectorEmployeesModal: false } }248 case 'SET_CURRENT_MILESTONES_TEMPLATE':249 return { ...state, newRequest: { ...state.newRequest, currentMilestonesTemplate: payload } }250 case 'GET_MILESTONES_GROUP_RES':251 return { ...state, newRequest: { ...state.newRequest, milestonesGroups: payload } }252 case 'CHANGE_MILESTONES_GROUPS':253 return changeMilestonesGroupsFunc(state, payload)254 case 'GET_MILESTONES_TEMPLATE_RES':255 return getMilestonesTemplateFunc(state, payload)256 case 'SELECT_MILESTONES':257 return selectMilestonesFunc(state, payload)258 case 'RENAME_MILESTONES_TITLE':259 return renameMilestonesTitleFunc(state, payload)260 case 'ADD_LEFT_MILESTONES':261 return addLeftMilestonesFunc(state, payload)262 case 'ADD_RIGHT_MILESTONES':263 return addRightMilestonesFunc(state, payload)264 case 'CHANGE_MILESTONES':265 return changeMilestonesFunc(state, payload)266 case 'DELETE_MILESTONES':267 return deleteMilestonesFunc(state, payload)268 case 'SET_MILESTONES_TEMPLATE':269 return setMilestonesTemplateFunc(state, payload)270 case 'SET_MILESTONES':271 return setMilestones(state, payload)272 case 'RESET_MILESTONES':273 return resetMilestones(state)274 case 'CHANGE_MILESTONE_NOTIFICATION':275 return changeMilestoneNotificationFunc(state, payload)276 case 'CHANGE_MILESTONE_EVALUATION':277 return changeMilestoneEvaluationFunc(state, payload)278 case 'GET_RECRUITER_ROLE_INFO_RES':279 return getRecruiterRoleInfoResFunc(state, payload)280 case 'GET_MANAGER_RECRUITER_ROLE_INFO_RES':281 return getRecruiterManagerRoleInfoResFunc(state, payload)282 case 'GET_GENERAL_RECRUITER_ROLE_INFO_RES':283 return getRecruiterGeneralRoleInfoResFunc(state, payload)284 case 'ADD_SELECTOR_EMPLOYEES':285 return addEmployeesFunc(state, payload)286 case 'CREATE_VACANCY_RES':287 case 'UPDATE_VACANCY_RES':288 return createVacancyFunc(state, payload)289 default:290 return state291 }...
receive.ctrl.js
Source:receive.ctrl.js
1(function() {2 "use strict";3 angular.module("blocktrail.wallet")4 .controller("ReceiveCtrl", ReceiveCtrl);5 function ReceiveCtrl($scope, $rootScope, $q, CONFIG, activeWallet, settingsService, CurrencyConverter, Currencies,6 trackingService) {7 var walletData = activeWallet.getReadOnlyWalletData();8 var settingsData = settingsService.getReadOnlySettingsData();9 // get current active wallets native currency10 var nativeCurrency = CONFIG.NETWORKS[walletData.networkType].TICKER;11 var listenerGroupValues;12 $rootScope.pageTitle = "RECEIVE";13 $scope.isLoading = true;14 $scope.useCashAddress = CONFIG.NETWORKS[walletData.networkType].CASHADDRESS;15 $scope.newRequest = {16 address: null,17 btcValue: "",18 fiatValue: 0,19 message: null,20 bitcoinUri: ""21 };22 $scope.qrSettings = {23 correctionLevel: 7,24 SIZE: 225,25 inputMode: "M",26 image: true27 };28 $scope.swapInputs = function() {29 $scope.fiatFirst = !$scope.fiatFirst;30 };31 $scope.currencies = null;32 $scope.currencyType = null;33 $scope.altCurrency = {};34 // Methods35 $scope.updateCurrentType = updateCurrentType;36 $scope.setAltCurrency = setAltCurrency;37 $scope.$on("enabled_currency", function() {38 updateCurrentType($scope.currencyType);39 });40 $scope.$watch("useCashAddress", function(newValue, oldValue) {41 if (newValue !== oldValue && $scope.newRequest.address) {42 if (newValue) {43 $scope.newRequest.address = activeWallet.getSdkWallet().sdk.getCashAddressFromLegacyAddress($scope.newRequest.address);44 } else {45 $scope.newRequest.address = activeWallet.getSdkWallet().sdk.getLegacyBitcoinCashAddress($scope.newRequest.address);46 }47 }48 });49 $scope.$on("$destroy", onDestroy);50 initData();51 /**52 * Init data53 */54 function initData() {55 // set default BTC56 updateCurrentType(nativeCurrency);57 // generate the first address58 $q.when(getNewAddress())59 .then(function() {60 generateQR();61 // Add watchers62 listenerGroupValues = $scope.$watchGroup(["newRequest.btcValue", "newRequest.address", "currencyType"], updateQRAndSetAltCurrency);63 $scope.isLoading = false;64 });65 }66 /**67 * Update currency type68 * @param currencyType69 */70 function updateCurrentType(currencyType) {71 $scope.currencies = Currencies.getCurrencies();72 // filter out crypto currencies that are not current73 $scope.currencies = $scope.currencies.filter(function(currency) {74 return currency.isFiat || currency.code === nativeCurrency;75 });76 // filter out selected currency77 $scope.currencies = $scope.currencies.filter(function(currency) {78 return currency.code !== currencyType;79 });80 $scope.currencyType = currencyType;81 setAltCurrency();82 }83 /**84 * Set alt currency85 */86 function setAltCurrency() {87 if ($scope.currencyType === nativeCurrency) {88 $scope.altCurrency.code = settingsData.localCurrency;89 $scope.altCurrency.amount = parseFloat(CurrencyConverter.fromBTC($scope.newRequest.btcValue, settingsData.localCurrency, 2)) || 0;90 } else {91 $scope.altCurrency.code = nativeCurrency;92 $scope.altCurrency.amount = parseFloat(CurrencyConverter.toBTC($scope.newRequest.btcValue, $scope.currencyType, 6)) || 0;93 }94 if ($scope.altCurrency.amount > 0) {95 trackingService.trackEvent(trackingService.EVENTS.RECEIVE_CUSTOM_AMOUNT);96 }97 }98 /**99 * Get new address100 */101 function getNewAddress() {102 $scope.newRequest.address = null;103 return $q.when(activeWallet.getNewAddress())104 .then(function(address) {105 $scope.newRequest.address = address;106 })107 .catch(function(e) {108 console.log(e);109 });110 }111 /**112 * Generate QR113 * @return { boolean }114 */115 function generateQR() {116 if (!$scope.newRequest.address) {117 return false;118 }119 var prefix = CONFIG.NETWORKS[walletData.networkType].URIPREFIX;120 if (CONFIG.NETWORKS[walletData.networkType].CASHADDRESS) {121 prefix = "";122 if (!$scope.useCashAddress) {123 prefix = CONFIG.NETWORKS["BTC"].URIPREFIX;124 }125 }126 $scope.newRequest.bitcoinUri = prefix + $scope.newRequest.address;127 $scope.newRequest.qrValue = 0;128 if ($scope.currencyType === nativeCurrency) {129 $scope.newRequest.qrValue = parseFloat($scope.newRequest.btcValue);130 } else {131 $scope.newRequest.qrValue = parseFloat($scope.altCurrency.amount);132 }133 if (!isNaN($scope.newRequest.qrValue) && $scope.newRequest.qrValue.toFixed(8) !== "0.00000000") {134 $scope.newRequest.bitcoinUri += "?amount=" + $scope.newRequest.qrValue.toFixed(8);135 }136 }137 /**138 * Update the URI and QR code when address or value change139 * @param newValue140 * @param oldValue141 */142 function updateQRAndSetAltCurrency(newValue, oldValue) {143 if (newValue !== oldValue) {144 setAltCurrency();145 // ignore call from scope initialisation146 generateQR();147 }148 }149 /**150 * On destroy151 */152 function onDestroy() {153 if (listenerGroupValues) {154 listenerGroupValues();155 }156 }157 }...
requests.js
Source:requests.js
1// $(document).ready(function(){2 function Request() {3 this.type = '';4 this.url = '';5 this.data = {};6 this.dataType = 'json';7 this.success = function(response){8 }9 };10 //------------------ Create User --------------------11 function createUser(username, email, password, callback) {12 var newRequest = new Request();13 newRequest['type'] = 'POST';14 newRequest['url'] = 'http://localhost:80/users';15 newRequest['data'] = {16 'user': {17 'username': username,18 'email': email,19 'password': password20 }21 };22 newRequest['success'] = function(response){23 console.log(response);24 return callback();25 };26 $.ajax(newRequest);27 };28 //------------------ Signing In -----------------------29 function signInUser(username, password, callback) {30 var newRequest = new Request();31 newRequest['type'] = 'POST';32 newRequest['url'] = 'http://localhost:80/sessions';33 newRequest['xhrFields'] = { 'withCredentials': true };34 newRequest['data'] = {35 'user': {36 'username': username,37 'password': password38 }39 };40 newRequest['success'] = function(response){41 console.log(response);42 return callback();43 };44 $.ajax(newRequest);45 };46 //------------------- Logging Out ---------------------47 function logoutUser(callback) {48 var newRequest = new Request();49 newRequest['type'] = 'DELETE';50 newRequest['url'] = 'http://localhost:80/sessions';51 newRequest['xhrFields'] = { 'withCredentials': true };52 newRequest['success'] = function(response){53 console.log(response);54 return callback();55 };56 $.ajax(newRequest);57 }58 //------------------ Authenticate ---------------------59 function authenticate(callback) {60 var newRequest = new Request();61 newRequest['type'] = 'GET';62 newRequest['url'] = 'http://localhost:80/authenticated';63 newRequest['xhrFields'] = { 'withCredentials': true };64 newRequest['success'] = function(response){65 console.log(response);66 return callback(response);67 };68 $.ajax(newRequest);69 };70 //---------------------- Tweets -----------------------71 //------------------- Post a Tweet --------------------72 function postTweet(msg, callback) {73 var newRequest = new Request();74 newRequest['type'] = 'POST';75 newRequest['url'] = 'http://localhost:80/tweets';76 newRequest['xhrFields'] = { 'withCredentials': true };77 newRequest['data'] = {78 'tweet': {79 'message': msg80 }81 };82 newRequest['success'] = function(response){83 console.log(response);84 return callback({'success': true});85 };86 $.ajax(newRequest);87 };88 //------------------- Get all Tweets ------------------89 function getAllTweets(callback) {90 var newRequest = new Request();91 newRequest['type'] = 'GET';92 newRequest['url'] = 'http://localhost:80/tweets';93 newRequest['success'] = function(response){94 return callback(response);95 };96 $.ajax(newRequest);97 };98 //----------------- Get tweet by ID --------------------99 function getOneTweet(id) {100 var newRequest = new Request();101 newRequest['type'] = 'GET';102 newRequest['url'] = 'http://localhost:80/tweets/' + id;103 newRequest['success'] = function(response){104 console.log(response);105 };106 $.ajax(newRequest);107 };108 //------------- Get All Tweets by Username -------------109 function getUserTweets(username, callback) {110 var newRequest = new Request();111 newRequest['type'] = 'GET';112 newRequest['url'] = 'http://localhost:80/users/' + username + '/tweets';113 newRequest['success'] = function(response){114 console.log(response);115 return callback(response);116 };117 $.ajax(newRequest);118 };119 //---------------- Delete a tweet by ID ----------------120 function deleteOneTweet(id, callback) {121 var newRequest = new Request();122 newRequest['type'] = 'DELETE';123 newRequest['url'] = 'http://localhost:80/tweets/' + id;124 newRequest['xhrFields'] = { 'withCredentials': true };125 newRequest['success'] = function(response){126 console.log(response);127 return callback();128 };129 $.ajax(newRequest);130 }; 131 //--------------- Search Tweet by Keyword --------------132 function searchTweets(keyword, callback) {133 var newRequest = new Request();134 newRequest['type'] = "GET";135 newRequest['url'] = "http://localhost:80/tweets/search/"+keyword; 136 newRequest["success"] = function(response){137 console.log(response);138 return callback(response);139 };140 $.ajax(newRequest);141 };...
service-worker.js
Source:service-worker.js
1const APP_PREFIX = 'budget-'; 2const VERSION = 'version_01'; 3const CACHE_NAME = APP_PREFIX + VERSION4const FILES_TO_CACHE = [5 "./index.html",6 "./manifest.json",7 "./css/styles.css",8 "./js/index.js",9 "./js/idb.js",10 "./icons/icon-72x72.png",11 "./icons/icon-96x96.png",12 "./icons/icon-128x128.png",13 "./icons/icon-144x144.png",14 "./icons/icon-152x152.png",15 "./icons/icon-192x192.png",16 "./icons/icon-384x384.png",17 "./icons/icon-512x512.png"18];19// Respond with cached resources20self.addEventListener('fetch', function (e) {21 if (e.request.url=="http://localhost:3001/"){22 const init = { 23 method: 'GET',24 mode: 'no-cors',25 headers: new Headers({26 'Content-Type': 'application/x-www-form-urlencoded'27 })28 };29 const url = new URL("http://localhost:3001/index.html")30 const newRequest = new Request(31 url.toString(),32 new Request(e.request, init),33 )34 console.log('fetch request : ' + newRequest.url)35 console.log(caches);36 e.respondWith(37 caches.match(newRequest).then(function (newRequest) {38 if (newRequest) { // if cache is available, respond with cache39 console.log('responding with cache : ' + newRequest.url)40 return newRequest41 } else { // if there are no cache, try fetching request42 console.log('file is not cached, fetching : ' + newRequest.url)43 return fetch(newRequest)44 }45 46 // You can omit if/else for console.log & put one line below like this too.47 // return request || fetch(e.request)48 })49 )50 }51 else if (e.request.url=="https://powerful-peak-64523.herokuapp.com/"){52 const init = { 53 method: 'GET',54 mode: 'no-cors',55 headers: new Headers({56 'Content-Type': 'application/x-www-form-urlencoded'57 })58 };59 const url = new URL("https://powerful-peak-64523.herokuapp.com/index.html")60 const newRequest = new Request(61 url.toString(),62 new Request(e.request, init),63 )64 console.log('fetch request : ' + newRequest.url)65 console.log(caches);66 e.respondWith(67 caches.match(newRequest).then(function (newRequest) {68 if (newRequest) { // if cache is available, respond with cache69 console.log('responding with cache : ' + newRequest.url)70 return newRequest71 } else { // if there are no cache, try fetching request72 console.log('file is not cached, fetching : ' + newRequest.url)73 return fetch(newRequest)74 }75 76 // You can omit if/else for console.log & put one line below like this too.77 // return request || fetch(e.request)78 })79 )80 }81 else {82 console.log('fetch request : ' + e.request.url)83 e.respondWith(84 caches.match(e.request).then(function (request) {85 if (request) { // if cache is available, respond with cache86 console.log('responding with cache : ' + e.request.url)87 return request88 } else { // if there are no cache, try fetching request89 console.log('file is not cached, fetching : ' + e.request.url)90 return fetch(e.request)91 }92 // You can omit if/else for console.log & put one line below like this too.93 // return request || fetch(e.request)94 })95 )96 }97})98// Cache resources99self.addEventListener('install', function (e) {100 e.waitUntil(101 caches.open(CACHE_NAME).then(function (cache) {102 console.log('installing cache : ' + CACHE_NAME)103 return cache.addAll(FILES_TO_CACHE)104 })105 )106})107// Delete outdated caches108self.addEventListener('activate', function (e) {109 e.waitUntil(110 caches.keys().then(function (keyList) {111 // `keyList` contains all cache names under your username.github.io112 // filter out ones that has this app prefix to create keeplist113 let cacheKeeplist = keyList.filter(function (key) {114 return key.indexOf(APP_PREFIX);115 })116 // add current cache name to keeplist117 cacheKeeplist.push(CACHE_NAME);118 return Promise.all(keyList.map(function (key, i) {119 if (cacheKeeplist.indexOf(key) === -1) {120 console.log('deleting cache : ' + keyList[i] );121 return caches.delete(keyList[i]);122 }123 }));124 })125 );...
lambda.js
Source:lambda.js
1const environment = JSON.parse(require('fs').readFileSync("environment.json"));2function mapHeaders(from, to) {3 from = from || {};4 to = to || {};5 for (var key in from) {6 to[key.toLowerCase()] = [{7 key: key,8 value: from[key]9 }];10 }11 return to;12}13exports.handler = (event, context, callback) => {14 const request = event.Records[0].cf.request;15 const headers = {};16 for (var key in request.headers) {17 request.headers[key].forEach(function (kv) {18 headers[kv.key] = kv.value;19 });20 }21 requestResponse(environment, {22 clientIp: request.clientIp,23 method: request.method,24 queryString: request.querystring,25 uri: request.uri,26 host: headers.Host,27 headers: headers28 }, function (response, newRequest) {29 if (newRequest) {30 request.clientIp = 'clientIp' in newRequest ? newRequest.clientIp : request.clientIp;31 request.method = 'method' in newRequest ? newRequest.method : request.method;32 request.queryString = 'queryString' in newRequest ? newRequest.queryString : request.queryString;33 request.uri = 'uri' in newRequest ? newRequest.uri : request.uri;34 if (!request.uri || request.uri[0] !== "/")35 request.uri = "/" + request.uri;36 mapHeaders(newRequest.headers, request.headers);37 callback(null, request);38 } else39 callback(null, {40 status: response.status,41 headers: mapHeaders(response.headers)42 });43 });...
Using AI Code Generation
1const { newRequest } = require('@playwright/test');2request.method = 'POST';3request.headers = { 'Content-Type': 'application/json' };4request.postData = JSON.stringify({ foo: 'bar' });5const response = await request.send();6console.log(`response status: ${response.status()}`);7console.log(`response body: ${await response.body()}`);8const { test } = require('@playwright/test');9test('test', async ({ page }) => {10 request.method = 'POST';11 request.headers = { 'Content-Type': 'application/json' };12 request.postData = JSON.stringify({ foo: 'bar' });13 const response = await request.send();14 console.log(`response status: ${response.status()}`);15 console.log(`response body: ${await response.body()}`);16});17const { test } = require('@playwright/test');18test('test', async ({ page }) => {19 request.method = 'POST';20 request.headers = { 'Content-Type': 'application/json' };21 request.postData = JSON.stringify({ foo: 'bar' });22 const response = await page.route('**/*', (route, request) => {23 route.resume();24 });25 console.log(`response status: ${response.status()}`);26 console.log(`response body: ${await response.body()}`);27});28Error: Protocol error (Network.requestWillBeSent): Cannot intercept URL that is not a document29 at ProgressController.run (/home/runner/work/playwright-test/playwright-test/node_modules/playwright-core/lib/client/progress.js:29:20)
Using AI Code Generation
1const { newRequest } = require('@playwright/test');2const response = await request.send();3console.log(response);4const { newPage } = require('@playwright/test');5const page = await newPage();6await page.screenshot({ path: 'example.png' });7await page.close();8const { test, expect } = require('@playwright/test');9test('google', async ({ page }) => {10 const title = page.locator('title');11 await expect(title).toHaveText('Google');12});13const { test } = require('@playwright/test');14test('google', async ({ page }) => {15 const title = page.locator('title');16 await expect(title).toHaveText('Google');17});18import { PlaywrightTestConfig } from '@playwright/test';19const config: PlaywrightTestConfig = {20 use: {21 viewport: { width: 1280, height: 720 },22 },23};24export default config;25import { PlaywrightTestConfig } from '@playwright/test';26const config: PlaywrightTestConfig = {27 use: {28 viewport: { width: 1280, height: 720 },29 },30};31export default config;32import { PlaywrightTestConfig } from '@playwright/test';33const config: PlaywrightTestConfig = {34 use: {35 viewport: { width: 1280, height: 720 },36 },37};38export default config;
Using AI Code Generation
1const { newRequest } = require('playwright/lib/server/network');2const request = newRequest({3 headers: {},4});5const { newRequest } = require('playwright/lib/server/network');6const request = newRequest({7 headers: {},8});9const routeHandler = (route, request) => {10 route.fulfill({ body: 'Hello World!' });11};12const { newRequest } = require('playwright/lib/server/network');13const request = newRequest({14 headers: {},15});16 route.fulfill({ body: 'Hello World!' });17});
Using AI Code Generation
1const { newRequest } = require("playwright/lib/transport/transport");2const { chromium } = require("playwright");3const fs = require("fs");4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 const request = newRequest("Network.enable", {});9 await page._delegate._connection.send(request);10 const response = await page._delegate._connection.waitForResponse(request);11 const responseBody = await response.body();12 fs.writeFileSync("test.json", responseBody);13 await browser.close();14})();
Using AI Code Generation
1const { newRequest } = require('@playwright/test');2request.method = 'POST';3request.postData = 'Hello World';4request.headers = { 'Content-Type': 'text/plain' };5const response = await request.send();6console.log(response.status());7console.log(await response.text());
Using AI Code Generation
1const { newRequest } = require('@playwright/test/lib/server/network');2const { toImpl } = require('@playwright/test/lib/server/injected/injectedScript');3const { helper } = require('@playwright/test/lib/server/helper');4const { assert } = require('@playwright/test/lib/server/helper');5(async () => {6 const page = await browser.newPage();7 await page.route('**', route => {8 console.log(route.request().url());9 const newReq = newRequest({10 });11 route.fulfill(newReq);12 });13})();14const { helper } = require('../helper');15const { assert } = require('../helper');16const { toImpl } = require('../injected/injectedScript');17const { Request, Response } = require('./networkTypes');18const { ProgressController } = require('./progress');19const { Headers } = require('./fetch/fetchTypes');20class Route {21 constructor(channel, routeHandler) {22 this._channel = channel;23 this._handler = routeHandler;24 this._handler = routeHandler;25 this._fired = false;26 channel.routeContinue = (params, metadata) => {27 if (this._fired)28 return;29 this._fired = true;30 this._handlerContinue(metadata);31 };32 channel.routeFulfill = (params, metadata) => {33 if (this._fired)34 return;35 this._fired = true;36 this._handlerFulfill(params, metadata);37 };38 channel.routeAbort = (params, metadata) => {39 if (this._fired)40 return;41 this._fired = true;42 this._handlerAbort(params, metadata);43 };44 }45 request() {46 return this._request;47 }48 async abort(errorCode = 'failed') {49 assert(this._handler, 'Route.abort: route is not intercepted');50 const errorReason = errorCodeToErrorReason(errorCode);51 assert(errorReason, 'Route.abort: unknown error code: ' + errorCode);52 await this._channel.abort({ errorReason });53 }
Using AI Code Generation
1const { newRequest } = require('@playwright/test');2console.log(request.url());3const { test, expect } = require('@playwright/test');4test('should use newRequest method of Playwright Internal API', async ({ page }) => {5 const response = await request.send();6 expect(response.status()).toBe(200);7});8const { test, expect } = require('@playwright/test');9test('should use newRequest method of Playwright Internal API', async ({ page }) => {10 const response = await request.send();11 expect(response.status()).toBe(200);12});13const { test, expect } = require('@playwright/test');14test('should use newRequest method of Playwright Internal API', async ({ page }) => {15 const response = await request.send();16 expect(response.status()).toBe(200);17});18const { test, expect } = require('@playwright/test');19test('should use newRequest method of Playwright Internal API', async ({ page }) => {20 const response = await request.send();21 expect(response.status()).toBe(200);22});23const { test, expect } = require('@playwright/test');24test('should use newRequest method of Playwright Internal API', async ({ page }) => {25 const response = await request.send();26 expect(response.status()).toBe(200);27});28const { test, expect } = require('@playwright/test');29test('should
Using AI Code Generation
1const {newRequest} = require('@playwright/test/lib/api/httpRequest');2const {newResponse} = require('@playwright/test/lib/api/httpResponse');3const {newPage} = require('@playwright/test/lib/api/page');4const page = newPage();5const {newBrowser} = require('@playwright/test/lib/api/browser');6const browser = newBrowser();7const {newContext} = require('@playwright/test/lib/api/browserContext');8const context = newContext();9const {newBrowserType} = require('@playwright/test/lib/api/browserType');10const browserType = newBrowserType();11const {newPlaywright} = require('@playwright/test/lib/api/playwright');12const playwright = newPlaywright();13const {newServer} = require('@playwright/test/lib/api/server');14const server = newServer();15const {newWorker} = require('@playwright/test/lib/api/worker');16const worker = newWorker();17const {newWorkerFixture} = require('@playwright/test/lib/api/workerFixture');18const workerFixture = newWorkerFixture();19const {newTestType} = require('@playwright/test/lib/api/testType');20const testType = newTestType();21const {newTestInfo} = require('@playwright/test/lib/api/testInfo');22const testInfo = newTestInfo();23const {newTestFixtures} = require('@playwright/test/lib/api/testFixtures');24const testFixtures = newTestFixtures();25const {newTest
Using AI Code Generation
1const { newRequest } = require('playwright/lib/server/network');2const { context } = require('playwright/lib/server/chromium');3const { chromium } = require('playwright');4const { request } = require('http');5(async () => {6 const browser = await chromium.launch({7 });8 const page = await browser.newPage();9 const request = newRequest({10 headers: {11 },12 postData: JSON.stringify({13 }),14 });15 const response = await page.route(request, route => route.continue());16 console.log(response);17 await page.screenshot({ path: 'example.png' });18 await browser.close();19})();20 return this._request;21 }22 async abort(errorCode = 'failed') {23 assert(this._handler, 'Route.abort: route is not intercepted');24 const errorReason = errorCodeToErrorReason(errorCode);25 assert(errorReason, 'Route.abort: unknown error code: ' + errorCode);26 await this._channel.abort({ errorReason });27 }
Using AI Code Generation
1const { newRequest } = require('@playwright/test');2const response = await request.send();3console.log(response.seatuswPag4[Apache 2.0](LICENSE)e();5 const request = newRequest("Network.enable", {});6 await page._delegate._connection.send(request);7 const response = await page._delegate._connection.waitForResponse(request);8 const responseBody = await response.body();9 fs.writeFileSync("test.json", responseBody);10 await browser.close();11})();
Using AI Code Generation
1const { newRequest } = require('@playwright/test');2request.method = 'POST';3request.postData = 'Hello World';4request.headers = { 'Content-Type': 'text/plain' };5const response = await request.send();6console.log(response.status());7console.log(await response.text());
Using AI Code Generation
1const { newRequest } = require('@playwright/test/lib/server/network');2const { toImpl } = require('@playwright/test/lib/server/injected/injectedScript');3const { helper } = require('@playwright/test/lib/server/helper');4const { assert } = require('@playwright/test/lib/server/helper');5(async () => {6 const page = await browser.newPage();7 await page.route('**', route => {8 console.log(route.request().url());9 const newReq = newRequest({10 });11 route.fulfill(newReq);12 });13})();14const { helper } = require('../helper');15const { assert } = require('../helper');16const { toImpl } = require('../injected/injectedScript');17const { Request, Response } = require('./networkTypes');18const { ProgressController } = require('./progress');19const { Headers } = require('./fetch/fetchTypes');20class Route {21 constructor(channel, routeHandler) {22 this._channel = channel;23 this._handler = routeHandler;24 this._handler = routeHandler;25 this._fired = false;26 channel.routeContinue = (params, metadata) => {27 if (this._fired)28 return;29 this._fired = true;30 this._handlerContinue(metadata);31 };32 channel.routeFulfill = (params, metadata) => {33 if (this._fired)34 return;35 this._fired = true;36 this._handlerFulfill(params, metadata);37 };38 channel.routeAbort = (params, metadata) => {39 if (this._fired)40 return;41 this._fired = true;42 this._handlerAbort(params, metadata);43 };44 }45 request() {46 return this._request;47 }48 async abort(errorCode = 'failed') {49 assert(this._handler, 'Route.abort: route is not intercepted');50 const errorReason = errorCodeToErrorReason(errorCode);51 assert(errorReason, 'Route.abort: unknown error code: ' + errorCode);52 await this._channel.abort({ errorReason });53 }
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!