Advertisement
Guest User

Untitled

a guest
Jan 21st, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. var identityApi = RestService.For<IAuthenticationIdentity>("add url here", new RefitSettings
  6. {
  7.  
  8. });
  9.  
  10. try
  11. {
  12. //var identity = identityApi.GetIdentity(689447080124620801, Guid.NewGuid().ToString()).Result;
  13.  
  14. var identity = identityApi.CreateIdentity(new CreateIdentityRequest
  15. {
  16. Username = "barry",
  17. Sitecode = "sitecode",
  18. Password = "open sesame"
  19. }, Guid.NewGuid().ToString()).Result;
  20. }
  21. catch (AggregateException exception)
  22. {
  23. var apiException = exception.InnerException as ApiException;
  24. if (apiException != null)
  25. {
  26. Console.WriteLine(apiException.Message);
  27. }
  28. }
  29. catch (ApiException exception)
  30. {
  31. Console.WriteLine(exception.Message);
  32. }
  33.  
  34. Console.ReadLine();
  35. }
  36. }
  37.  
  38.  
  39. public interface IAuthenticationIdentity
  40. {
  41. [Get("/identity/{id}")]
  42. Task<Identity> GetIdentity(long id, [Header("X-Correlation-Token")]string correlationToken);
  43.  
  44. [Post("/identity")]
  45. Task<Identity> CreateIdentity([Body] CreateIdentityRequest identity, [Header("X-Correlation-Token")]string correlationToken);
  46. }
  47.  
  48. public class CreateIdentityRequest
  49. {
  50. public string Username { get; set; }
  51.  
  52. public string Sitecode { get; set; }
  53.  
  54. public string Password { get; set; }
  55. }
  56.  
  57. public class Identity
  58. {
  59. public long BedePlayerId { get; set; }
  60.  
  61. public string Username { get; set; }
  62.  
  63. public string Sitecode { get; set; }
  64.  
  65. public bool IsLockedOut { get; set; }
  66.  
  67. public DateTime? LastLoginDate { get; set; }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement