Skip to content

Instantly share code, notes, and snippets.

@zahedshareef
Last active April 28, 2021 16:23
Show Gist options
  • Save zahedshareef/a3785d7067bc510d64f0befedaacd803 to your computer and use it in GitHub Desktop.
Save zahedshareef/a3785d7067bc510d64f0befedaacd803 to your computer and use it in GitHub Desktop.
Sample Og Stack Client Enrollment API in .NET Core
namespace ServiceProviderSolution.Controllers
{
[Route("api/v1/subscriptions")]
[ApiController]
public class SubscriptionsController : ControllerBase
{
private readonly IEnrollmentService _enrollmentService;
public SubscriptionsController(IEnrollmentService enrollmentService)
{
_enrollmentService = enrollmentService;
}
[HttpPost("init")]
public async Task<IActionResult> Init([FromBody] InitRequest payload)
{
await _enrollmentService.InitService(input);
return Ok();
}
[HttpPost]
public async Task<IActionResult> Enroll([FromBody] EncryptedEnrollmentRequest payload)
{
await _enrollmentService.EnrollService(input);
return Ok();
}
[HttpDelete("{id}")]
public async Task<IActionResult> UnEnroll([FromRoute] string id, [FromBody] UnEnrollmentRequest payload)
{
await _enrollmentService.UnEnrollService(id, input);
return Ok();
}
}
}
public class EncryptedEnrollmentRequest
{
public string EncryptedData { get; set; }
public string EncryptedKey { get; set; }
public string PublicKeyFingerprint { get; set; }
public string HashingAlgorithm { get; set; }
}
public class InitRequest
{
public string ServiceName { get; set; }
public string ServiceProviderName { get; set; }
public bool Sandbox { get; set; }
}
public class UnEnrollmentRequest
{
public string ServiceId { get; set; }
public string TenantId { get; set; }
//other parameters included as part of OperationUrl are passed here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment