private string GetPageUrl(RequestContext requestContext, string path, bool retry)
        {
            string matchedUrl = null;

            foreach (var pathPart in path.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (PageRegistration.IsLocationRegistered(pathPart))
                {
                    matchedUrl = pathPart;
                    break;
                }
            }

            if (matchedUrl == null && !retry)
            {
                PageRegistration.LocatePages();
                matchedUrl = this.GetPageUrl(requestContext, path, true);
            }

            if (!retry)
            {
                PageRegistration.RegisterPage(requestContext.HttpContext, requestContext.RouteData, matchedUrl);
            }

            return(matchedUrl);
        }
Example #2
0
        static void Main(string[] args)
        {
            const string appId  = "e488ce85";
            var          client = new JustGivingApiClient(appId);

            client.UseSandbox();
            client.LogEverything();

            //If you need to set a proxy, do so like this
            //client.UseProxy(new WebProxy());

            var password = Guid.NewGuid().ToString();
            var email    = $"example-{Guid.NewGuid():N}@justgiving.com";

            client.Accounts.CreateAccount(new RegisterAccountRequest()
            {
                FirstName = "Joe",
                LastName  = "bloggs",
                Email     = email,
                AcceptTermsAndConditions = true,
                Password  = password,
                Reference = "SDKSample"
            });

            Thread.Sleep(3000);

            client = new JustGivingApiClient(appId, new BasicCredential(email, password));
            client.UseSandbox();
            client.LogEverything();

            var pageName = "Sdk-test-" + DateTime.Now.ToFileTimeUtc();

            Console.WriteLine($"Creating fundraising page with page name '{pageName}'");

            var createPage = new PageRegistration
            {
                ActivityType    = ActivityTypes.Birthday,
                CharityId       = 2050,
                PageShortName   = pageName,
                PageTitle       = "My Sandbox Page",
                EventName       = "My Birthday",
                EventDate       = DateTime.Now.AddMonths(1).Date,
                PageStory       = "I created this page using the JustGiving SDK",
                PageSummaryWhat = "What",
                PageSummaryWhy  = "Why",
                Currency        = "GBP",
                ExpiryDate      = DateTime.Now.AddDays(3),
                Attribution     = "Joe Bloggs",
                CharityFunded   = false,
                CharityOptIn    = true
            };

            client.Fundraising.RegisterFundraisingPage(createPage);

            Thread.Sleep(5000);

            Process.Start($"https://v3-sandbox.justgiving.com/{pageName}");

            Console.ReadKey();
        }
        public async Task RegisterFundraisingPage(PageRegistration pageRegistration)
        {
            var resource = $"/v1/fundraising/pages";
            var request  = new HttpRequestMessage(HttpMethod.Put, resource);

            await Execute(request, pageRegistration);
        }
Example #4
0
        public async Task <RegisterPageForEventByEventReferenceResponse> CreatePageForEventByEventReference(string eventRef,
                                                                                                            PageRegistration pageRegistration)
        {
            var resource = $"/v1/event/ref/{eventRef}/pages";
            var request  = new HttpRequestMessage(HttpMethod.Post, resource);

            return(await Execute <RegisterPageForEventByEventReferenceResponse, PageRegistration>(request, pageRegistration));
        }