This is a simple C# library you can use to communicate with Huawei's Developer APIs with ease.
To use this library, you need to add its dependencies using AddHuaweiDeveloperApi method. First of all, add the required using statement.
usingHuawei.DeveloperApi;Then make a call to AddHuaweiDeveloperApi extension method.
publicoverridevoidConfigureServices(IServiceCollectionservices){services.AddHuaweiDeveloperApi(Configuration);}This method will register an instance of the following classes.
HuaweiOptions: This is the options used in the library.
HuaweiDeveloperService: You will use this to call any of the provided endpoints.
HuaweiInMemoryTokenStorage: This is the default implementation of IHuaweiTokenStorage, which stores the authorization details in-memory. By using this, you'll have to re-authorize your app against Cafe Bazaar.
Here is the required properties:
{
"Huawei": {
"ClientId": "<YOUR_CLIENT_ID>",
"ClientSecret": "<YOUR_CLIENT_SECRET>"
}
}You can use ValidateSubscription to validate a subscription.
[HttpGet("subscription/{subscriptionId}/{purchaseToken}")]publicasyncTask<IActionResult>Validate(stringsubscriptionId,stringpurchaseToken){varresult=await_developerService.ValidateSubscription(newHuaweiValidateSubscriptionRequest{SubscriptionId=subscriptionId,PurchaseToken=purchaseToken});returnnewJsonResult(result);}