Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/halomakes/abenity.perks

.NET Standard client for interacting with the Abenity Perks API
https://github.com/halomakes/abenity.perks

abenity api-clent netstandard20

Last synced: 14 days ago
JSON representation

.NET Standard client for interacting with the Abenity Perks API

Awesome Lists containing this project

README

        

# Abenity.Perks [![Version](https://img.shields.io/nuget/vpre/Abenity.Perks)](https://www.nuget.org/packages/Abenity.Perks/) [![Downloads](https://img.shields.io/nuget/dt/Abenity.Perks)](https://www.nuget.org/packages/Abenity.Perks/) [![Build Status](https://api.travis-ci.org/halomademeapc/Abenity.Perks.svg?branch=master)](https://travis-ci.org/github/halomademeapc/Abenity.Perks)
.NET Standard API Client for interacting with the [Abenity Perks API](https://abenity.com/developers/api/perks)
This can be used alongside the [Abenity.Members](https://github.com/halomademeapc/Abenity.Members) library to send users directly to a deal's details page.

> This code has not been fully-tested and is provided as-is. I do not have an account with access to the Perks API so this is based on the [limited documentation](https://abenity.com/developers/api/perks) at Abenity's developer site. If you have any issues please let me know or submit a bug and I will take a look.

## Configuration
The following information is required to authorize API requests.
1. A "username" (an API key)
2. Your client subdomain (mycompany.abenity.com)

Provided below is an example configuration section.
```json
"Perks": {
"BaseUrl": "https://YOUR_COMPANY.abenity.com/perks/api",
"Username": "abcdefghijkl"
}
```

## Example Usage
Register the API Client in your application's service provider
```csharp
var config = new AbenityPerksConfiguration();
Configuration.Bind("Perks", config);
services.AddSingleton(config);

services.AddHttpClient();
services.AddScoped();
```

Inject it into your service/controller and make a call
```csharp
private readonly IAbenityPerksApiClient perksClient;

public MyService(IAbenityPerksApiClient perksClient) {
this.perksClient = perksClient;
}

// Get offers using a category object
public async Task> GetOffers() {
var category = (await perksClient.GetCategoriesAsync()).FirstOrDefault();
var deals = await perksClient.GetOffersAsync(category);
return deals;
}

// Get offers using a category key
public Task> GetOffers(string key) => perksClient.GetOffersAsync(categoryKey: key);

// Get offers using a category ID
public Task> GetOffersById(string id) => perksClient.GetOffersAsync(categoryId: id);
```

## Dependencies
* **Newtonsoft.Json** 10.0.3+

## Changelog
**0.1.0-alpha** Initial Preview