Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ballerina
gsheets4
.gitignore
.travis.yml
Ballerina.toml
LICENSE
README.md
issue_template.md
pull_request_template.md

README.md

Build Status

Ballerina Google Spreadsheet Endpoint

Google Sheets is an online spreadsheet that lets users create and format spreadsheets and simultaneously work with other people. The Google Spreadsheet endpoint allows you to access the Google Spreadsheet API Version v4 through Ballerina.

The following sections provide you with information on how to use the Ballerina Google Spreadsheet endpoint.

Compatibility

Ballerina Language Version Google Spreadsheet API Version
0.991.0 V4
Prerequisites

Download the ballerina distribution.

Contribute To Develop

Clone the repository by running the following command git clone https://github.com/wso2-ballerina/module-googlespreadsheet.git

Working with GSheets Endpoint actions

All the actions return valid response or error. If the action is a success, then the requested resource will be returned. Else error will be returned.

In order for you to use the GSheets Endpoint, first you need to create a GSheets Client endpoint.

import wso2/gsheets4;

gsheets4:SpreadsheetConfiguration spreadsheetConfig = {
    clientConfig: {
        auth: {
            scheme: http:OAUTH2,
            config: {
                grantType: http:DIRECT_TOKEN,
                config: {
                    accessToken: "<accessToken>",
                    refreshConfig: {
                        clientId: "<clientId>",
                        clientSecret: "<clientSecret>",
                        refreshToken: "<refreshToken>",
                        refreshUrl: gsheets4:REFRESH_URL
                    }
                }
            }
        }
    }   
};

gsheets4:Client spreadsheetClient = new(spreadsheetConfig);

Then the endpoint actions can be invoked as var response = spreadsheetClient->actionName(arguments).

Sample

import ballerina/http;
import ballerina/io;
import wso2/gsheets4;

gsheets4:SpreadsheetConfiguration spreadsheetConfig = {
    clientConfig: {
        auth: {
            scheme: http:OAUTH2,
            config: {
                grantType: http:DIRECT_TOKEN,
                config: {
                    accessToken: "<accessToken>",
                    refreshConfig: {
                        clientId: "<clientId>",
                        clientSecret: "<clientSecret>",
                        refreshToken: "<refreshToken>",
                        refreshUrl: gsheets4:REFRESH_URL
                    }
                }
            }
        }
    }   
};
gsheets4:Client spreadsheetClient = new(spreadsheetConfig);

public function main(string... args) {
    var response = spreadsheetClient->openSpreadsheetById("1Ti2W5mGK4mq0_xh9Gl_zG_dK9qqwdduirsFgl6zZu7M");
    if (response is gsheets4:Spreadsheet) {
        io:println("Spreadsheet Details: ", response);
    } else {
        io:println("Error: ", response);
    }
}
You can’t perform that action at this time.