using System.Collections.Generic;
using System.Threading.Tasks;
using xCommons.Extensions;
using xHttpService.Constants;
using xHttpService.Extensions;
using xIdentityModels.Constants;
using xIdentityModels.Dtos;
using xIdentityModels.Models;
using xIdentityModels.Navigations;
using xIdentityService.Constants;
using xModels.Dtos;
namespace xIdentityService.Providers
{
public partial class XIdentityProvider
{
//
#region Friendship ...
///
/// Follow a User
///
/// Authentication Tokens
/// a user identifier which represent destination user
/// an instance of XFriendshipFollowing
public async Task Follow(
XTokenResponse tokens,
string destUser
)
{
//
// Validate Args ...
await validationProvider
.GroupValidationBuilder()
.AddNotNull(tokens)
.AddNotEmpty(
destUser,
tokens.AccessToken
)
.ValidateGroupAsync();
//
var client = GetRestClient(tokens);
//
var request = GetRestRequet(
XApiAccountEndpoint.Follow,
@params: new Dictionary { { XParam.XDestUser.GetStringValue (), destUser }
}
);
//
var response = await RunRestRequest(
client,
request,
XHttpMethod.POST
);
return response;
}
///
/// Cancel Following Request
///
/// Authentication Tokens
/// a user identifier which represent destination user
/// a boolean value
public async Task Cancel(
XTokenResponse tokens,
string destUser
)
{
//
// Validate Args ...
await validationProvider
.GroupValidationBuilder()
.AddNotNull(tokens)
.AddNotEmpty(
destUser,
tokens.AccessToken
)
.ValidateGroupAsync();
//
var client = GetRestClient(tokens);
//
var request = GetRestRequet(
XApiAccountEndpoint.Cancel,
@params: new Dictionary { { XParam.XDestUser.GetStringValue (), destUser }
}
);
//
var response = await RunRestRequest(
client,
request,
XHttpMethod.POST
);
return response;
}
///
/// Unfollow a Follower
///
/// Authentication Tokens
/// a user identifier which represent destination user
///
public async Task UnFollowFollower(
XTokenResponse tokens,
string destUser
)
{
//
// Validate Args ...
await validationProvider
.GroupValidationBuilder()
.AddNotNull(tokens)
.AddNotEmpty(
destUser,
tokens.AccessToken
)
.ValidateGroupAsync();
//
var client = GetRestClient(tokens);
//
var request = GetRestRequet(
XApiAccountEndpoint.UnFollowFollower,
@params: new Dictionary { { XParam.XDestUser.GetStringValue (), destUser }
}
);
//
var response = await RunRestRequest