Skip to content

Commit

Permalink
fix(shopware5): adjust to latest interface version
Browse files Browse the repository at this point in the history
  • Loading branch information
jembach committed Aug 10, 2022
1 parent 5034244 commit ef08c53
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 24 deletions.
16 changes: 12 additions & 4 deletions packages/storefront-shop-adapter-shopware5/src/providers/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class StorefrontShopAdapterShopware5Cart

return { data: { items }, raw: { getCart: response }, error: undefined }
} catch (e) {
return { data: undefined, error: e as Error }
return { data: undefined, raw: { getCart: undefined }, error: e as Error }
}
}

Expand Down Expand Up @@ -118,7 +118,7 @@ export class StorefrontShopAdapterShopware5Cart

return { data, raw, error: undefined }
} catch (e) {
return { data: undefined, error: e as Error }
return { data: undefined, raw: { addItem: undefined }, error: e as Error }
}
}

Expand Down Expand Up @@ -166,7 +166,11 @@ export class StorefrontShopAdapterShopware5Cart

return { data, raw, error: undefined }
} catch (e) {
return { data: undefined, error: e as Error }
return {
data: undefined,
raw: { removeItem: undefined },
error: e as Error,
}
}
}

Expand Down Expand Up @@ -217,7 +221,11 @@ export class StorefrontShopAdapterShopware5Cart

return { data, raw, error: undefined }
} catch (e) {
return { data: undefined, error: e as Error }
return {
data: undefined,
raw: { updateItem: undefined },
error: e as Error,
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ export class StorefrontShopAdapterShopware5Checkout
constructor(private mainAdapter: StorefrontShopAdapterShopware5) {}

getCheckout: MakairaGetCheckout<unknown, undefined, Error> = async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}

submit: MakairaSubmitCheckout<unknown, undefined, Error> = async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}
}
12 changes: 10 additions & 2 deletions packages/storefront-shop-adapter-shopware5/src/providers/review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export class StorefrontShopAdapterShopware5Review
error: undefined,
}
} catch (e) {
return { data: undefined, error: e as Error }
return {
data: undefined,
raw: { getReviews: undefined },
error: e as Error,
}
}
}

Expand Down Expand Up @@ -113,7 +117,11 @@ export class StorefrontShopAdapterShopware5Review

return { data, raw, error: undefined }
} catch (e) {
return { data: undefined, error: e as Error }
return {
data: undefined,
raw: { createReview: undefined },
error: e as Error,
}
}
}
}
13 changes: 9 additions & 4 deletions packages/storefront-shop-adapter-shopware5/src/providers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ export class StorefrontShopAdapterShopware5User

return { data: undefined, raw, error: errorGetUser }
} catch (e) {
return { data: undefined, error: e as Error }
return {
data: undefined,
raw: { getUser: undefined, login: undefined },
error: e as Error,
}
}
}

Expand Down Expand Up @@ -116,13 +120,14 @@ export class StorefrontShopAdapterShopware5User
} catch (e) {
return {
data: undefined,
raw: { logout: undefined },
error: e as Error,
}
}
}

signup: MakairaSignup<unknown, undefined, Error> = async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}

getUser: MakairaGetUser<unknown, ShopwareGetUserRaw, Error> = async () => {
Expand Down Expand Up @@ -165,12 +170,12 @@ export class StorefrontShopAdapterShopware5User
error: undefined,
}
} catch (e) {
return { data: undefined, error: e as Error }
return { data: undefined, raw: { getUser: undefined }, error: e as Error }
}
}

forgotPassword: MakairaForgotPassword<unknown, undefined, Error> =
async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export class StorefrontShopAdapterShopware5Wishlist
constructor(private mainAdapter: StorefrontShopAdapterShopware5) {}

getWishlist: MakairaGetWishlist<unknown, undefined, Error> = async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}

addItem: MakairaAddItemToWishlist<unknown, undefined, Error> = async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}

removeItem: MakairaRemoveItemFromWishlist<unknown, undefined, Error> =
async () => {
return { error: new NotImplementedError() }
return { error: new NotImplementedError(), raw: undefined }
}
}
18 changes: 9 additions & 9 deletions packages/storefront-shop-adapter-shopware5/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type ShopwareReview = {

export type ShopwareGetCartRes = ShopwareProduct[]

export type ShopwareGetCartRaw = { getCart: ShopwareGetCartRes }
export type ShopwareGetCartRaw = { getCart?: ShopwareGetCartRes }

//#endregion

Expand All @@ -41,7 +41,7 @@ export type ShopwareAddItemRes =
| { ok: false; message: string }

export type ShopwareAddItemRaw = {
addItem: ShopwareAddItemRes
addItem?: ShopwareAddItemRes
}

//#endregion
Expand All @@ -53,7 +53,7 @@ export type ShopwareRemoveItemRes =
| { ok: false; message: string }

export type ShopwareRemoveItemRaw = {
removeItem: ShopwareRemoveItemRes
removeItem?: ShopwareRemoveItemRes
}

//#endregion
Expand All @@ -65,7 +65,7 @@ export type ShopwareUpdateItemRes =
| { ok: false; message: string }

export type ShopwareUpdateItemRaw = {
updateItem: ShopwareUpdateItemRes
updateItem?: ShopwareUpdateItemRes
}

//#endregion
Expand All @@ -80,7 +80,7 @@ export type ShopwareGetUserRes =
| ShopwareUser
| { ok: false; message?: 'Forbidden' | string }

export type ShopwareGetUserRaw = { getUser: ShopwareGetUserRes }
export type ShopwareGetUserRaw = { getUser?: ShopwareGetUserRes }

//#endregion

Expand All @@ -89,7 +89,7 @@ export type ShopwareGetUserRaw = { getUser: ShopwareGetUserRes }
export type ShopwareLogoutRes = { ok: true }

export type ShopwareLogoutRaw = {
logout: ShopwareLoginRes
logout?: ShopwareLoginRes
}

//#endregion
Expand All @@ -102,7 +102,7 @@ export type ShopwareLoginRes =
| { ok: false; errors: any }

export type ShopwareLoginRaw = {
login: ShopwareLoginRes
login?: ShopwareLoginRes
getUser?: ShopwareGetUserRaw['getUser']
}

Expand All @@ -120,7 +120,7 @@ export type ShopwareGetReviewsRes =
| ShopwareReview[]
| { ok: false; message: string }

export type ShopwareGetReviewsRaw = { getReviews: ShopwareGetReviewsRes }
export type ShopwareGetReviewsRaw = { getReviews?: ShopwareGetReviewsRes }

//#endregion

Expand All @@ -137,7 +137,7 @@ export type ShopwareCreateReviewRes =
| { ok: false; message: string }

export type ShopwareCreateReviewRaw = {
createReview: ShopwareCreateReviewRes
createReview?: ShopwareCreateReviewRes
}

//#endregion
Expand Down

0 comments on commit ef08c53

Please sign in to comment.