コード例 #1
0
 public RoutesController(IIOServiceContext context, IHttpContextAccessor httpContextAccessor, IHttpClientFactory clientFactory, IGoogleSheetsService googleSheetsService, IVtexApiService vtexApiService, ISheetsCatalogImportRepository SheetsCatalogImportRepository)
 {
     this._context                       = context ?? throw new ArgumentNullException(nameof(context));
     this._httpContextAccessor           = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
     this._clientFactory                 = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
     this._googleSheetsService           = googleSheetsService ?? throw new ArgumentNullException(nameof(googleSheetsService));
     this._vtexApiService                = vtexApiService ?? throw new ArgumentNullException(nameof(vtexApiService));
     this._sheetsCatalogImportRepository = SheetsCatalogImportRepository ?? throw new ArgumentNullException(nameof(SheetsCatalogImportRepository));
 }
コード例 #2
0
ファイル: Mutation.cs プロジェクト: vtex-apps/google-import
        public Mutation(IGoogleSheetsService googleSheetsService, ISheetsCatalogImportRepository sheetsCatalogImportRepository, IVtexApiService vtexApiService)
        {
            Name = "Mutation";

            Field <BooleanGraphType>(
                "revokeToken",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "accountName", Description = "Account Name"
            }
                    ),
                resolve: context =>
            {
                bool revoked = googleSheetsService.RevokeGoogleAuthorizationToken().Result;
                if (revoked)
                {
                    string accountName = context.GetArgument <string>("accountName");
                    sheetsCatalogImportRepository.SaveFolderIds(null, accountName);
                }

                return(revoked);
            });

            Field <StringGraphType>(
                "googleAuthorize",
                resolve: context =>
            {
                return(googleSheetsService.GetAuthUrl());
            });

            Field <StringGraphType>(
                "createSheet",
                resolve: context =>
            {
                var created = googleSheetsService.CreateSheet();
                vtexApiService.SetBrandList();
                return(created);
            });

            Field <StringGraphType>(
                "processSheet",
                resolve: context =>
            {
                return(vtexApiService.ProcessSheet());
            });

            Field <StringGraphType>(
                "clearSheet",
                resolve: context =>
            {
                var cleared         = vtexApiService.ClearSheet();
                var catalogAndBrand = vtexApiService.SetBrandList();
                return(!string.IsNullOrWhiteSpace(cleared.Result) && catalogAndBrand.Result);
            });

            Field <StringGraphType>(
                "addImages",
                resolve: context =>
            {
                return(vtexApiService.AddImagesToSheet());
            });

            Field <StringGraphType>(
                "exportProducts",
                arguments: new QueryArguments(
                    new QueryArgument <StringGraphType> {
                Name = "exportQuery", Description = "Export Query"
            }
                    ),
                resolve: context =>
            {
                string query = context.GetArgument <string>("exportQuery");
                return(vtexApiService.ExportToSheet(query));
            });
        }