EdgegapWizardApi.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System.Net.Http;
  2. using System.Threading.Tasks;
  3. using Edgegap.Editor.Api.Models.Results;
  4. using Newtonsoft.Json.Linq;
  5. namespace Edgegap.Editor.Api
  6. {
  7. /// <summary>Wraps the v1/wizard API endpoint. Used for internal purposes.</summary>
  8. public class EdgegapWizardApi : EdgegapApiBase
  9. {
  10. /// <summary>Extended path after the base uri</summary>
  11. public EdgegapWizardApi(
  12. ApiEnvironment apiEnvironment,
  13. string apiToken,
  14. EdgegapWindowMetadata.LogLevel logLevel = EdgegapWindowMetadata.LogLevel.Error)
  15. : base(apiEnvironment, apiToken, logLevel)
  16. {
  17. }
  18. #region API Methods
  19. /// <summary>POST to v1/wizard/init-quick-start</summary>
  20. /// <returns>
  21. /// Http info with no explicit data model
  22. /// - Success: 204 (no result model)
  23. /// </returns>
  24. public async Task<EdgegapHttpResult> InitQuickStart()
  25. {
  26. string json = new JObject { ["source"] = "unity" }.ToString();
  27. HttpResponseMessage response = await PostAsync("v1/wizard/init-quick-start", json);
  28. EdgegapHttpResult result = new EdgegapHttpResult(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
  29. return result;
  30. }
  31. /// <summary>GET to v1/wizard/registry-credentials</summary>
  32. /// <returns>
  33. /// - Http info with GetRegistryCredentialsResult data model
  34. /// - Success: 200
  35. /// - Error: Likely if called before a successful InitQuickStart(),
  36. /// or if called in a staging env. Soon, this will be available in production.
  37. /// </returns>
  38. public async Task<EdgegapHttpResult<GetRegistryCredentialsResult>> GetRegistryCredentials()
  39. {
  40. HttpResponseMessage response = await GetAsync("v1/wizard/registry-credentials");
  41. EdgegapHttpResult<GetRegistryCredentialsResult> result = new EdgegapHttpResult<GetRegistryCredentialsResult>(response); // MIRROR CHANGE: 'new()' not supported in Unity 2020
  42. return result;
  43. }
  44. #endregion // API Methods
  45. }
  46. }