Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import ballerina/http;

map<json[]> partialSurveys = {};

listener http:Listener httpListener = new (port = 8080);

service /api/v1 on httpListener {
resource function post survey/[string id](@http:Header string userId, @http:Payload json formData) returns error? {
map<json[]> partialSurveys = {};
json[]|() surveyData = partialSurveys[userId];
if surveyData == () {
json[] newSurvey = [formData];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[package]
org = "wso2"
name = "channel_adapter"
version = "0.1.0"
version = "0.1.0"
[[dependency]]
org = "ballerinax"
name = "jira"
version = "1.5.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function filterReimbursements(DetailedReimbursementTemplate[] templates) returns ReimbursementTemplate[] =>
from var templatesItem in templates
select {reimbursementTypeID: templatesItem.reimbursementTypeID, fixedAmount: templatesItem.fixedAmount};
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ service /payroll on httpListener {

resource function post employees/[string id]/paytemplate/reimbursements(DetailedReimbursementTemplate[] templates)
returns Reimbursement|error {
ReimbursementTemplate[] reimbursementRequests = from var {reimbursementTypeID, fixedAmount} in templates
select {reimbursementTypeID, fixedAmount};
ReimbursementTemplate[] reimbursementRequests = filterReimbursements(templates);
Reimbursement result = check xero->/payrollxro/employees/[id]/paytemplate/reimbursements.post(reimbursementRequests);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function toPatient(PatientReqV1 req) returns Patient => {
dob: req.dob,
fullName: req.firstName + " " + req.lastName,
diagnosis: req.diagnosis
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@ import ballerina/http;
listener http:Listener httpListener = new (port = 8080);

service /api/v1 on httpListener {
resource function post data/patient(PatientReq patintReq) returns error? {
resource function post data/patient(PatientReq patientReq) returns error? {
Patient patient;
if patintReq is PatientReqV1 {
patient = {
dob: patintReq.dob,
fullName: patintReq.firstName + " " + patintReq.lastName,
diagnosis: patintReq.diagnosis
};
if patientReq is PatientReqV1 {
patient = toPatient(patientReq);
} else {
patient = {
dob: patintReq.patient.dob,
fullName: patintReq.patient.fullName,
diagnosis: patintReq.patient.diagnosis
dob: patientReq.patient.dob,
fullName: patientReq.patient.fullName,
diagnosis: patientReq.patient.diagnosis
};
}
http:Response response = check patientClient->/patient.post(patient, targetType = http:Response);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import ballerina/http;

map<OrderStatus> orderStatuses = {};

listener http:Listener httpListener = new (port = 8080);

service /api/v1 on httpListener {
resource function put manage\-orders/[string orderId](OrderDetail orderDetail) returns http:STATUS_NO_CONTENT|http:STATUS_CREATED {
map<OrderStatus> orderStatuses = {};
"CANCELLED"|"COMPLETED"|"SHIPPED"|"CREATED"|() orderStatus = orderStatuses[orderId];
if orderStatus == orderDetail.status {
return http:STATUS_NO_CONTENT;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import ballerina/http;

final http:Client surveyMonkey = check new ("http://api.surveymonkey.com/v3/surveys");
final http:Client surveyMonkey = check new ("http://api.surveymonkey.com.balmock.io");
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import ballerina/http;
listener http:Listener httpListener = new (port = 8080);

service /api/v1/rates on httpListener {
isolated resource function get covert(Currency base, Currency target, decimal amount = 1.00) returns decimal {
isolated resource function get convert(Currency base, Currency target, decimal amount = 1.00) returns decimal {
map<decimal> rates = {
"AUD": 1.59,
"INR": 83.24,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

type Currency "AUD"|"INR"|"BGP";
type Currency "AUD"|"INR"|"GBP";
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function translate(SalesData salesData) returns QuickBooksInvoice => {
customerId: salesData.customer.id,
invoices: from var opportunity in salesData.opportunities
select {
id: opportunity.id,
amount: opportunity.amount,
invoiceDate: opportunity.closeDate
}
};
Original file line number Diff line number Diff line change
@@ -1,11 +0,0 @@
function translate(SalesData salesData) returns QuickBooksInvoice {
return {
customerId: salesData.customer.id,
invoices: from var oppotunity in salesData.opportunities
select {
id: oppotunity.id,
amount: oppotunity.amount,
invoiceDate: oppotunity.closeDate
}
};
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

type SalesData record {|
Customer customer;
Oppotunity[] opportunities;
Opportunity[] opportunities;
|};

type Customer record {|
Expand All @@ -10,7 +10,7 @@ type Customer record {|
string email;
|};

type Oppotunity record {|
type Opportunity record {|
string id;
decimal amount;
string closeDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ listener http:Listener httpDefaultListener = http:getDefaultListener();

service /api/v1 on httpDefaultListener {
isolated resource function get employee/top\-performers(int count) returns TopPerformer[]|error {
EmployeePerformance[] employeePerformace = check firebaseClient->/performance\.json.get();
return from var {empId, productivity, customerSatisfaction, goalAchievement} in employeePerformace
EmployeePerformance[] employeePerformance = check firebaseClient->/performance\.json.get();
return from var {empId, productivity, customerSatisfaction, goalAchievement} in employeePerformance
let float performance = productivity * 0.3 + customerSatisfaction * 0.1 + goalAchievement * 0.6
where performance > 7.5
limit count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function createFedexShipment(OrderResponse response) returns FedexResponse|error
return targetType;
}

function creeateDhlShipment(OrderResponse response) returns DHLResponse|error {
function createDhlShipment(OrderResponse response) returns DHLResponse|error {
ShipmentRequest dhlReq = {
amount: response.total,
currency: response.currency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ service /api/v1 on httpListener {
FedexResponse fedexResp = check createFedexShipment(response);
trackingNumber = fedexResp.trackingNumber;
} else {
DHLResponse dhlResp = check creeateDhlShipment(response);
DHLResponse dhlResp = check createDhlShipment(response);
trackingNumber = dhlResp.trackingNumber;
}
future<error?> futureResult = start sendConfirmationMail(response.address.fullName, response.email, trackingNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ service /api/v1 on httpListener {
mobileNumber: message.mobileNumber,
routingSlip: message.routingSlip
};
http:Response targetType = check pointHandler->/points.post(payload);
points = check pointHandler->/points.post(payload);
}
return checkout(message, points);
}
Expand Down