Esempio n. 1
0
        public GoogleTableRequest(string tableId, string range, MajorDimension majorDimension, string apiKey)
        {
            this.tableId        = tableId;
            this.range          = range;
            this.majorDimension = majorDimension;

            path = string.Format(NetworkConstants.GOOGLE_TABLE_REQUEST_FORMAT, tableId, range, majorDimension, apiKey);
        }
 public GoogleSpreadsheetConnection(
     SheetsService service,
     string spreadsheetId,
     MajorDimension dimension = MajorDimension.ROWS)
 {
     // Create Google Sheets API service.
     _service       = service;
     _spreadsheetId = spreadsheetId;
     _dimension     = dimension;
 }
 public SheetData(string sheetId, string spreadsheetId, MajorDimension dimension)
 {
     _dimension = dimension;
     _table     = new DataTable(sheetId, spreadsheetId);
 }
 /// <summary>
 /// Initializes a new instance of the Xunit.Google.Sheets.GoogleSheetDataAttribute class.
 /// </summary>
 /// <param name="apiKey">The Google developer API key. Eg. 'AIzaFyB8Tf54Xd1AQaUkVz0a5DLPq1pClEHpJvZ'. See https://developers.google.com/sheets/api/guides/authorizing#APIKey .</param>
 /// <param name="spreadsheetId">The id of the spreadsheet. Eg '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms'.</param>
 /// <param name="ranges">Multiple range of cells to get data from. Eg [ 'Class Data!A2:E', 'Class Data!A42:E' ]</param>
 /// <param name="majorDimension">The major dimension that results should use.</param>
 /// <param name="valueRenderOption">How values should be represented in the output.</param>
 /// <param name="dateTimeRenderOption">How dates, times, and durations should be represented in the output. This is ignored if valueRenderOption is FORMATTED_VALUE.</param>
 public GoogleSheetDataAttribute(string apiKey, string spreadsheetId, IEnumerable <string> ranges, MajorDimension majorDimension = MajorDimension.DIMENSIONUNSPECIFIED, ValueRenderOption valueRenderOption = ValueRenderOption.FORMATTEDVALUE, DateTimeRenderOption dateTimeRenderOption = DateTimeRenderOption.SERIALNUMBER)
 {
     _data = new Lazy <IEnumerable <object[]> >(() =>
     {
         using (var service = new SheetsService(new BaseClientService.Initializer
         {
             ApiKey = apiKey,
             ApplicationName = "Xunit.Google.Sheets",
         }))
         {
             var request                  = service.Spreadsheets.Values.BatchGet(spreadsheetId);
             request.MajorDimension       = (SpreadsheetsResource.ValuesResource.BatchGetRequest.MajorDimensionEnum?)majorDimension;
             request.ValueRenderOption    = (SpreadsheetsResource.ValuesResource.BatchGetRequest.ValueRenderOptionEnum?)valueRenderOption;
             request.DateTimeRenderOption = (SpreadsheetsResource.ValuesResource.BatchGetRequest.DateTimeRenderOptionEnum?)dateTimeRenderOption;
             request.Ranges               = new Repeatable <string>(ranges);
             var response                 = request.Execute();
             return(response.ValueRanges.SelectMany(valueRange => valueRange.Values.Select(value => value.ToArray())));
         }
     });
 }