- A .NET version of SEEK's Job Ad Posting API Client which can be installed via NuGet.
- It comprises of the following three projects:
- SEEK.AdPostingApi.Client - Source code of the API client
- SEEK.AdPostingApi.SampleConsumer - Example code using the API client to make requests to the Job Ad Posting API
- SEEK.AdPostingApi.Client.Tests - Contract (PACT) tests between the API client and the Job Ad Posting API.
- Exchanges the OAuth 2.0 credentials (client key and client secret) for an OAuth 2.0 access token.
- Using the OAuth 2.0 access token:
- Retrieves the API links from the Job Ad Posting API.
- Depending on the operation (create, update, retrieve or expire):
- Builds the appropriate API link for the operation.
- Makes the appropriate request to the API.
- Job Ad Posting API Documentation
- NuGet Package
- Release Notes
- Contract (PACT) Between the API Client and the Job Ad Posting API
Via NuGet with Install-Package SEEK.AdPostingApi.Client
To initialize a client, the following values are needed:
- Client Key [Required]: the client key for getting an OAuth 2 access token
- Client Secret [Required]: the client secret for getting an OAuth 2 access token
- Environment [Optional]: the environment to which your consumer will integrate with, either "Integration" or "Production" can be supplied. Without supplying anything, "Production" will be used by default.
- AdPostingApiBaseUrl [Optional]: the URL of the Job Ad Posting API. Without supplying anything, the Production URL will be used by default.
IAdPostingApiClient postingClient = new AdPostingApiClient("<client id>", "<client secret>", Environment.Integration);
var ad = new Advertisement
{
CreationId = "Sample Consumer 20151001 114732 1234567",
ThirdParties = new ThirdParties { AdvertiserId = "Advertiser Id" },
JobTitle = "A Job Title",
JobSummary = "Job summary of the job ad",
AdvertisementDetails = "Experience Required",
AdvertisementType = AdvertisementType.Classic,
WorkType = WorkType.Casual,
Salary = new Salary
{
Type = SalaryType.HourlyRate,
Minimum = 20,
Maximum = 24
},
Location = new Location
{
Id = "Melbourne",
AreaId = "MelbourneNorthernSuburbs"
},
SubclassificationId = "AerospaceEngineering"
};
AdvertisementResource advertisement = await postingClient.CreateAdvertisementAsync(ad);
This client supports specifying a custom DelegatingHandler for logging or processing requests/responses before they're sent. The custom delegating handlers will:
- Be last in the request pipeline before sending the request; and
- Will have the
InnerHandler
automatically set by theAdPostingApiClient
For example, a custom LoggingDelegatingHandler
can be specified:
public class LoggingDelegatingHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Log.Verbose("Making request to {RequestUri}", request.RequestUri);
return await base.SendAsync(request, cancellationToken);
}
}
using (var client = new AdPostingApiClient("<client id>", "<client secret>", Environment.Integration, new LoggingDelegateHandler()))
{
// Use the client as per normal
}
The build scripts are written in GNU Make.
- Dotnet core 2.1 LTS SDK.
- GNU Make to run the build locally.
- CS-Script for generating PACT markdown files. If ".Net Core 2.1 Global Tool" does not work, use the OS-specific install instructions.
Run make
from the root folder to get help on targets.
Example targets:
make
to show helpmake test
to build and run tests locally
- The latest PACTs in
/pact
should be committed and pushed, this includes the documentation generated with thepact-markdown
target
The build scripts are written in Cake (C#), and will automatically pull down the required .NET Core SDK.
- Powershell v4 or later
- CS-Script for generating PACT markdown files. If ".Net Core 2.1 Global Tool" does not work, use the OS-specific install instructions.
Run the builds from the build
folder.
Some example targets:
.\build.ps1 -Target Help
to list help.\build.ps1 -Target Test
to build and run all tests.\build.ps1 -Target Test -Configuration Debug
to build and run all tests in debug mode.\build.ps1 -Target NuGet
to build a NuGet package in/out
.\build.ps1 -Target PactMarkdown
to generate Markdown of the PACTs in/pact
, this is required if they've changed.\build.ps1 -Target UploadPact
to build, run all tests, and upload the PACTs to the broker- The broker can be specified with environment variables:
PACT_BROKER_URL
,PACT_BROKER_USERNAME
(optional), andPACT_BROKER_PASSWORD
(optional)
- The broker can be specified with environment variables:
- The latest PACTs should be committed to
/pact
, this includes the documentation generated with thePactMarkdown
target