Skip to content

Commit 9533781

Browse files
authored
Blackbaud RENXT Gifts connector updates (#3924)
1 parent 876b0a7 commit 9533781

File tree

2 files changed

+70
-3
lines changed

2 files changed

+70
-3
lines changed

certified-connectors/Blackbaud RENXT Gifts/apiProperties.json

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
},
2929
"iconBrandColor": "#0CD973",
3030
"scriptOperations": [
31-
"ListGiftCustomFields"
31+
"ListGiftCustomFields",
32+
"CreatePledgePayment"
3233
],
3334
"capabilities": [],
3435
"policyTemplateInstances": [
@@ -51,7 +52,10 @@
5152
"x-ms-apimTemplateParameter.propertyValuePathTemplate": "[{@body().payments}]",
5253
"x-ms-apimTemplate-policySection": "Request",
5354
"x-ms-apimTemplate-operationName": [
54-
"CreateGift"
55+
"CreateGift",
56+
"CreatePledge",
57+
"CreatePledgePayment",
58+
"CreateStock"
5559
]
5660
}
5761
},
@@ -64,7 +68,25 @@
6468
"x-ms-apimTemplateParameter.propertyValuePathTemplate": "[{@body().receipts}]",
6569
"x-ms-apimTemplate-policySection": "Request",
6670
"x-ms-apimTemplate-operationName": [
67-
"CreateGift"
71+
"CreateGift",
72+
"CreatePledge",
73+
"CreatePledgePayment",
74+
"CreateStock"
75+
]
76+
}
77+
},
78+
{
79+
"templateId": "setproperty",
80+
"title": "Set gift acknowledgements",
81+
"parameters": {
82+
"x-ms-apimTemplateParameter.newPropertyParentPathTemplate": "@body()",
83+
"x-ms-apimTemplateParameter.newPropertySubPathTemplate": "acknowledgements",
84+
"x-ms-apimTemplateParameter.propertyValuePathTemplate": "[{@body().acknowledgements}]",
85+
"x-ms-apimTemplate-policySection": "Request",
86+
"x-ms-apimTemplate-operationName": [
87+
"CreatePledge",
88+
"CreatePledgePayment",
89+
"CreateStock"
6890
]
6991
}
7092
},
@@ -117,6 +139,19 @@
117139
"AddGiftToBatch"
118140
]
119141
}
142+
},
143+
{
144+
"templateId": "routerequesttoendpoint",
145+
"title": "Add pledge, payment, stock routing",
146+
"parameters": {
147+
"x-ms-apimTemplateParameter.newPath": "/gft-gifts/v2/gifts",
148+
"x-ms-apimTemplateParameter.httpMethod": "@Request.OriginalHTTPMethod",
149+
"x-ms-apimTemplate-operationName": [
150+
"CreatePledge",
151+
"CreatePledgePayment",
152+
"CreateStock"
153+
]
154+
}
120155
}
121156
],
122157
"publisher": "Blackbaud, Inc.",

certified-connectors/Blackbaud RENXT Gifts/script.csx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ public class Script : ScriptBase
44
{
55
switch (this.Context.OperationId)
66
{
7+
case "CreatePledgePayment":
8+
return await this.HandleCreatePledgePaymentOperation().ConfigureAwait(false);
9+
710
case "ListGiftCustomFields":
811
return await this.HandleListCustomFieldOperation().ConfigureAwait(false);
912
}
@@ -13,6 +16,35 @@ public class Script : ScriptBase
1316
return response;
1417
}
1518

19+
private async Task<HttpResponseMessage> HandleCreatePledgePaymentOperation()
20+
{
21+
// transform the installment_payments property to the applied_payments shape
22+
23+
// first, get the object from the request
24+
var requestContent = await this.Context.Request.Content.ReadAsStringAsync().ConfigureAwait(false);
25+
var requestJson = JObject.Parse(requestContent);
26+
27+
var installmentPayments = (JArray)requestJson["installment_payments"];
28+
29+
requestJson.Add("apply_payments", new JArray(installmentPayments.GroupBy(item => item["pledge_id"]).Select(group => new JObject() {
30+
["parent_id"] = group.Key,
31+
["installments"] = new JArray(group.Select(item => new JObject() {
32+
["installment_id"] = item["installment_id"],
33+
["amount_applied"] = item["amount_applied"]
34+
}))
35+
})));
36+
37+
// remove properties not used by the backend (should be ignored, but let's not risk it)
38+
requestJson.Remove("installment_payments");
39+
40+
var newBody = requestJson;
41+
42+
// send the request to the backend and return the response
43+
this.Context.Request.Content = CreateJsonContent(newBody.ToString());
44+
var response = await this.Context.SendAsync(this.Context.Request, this.CancellationToken).ConfigureAwait(continueOnCapturedContext: false);
45+
return response;
46+
}
47+
1648
private async Task<HttpResponseMessage> HandleListCustomFieldOperation()
1749
{
1850
// make the API request to the SKY API backend

0 commit comments

Comments
 (0)