Skip to content

Instantly share code, notes, and snippets.

View pramodya1994's full-sized avatar
🏠
Working from home

Pramodya Mendis pramodya1994

🏠
Working from home
View GitHub Profile
import ballerina/io;
public function main() {
io:println("Hello, World!");
}
# AUTO-GENERATED FILE. DO NOT MODIFY.
# This file is auto-generated by Ballerina for managing dependency versions.
# It should not be modified by hand.
[ballerina]
dependencies-toml-version = "2"
[[package]]
org = "ballerina"
@pramodya1994
pramodya1994 / .bal
Created November 16, 2021 11:36
new main.bal
# Prints `Hello` with input string name.
#
# + name - the input sting name
# + return - "Hello " with the input string name
public function sayHello(string name) returns string {
if !(name is "") {
// We are adding "!" in the end and remove "," after hello as a bug fix.
return "Hello " + name + "!";
}
import ballerina/io;
import pramodya/greetings;
// Prints `Hello World`.
public function main() {
io:println(greetings:sayHello("Doe"));
}
public function main() returns error? {
// Create salesforce bulk client.
sfdc46:SalesforceBulkClient sfBulkClient = salesforceClient->createSalesforceBulkClient();
// Create CSV insert operator.
sfdc46:CsvInsertOperator csvInserter = check sfBulkClient->createCsvInsertOperator("Contact");
// Read CSV file content.
io:ReadableByteChannel contacts = check io:openReadableFile("sfdc contacts - sheet1.csv");
// Import csv contacts to Salesforce.
sfdc46:BatchInfo batch = check csvInserter->insert(<@untainted> contacts);
}
public function main() returns error? {
// Create salesforce bulk client.
sfdc46:SalesforceBulkClient sfBulkClient = salesforceClient->createSalesforceBulkClient();
// Create CSV insert operator.
sfdc46:CsvInsertOperator csvInserter = check sfBulkClient->createCsvInsertOperator("Contact");
}
@pramodya1994
pramodya1994 / ballerina.conf
Created October 21, 2019 12:01
Ballerina config file
BASE_URL="https://<YOUR_INSTANCE>.salesforce.com"
ACCESS_TOKEN="00D2v000001XKxi!AQ4AQF__SOMETHING"
CLIENT_ID="3MVG9G9pzCUSkzZt4BtawIPCq__SOMETHING"
CLIENT_SECRET="F76A05F3E49F73C640EC7__SOMETHING"
REFRESH_TOKEN="5Aep861dlMxAL.LhVTuPR__SOMETHING"
REFRESH_URL="https://login.salesforce.com/services/oauth2/token"
@pramodya1994
pramodya1994 / main.bal
Created October 21, 2019 11:23
Ballerina Salesforce Configuration
import wso2/sfdc46;
import ballerina/config;
sfdc46:SalesforceConfiguration salesforceConfig = {
baseUrl: config:getAsString("BASE_URL"),
clientConfig: {
accessToken: config:getAsString("ACCESS_TOKEN"),
refreshConfig: {
clientId: config:getAsString("CLIENT_ID"),
import React, {Component} from 'react';
import './App.css';
class ItemAdder extends Component {
constructor(props) {
super(props);
this.state = {
widgetName: "Add items to cart",
name: "",