Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- var identityApi = RestService.For<IAuthenticationIdentity>("add url here", new RefitSettings
- {
- });
- try
- {
- //var identity = identityApi.GetIdentity(689447080124620801, Guid.NewGuid().ToString()).Result;
- var identity = identityApi.CreateIdentity(new CreateIdentityRequest
- {
- Username = "barry",
- Sitecode = "sitecode",
- Password = "open sesame"
- }, Guid.NewGuid().ToString()).Result;
- }
- catch (AggregateException exception)
- {
- var apiException = exception.InnerException as ApiException;
- if (apiException != null)
- {
- Console.WriteLine(apiException.Message);
- }
- }
- catch (ApiException exception)
- {
- Console.WriteLine(exception.Message);
- }
- Console.ReadLine();
- }
- }
- public interface IAuthenticationIdentity
- {
- [Get("/identity/{id}")]
- Task<Identity> GetIdentity(long id, [Header("X-Correlation-Token")]string correlationToken);
- [Post("/identity")]
- Task<Identity> CreateIdentity([Body] CreateIdentityRequest identity, [Header("X-Correlation-Token")]string correlationToken);
- }
- public class CreateIdentityRequest
- {
- public string Username { get; set; }
- public string Sitecode { get; set; }
- public string Password { get; set; }
- }
- public class Identity
- {
- public long BedePlayerId { get; set; }
- public string Username { get; set; }
- public string Sitecode { get; set; }
- public bool IsLockedOut { get; set; }
- public DateTime? LastLoginDate { get; set; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement