Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add company survey example #158

Merged
merged 14 commits into from
Jul 5, 2024

Conversation

Chilliwiddit
Copy link
Contributor

Purpose

Add company survey example

Examples

Checklist

  • Linked to an issue
  • Updated the changelog
  • Added tests
  • Updated the spec
  • Checked native-image compatibility

@@ -0,0 +1,5 @@
[package]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename is file to Ballerina.toml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes. Thanks

import ballerinax/slack;

public function companySurvey() returns error? {
slack:Client cl = check new ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this as a final module variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved. Thank you.

public function companySurvey() returns error? {
slack:Client cl = check new ({
auth: {
token: value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The token should be defined as configurable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved Thanks

@@ -0,0 +1,24 @@
import ballerina/io;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing license header


configurable string value = ?;

final slack:Client cl = check new ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final slack:Client cl = check new ({
final slack:Client slack = check new ({

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to keep the Config.toml file

@@ -0,0 +1,5 @@
[package]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[package]

org = "wso2"
name = "company_survey"
version = "0.1.0"
distribution = "2201.9.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing newline

Comment on lines 2 to 6
import ballerinax/slack; //importing the slack connector module

configurable string value = ?; //initializing of the configurable token value variable

final slack:Client slack = check new ({ //the initialization of the slack client at module variable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to comment on self-explanatory code

import ballerina/io; //importing the io module
import ballerinax/slack; //importing the slack connector module

configurable string value = ?; //initializing of the configurable token value variable
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
configurable string value = ?; //initializing of the configurable token value variable
configurable string token = ?;


final slack:Client slack = check new ({ //the initialization of the slack client at module variable
auth: {
token: value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
token: value
token

}
});

public function companySurvey() returns error? {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function companySurvey() returns error? {
public function main() returns error? {

public function companySurvey() returns error? {

json conversationsResponse = check slack->/conversations\.create.post({name: "survey-coordination"});
io:println(conversationsResponse); //creation of a channel to coordinate surveys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to print these intermediate reponses

Improve the example and fix various issues
@NipunaRanasinghe NipunaRanasinghe merged commit 4ec03cc into ballerina-platform:master Jul 5, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants