Exemplo n.º 1
0
        public async Task <ServiceProviderResponse> CreateOrUpdateUserInfoRecordAsync(
            [FromHeader(Constant.OperationTrackingIdHeader)] string requestId,
            [FromHeader] string account,
            [FromBody] UserInfoRecordDescription description)
        {
            Validator.ArgumentNotNullOrEmpty(account, nameof(account));
            Validator.ArgumentNotNull(description, nameof(description));
            description.Validate();
            var    channel     = SocialChannelHelper.Format(description.Channel);
            object channelId   = null;
            object platform    = null;
            object accessToken = null;

            description.Properties.TryGetValue(ChannelIdKey, out channelId);
            Validator.ArgumentNotNull(channelId, nameof(channelId));
            description.Properties.TryGetValue(AccessTokenKey, out accessToken);
            Validator.ArgumentNotNull(accessToken, nameof(accessToken));
            description.Properties.TryGetValue(PlatformKey, out platform);
            Validator.ArgumentNotNull(platform, nameof(platform));
            var socialPlatform = SocialPlatformHelper.Format(platform.ToString());

            var record = await this.engine.CreateOrUpdateUserInfoRecordAsync(account, channel, accessToken.ToString(), channelId.ToString(), socialPlatform, requestId, CancellationToken.None);

            return(new ServiceProviderResponse
            {
                StatusCode = HttpStatusCode.OK,
                JsonContent = record
            });
        }
Exemplo n.º 2
0
        public async Task <ServiceProviderResponse> DeleteUserInfoRecordAsync(
            [FromHeader(Constant.OperationTrackingIdHeader)] string requestId,
            [FromHeader] string account,
            [FromQuery] string channel,
            [FromQuery] string id)
        {
            Validator.ArgumentNotNullOrEmpty(account, nameof(account));
            Validator.ArgumentNotNullOrEmpty(channel, nameof(channel));
            Validator.ArgumentNotNullOrEmpty(id, nameof(id));
            channel = SocialChannelHelper.Format(channel);
            await this.engine.DeleteUserInfoRecordAsync(account, channel, id, requestId, CancellationToken.None);

            return(new ServiceProviderResponse
            {
                StatusCode = HttpStatusCode.OK
            });
        }