feat(medusa,brightpearl,segment,webshipper): claims (#163)
* chore: create tests * chore: models * fix: passing initial tests * test: adds integration test * test: clean up integration implementation * fix: claims * fix: brightpearl + webshipper * tests: passing * fix: update claim items * fix: adds gitignore * fix: pr comments * fix: single migration * fix(medusa-plugin-segment): adds item claimed event to segment
This commit is contained in:
@@ -4,7 +4,7 @@ import Webshipper from "../utils/webshipper"
|
||||
class WebshipperFulfillmentService extends FulfillmentService {
|
||||
static identifier = "webshipper"
|
||||
|
||||
constructor({ logger, swapService, orderService }, options) {
|
||||
constructor({ logger, claimService, swapService, orderService }, options) {
|
||||
super()
|
||||
|
||||
this.options_ = options
|
||||
@@ -18,6 +18,9 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
||||
/** @private @const {SwapService} */
|
||||
this.swapService_ = swapService
|
||||
|
||||
/** @private @const {SwapService} */
|
||||
this.claimService_ = claimService
|
||||
|
||||
/** @private @const {AxiosClient} */
|
||||
this.client_ = new Webshipper({
|
||||
account: this.options_.account,
|
||||
@@ -82,19 +85,20 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
||||
* return lines.
|
||||
*/
|
||||
async createReturn(returnOrder) {
|
||||
let fromOrder
|
||||
let orderId
|
||||
if (returnOrder.order_id) {
|
||||
fromOrder = await this.orderService_.retrieve(returnOrder.order_id, {
|
||||
select: ["total"],
|
||||
relations: ["shipping_address", "returns"],
|
||||
})
|
||||
orderId = returnOrder.order_id
|
||||
} else if (returnOrder.swap) {
|
||||
fromOrder = await this.orderService_.retrieve(returnOrder.swap.order_id, {
|
||||
select: ["total"],
|
||||
relations: ["shipping_address", "returns"],
|
||||
})
|
||||
orderId = returnOrder.swap.order_id
|
||||
} else if (returnOrder.claim_order) {
|
||||
orderId = returnOrder.claim_order.order_id
|
||||
}
|
||||
|
||||
const fromOrder = await this.orderService_.retrieve(orderId, {
|
||||
select: ["total"],
|
||||
relations: ["discounts", "shipping_address", "returns"],
|
||||
})
|
||||
|
||||
const methodData = returnOrder.shipping_method.data
|
||||
|
||||
const relationships = {
|
||||
@@ -384,6 +388,12 @@ class WebshipperFulfillmentService extends FulfillmentService {
|
||||
trackingNumbers
|
||||
)
|
||||
}
|
||||
} else if (orderId.charAt(0).toLowerCase() === "c") {
|
||||
return this.claimService_.createShipment(
|
||||
orderId,
|
||||
fulfillmentIndex,
|
||||
trackingNumbers
|
||||
)
|
||||
} else {
|
||||
if (fulfillmentIndex.startsWith("ful")) {
|
||||
return this.orderService_.createShipment(
|
||||
|
||||
Reference in New Issue
Block a user