Back to EIP
Content Filter
Pattern | The content filter removes data from the original message and can also be employed to simplify the message structure. |
How Ballerina helps | Ballerina excels at manipulating data and handling diverse formats, structures, and transformations. The query expression ( |
import ballerina/http;
type DetailedReimbursementTemplate record {
string reimbursementTypeID;
string reimbursementTypeName;
float fixedAmount;
};
type ReimbursementTemplate record {
string reimbursementTypeID;
float fixedAmount;
};
type Reimbursement record {
string id;
record {
string reimbursementTypeID;
float fixedAmount;
}[] reimbursementTemplates;
};
final http:Client xero = check new ("http://api.xero.com.balmock.io");
service /payroll on new http:Listener(8080) {
resource function post employees/[string id]/paytemplate/reimbursements(DetailedReimbursementTemplate[] templates)
returns Reimbursement|error {
ReimbursementTemplate[] reimbursementRequests = from var {reimbursementTypeID, fixedAmount} in templates
select {reimbursementTypeID, fixedAmount};
return xero->/payrollxro/employees/[id]/paytemplate/reimbursements.post(reimbursementRequests);
}
}