SEEK.AdPostingApi.Client.Resources.AdvertisementSummaryPageResource.Initialise C# (CSharp) Method

Initialise() public method

public Initialise ( Hal client ) : void
client Hal
return void
        public void Initialise(Hal.Client client)
        {
            this._client = client;
        }

Usage Example

        public async Task GetAllAdvertisementsByAdvertiserNextPage()
        {
            const string advertiserId = "456";
            const string advertisementId1 = "f7302df2-704b-407c-a42a-62ff822b5461";
            const string beforeJobId = "5";
            const string queryString = "advertiserId=" + advertiserId + "&beforeId=" + beforeJobId;
            const string selfLink = "/advertisement?" + queryString;
            OAuth2Token oAuth2Token = new OAuth2TokenBuilder().Build();

            this.Fixture.AdPostingApiService
                .Given("A page size of 3 with more than 1 page of data")
                .UponReceiving("a GET advertisements request for the second page of advertisements belonging to the advertiser")
                .With(new ProviderServiceRequest
                {
                    Method = HttpVerb.Get,
                    Path = "/advertisement",
                    Query = queryString,
                    Headers = new Dictionary<string, string>
                    {
                        { "Authorization", "Bearer " + oAuth2Token.AccessToken },
                        { "Accept", $"{ResponseContentTypes.AdvertisementListVersion1}, {ResponseContentTypes.AdvertisementErrorVersion1}" },
                        { "User-Agent", AdPostingApiFixture.UserAgentHeaderValue }
                    }
                })
                .WillRespondWith(new ProviderServiceResponse
                {
                    Status = 200,
                    Headers = new Dictionary<string, string>
                    {
                        { "Content-Type", ResponseContentTypes.AdvertisementListVersion1 },
                        { "X-Request-Id", RequestId }
                    },
                    Body = new
                    {
                        _embedded = new
                        {
                            advertisements = new[]
                            {
                                new AdvertisementSummaryResponseContentBuilder()
                                    .WithId(advertisementId1)
                                    .WithAdvertiserId(advertiserId)
                                    .WithJobTitle("Exciting Developer role in a great CBD location. Great $$")
                                    .WithJobReference("JOB1111")
                                    .WithResponseLink("self", this.GenerateSelfLink(advertisementId1))
                                    .WithResponseLink("view", this.GenerateViewLink(advertisementId1))
                                    .Build()
                            }
                        },
                        _links = new
                        {
                            self = new { href = selfLink }
                        }
                    }
                });

            AdvertisementSummaryPageResource pageResource = new AdvertisementSummaryPageResource
            {
                Links = new Links(this.Fixture.AdPostingApiServiceBaseUri)
                {
                    {"self", new Link {Href = "/advertisement"}},
                    {"next", new Link {Href = $"/advertisement?advertiserId={advertiserId}&beforeId={beforeJobId}"}}
                }
            };

            var oAuthClient = Mock.Of<IOAuth2TokenClient>(c => c.GetOAuth2TokenAsync() == Task.FromResult(oAuth2Token));
            AdvertisementSummaryPageResource nextPageResource;

            using (var client = new Hal.Client(new HttpClient(new AdPostingApiMessageHandler(new OAuthMessageHandler(oAuthClient)))))
            {
                pageResource.Initialise(client);

                nextPageResource = await pageResource.NextPageAsync();
            }

            AdvertisementSummaryPageResource expectedNextPageResource = new AdvertisementSummaryPageResource
            {
                AdvertisementSummaries = new List<AdvertisementSummaryResource>
                {
                    new AdvertisementSummaryResource
                    {
                        Id = new Guid(advertisementId1),
                        AdvertiserId = advertiserId,
                        JobReference = "JOB1111",
                        JobTitle = "Exciting Developer role in a great CBD location. Great $$",
                        Links = new Links(this.Fixture.AdPostingApiServiceBaseUri)
                        {
                            {"self", new Link {Href = $"/advertisement/{advertisementId1}"}},
                            {"view", new Link {Href = $"/advertisement/{advertisementId1}/view"}}
                        }
                    }
                },
                Links = new Links(this.Fixture.AdPostingApiServiceBaseUri)
                {
                    {"self", new Link {Href = selfLink}}
                },
                RequestId = RequestId
            };

            nextPageResource.ShouldBeEquivalentTo(expectedNextPageResource);
        }
AdvertisementSummaryPageResource