This document outlines the implementation code for the API .NET wrapper on each available functionality on our API.
To use the component in your project, you will have to add a reference to it. Select Browse on the Add Reference dialog box and add the respective dll files.
Refer to the attachment at the bottom of this document for the .NET wrapper packaged dll.
I. Scope
- Authentication using Access Token
- Authentication using Client ID and Client Secret
- Create Fundraising Page
- Get Fundraising Pages By Event
- Get Beneficiaries by Event
II. Implementation
string clientid = "X-X-X-X";
string clientSecret = "X-X-X-X";
string apiDomain = "https://api.gofundraise.com.au";
try {
var apiClient = new GoFundraise.API.Client(apiDomain, clientId, clientSecret);
var newPageInfo = new GoFundraise.API.CreatePageRequest() {
UserAccountId = "1234567",
BeneficiaryAccountId = "100",
EventCampaignId = "10",
CreatorName= "Creator Name"
};
var newPage = apiClient.Pages.CreateFundraisingPage(newPageInfo);
}
catch (AuthenticationFailedException ex) {
string error = ex.Result.Error;
string errorDescription = ex.Result.ErrorDescription;
}
catch (RequestFailedException ex) {
}
III. Two Ways of Authentication
After registering your application, you can authenticate requests using either your Client Id and Client Secret or an Access Token. An AuthenticationFailedException exception would be received if the authentication does not succeed.
Client ID and Client Secret Authentication:
string clientId = "X-X-X-X";
string clientSecret = "X-X-X-X";
string apiDomain = "https://api.gofundraise.com.au";
var apiClient = new GoFundraise.API.Client(apiDomain, clientId, clientSecret);
Access Token Authentication:
string accessToken = "XXXXXXXXXX";
string apiDomain = "https://api.gofundraise.com.au";
var apiClient = new GoFundraise.API.Client(apiDomain, accessToken);
IV. Fundraising Page Client
Two Ways to Create a Fundraising Page:
Using UserAccountId
var newCreatePageRequest = new GoFundraise.API.CreatePageRequest() {
UserAccountId = "1234567",
BeneficiaryAccountId = "100",
EventCampaignId = "10"
};
var newPage = apiClient.Pages.CreateFundraisingPage(newCreatePageRequest);
Using Personal Details
var newCreatePageRequest = new GoFundraise.API.CreatePageRequest() {
EmailAddress = "jane.smith@gmail.com",
FirstName = "Jane",
LastName = "Smith",
DateOfBirth = "1990-10-10",
BeneficiaryAccountId = "100",
EventCampaignId = "10"
};
var newPage = apiClient.Pages.CreateFundraisingPage(newCreatePageRequest);
Get a Fundraising Page:
var pageId = 1234567;
var page = apiClient.Pages.GetFundraisingPage(pageId);
List Fundraising Pages By Event:
var eventId = 1234567;
var eventPages = apiClient.Pages.GetFundraisingPagesByEvent(eventId);
VI. Beneficiaries Client
List Beneficiaries By Event:
var eventId = 1234567;
var eventBeneficiaries = apiClient.Pages.GetBeneficiariesByEvent(eventId);
VI. Models
Fundraising Page Creation Model
Class:
GoFundraise.API.CreatePageRequest
Fields:
UserAccountId
EmailAddress
FirstName
LastName
DateOfBirth
BeneficiaryAccountId
EventCampaignId
WebTag
PageTitle
CreatorName
Message
PageTypeId
TeamId
ImagePath
RaiseTarget
MinimumRaiseTarget
TeamTarget
DisplayDonations
DisplayDonationAmount
DisplayFitnessData
ExpireDate