diff --git a/src/modules/app/AppRepositoryGql.ts b/src/modules/app/AppRepositoryGql.ts index 07f7608..deb5272 100644 --- a/src/modules/app/AppRepositoryGql.ts +++ b/src/modules/app/AppRepositoryGql.ts @@ -10,4 +10,12 @@ export class AppRepositoryGql { return app } + + static async getBySlug(slug: string, fields?: AppFields[]): Promise { + const appQuery = new AppQueries(fields) + const getAppQuery: string = appQuery.getApp() + const { app }: AppResponse = await getClient().query(getAppQuery, { filter: { slug: slug } }) + + return app + } } diff --git a/src/modules/app/AppRepositoryJson.ts b/src/modules/app/AppRepositoryJson.ts index 8e1b213..32b9fc3 100644 --- a/src/modules/app/AppRepositoryJson.ts +++ b/src/modules/app/AppRepositoryJson.ts @@ -18,4 +18,22 @@ export class AppRepositoryJson { return mock } + + static async getBySlug(slug: string, fields?: AppFields[]) { + const mock = shop_ctx.mock?.apps || {} + + if (slug != mock.slug) { + throw new Error('apps_not_found') + } + + const isFieldNotSelected = entry => !fields.includes(entry) + + const deleteFieldIfNecessary = entry => { + isFieldNotSelected(entry) && delete mock[entry] + } + + fields && Object.keys(mock).forEach(deleteFieldIfNecessary) + + return mock + } } diff --git a/src/modules/app/AppService.ts b/src/modules/app/AppService.ts index a2314c2..583efec 100644 --- a/src/modules/app/AppService.ts +++ b/src/modules/app/AppService.ts @@ -16,4 +16,15 @@ export class AppService { throw new Error(error?.message) } } + + static async getBySlug(slug: string, fields?: AppFields[]): Promise { + try { + const result = await Repository().getBySlug(slug, fields) + BroadcastService.emit('Apps', result) + + return result + } catch (error) { + throw new Error(error?.message) + } + } } diff --git a/src/modules/buy-together/BuyTogetherQueries.ts b/src/modules/buy-together/BuyTogetherQueries.ts index fffe59a..881615c 100644 --- a/src/modules/buy-together/BuyTogetherQueries.ts +++ b/src/modules/buy-together/BuyTogetherQueries.ts @@ -72,6 +72,7 @@ export class BuyTogetherQueries { markup isDefault installment ${installmentFields} + installments ${installmentFields} }` const featureFields = ` { diff --git a/src/modules/buy-together/BuyTogetherTypes.ts b/src/modules/buy-together/BuyTogetherTypes.ts index c18a957..ef3f550 100644 --- a/src/modules/buy-together/BuyTogetherTypes.ts +++ b/src/modules/buy-together/BuyTogetherTypes.ts @@ -33,7 +33,7 @@ export interface PaymentInstallment { discount: number interest: number total: string - parcel_price: string + parcelPrice: string } export interface Payment {