Example #1
0
        private async Task <WebApiSetting> LoadWebApiSettingAsync(MFWebApiOption option, CancellationToken token)
        {
            var setting = (await webApiSettingQueryProcessor.GetByIdAsync(option.CompanyId, ApiTypeId, token)) ?? new WebApiSetting
            {
                CompanyId      = option.CompanyId,
                ApiTypeId      = ApiTypeId,
                ApiVersion     = option.ApiVersion,
                ClientId       = option.ClientId,
                ClientSecret   = option.ClientSecret,
                ExtractSetting = option.ExtractSetting,
                CreateBy       = option.LoginUserId,
                UpdateBy       = option.LoginUserId,
            };

            if (!string.IsNullOrEmpty(option.ClientId))
            {
                setting.ClientId = option.ClientId;
            }
            if (!string.IsNullOrEmpty(option.ClientSecret))
            {
                setting.ClientSecret = option.ClientSecret;
            }
            if (!string.IsNullOrEmpty(option.ExtractSetting))
            {
                setting.ExtractSetting = option.ExtractSetting;
            }
            return(setting);
        }
Example #2
0
        /// <summary>access_token/refresh_token の有効性を確認</summary>
        /// <param name="option"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <bool> ValidateToken(MFWebApiOption option, CancellationToken token = default(CancellationToken))
        {
            var setting = await LoadWebApiSettingAsync(option, token);

            client.WebApiSetting = setting;
            var valid = await client.ValidateToken();

            await SaveSettingInnerAsync(client, option, token);

            return(valid);
        }
Example #3
0
        /// <summary>請求データ取得処理</summary>
        /// <param name="option"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <IEnumerable <billing> > GetBillingsAsync(MFWebApiOption option, CancellationToken token = default(CancellationToken))
        {
            var setting = await LoadWebApiSettingAsync(option, token);

            client.WebApiSetting = setting;
            var billings = (await client.GetBillingAsync(option.BillingDateFrom, option.BillingDateTo)).ToArray();

            await SaveSettingInnerAsync(client, option, token);

            return(billings);
        }
Example #4
0
        /// <summary>取引先情報取得処理</summary>
        /// <param name="option"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <partner> GetPartnersAsync(MFWebApiOption option, CancellationToken token = default(CancellationToken))
        {
            var setting = await LoadWebApiSettingAsync(option, token);

            client.WebApiSetting = setting;

            var partner = await client.GetPartnersAsync(option.PartnerId);

            await SaveSettingInnerAsync(client, option, token);

            return(partner);
        }
Example #5
0
        /// <summary>MFC請求書 入金ステータスの更新処理</summary>
        /// <param name="option"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <bool> PatchBillings(MFWebApiOption option, CancellationToken token = default(CancellationToken))
        {
            var setting = await LoadWebApiSettingAsync(option, token);

            client.WebApiSetting = setting;

            var result = await client.PatchPaymentAsync(option.MFIds, option.IsMatched);

            await SaveSettingInnerAsync(client, option, token);

            return(result);
        }
Example #6
0
        /// <summary>事業所取得処理</summary>
        /// <param name="option"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public async Task <Office> GetOfficesAsync(MFWebApiOption option, CancellationToken token = default(CancellationToken))
        {
            var setting = await LoadWebApiSettingAsync(option, token);

            client.WebApiSetting = setting;

            var office = await client.GetOfficeAsync();

            await SaveSettingInnerAsync(client, option, token);

            return(office);
        }
Example #7
0
        private async Task <int> SaveSettingInnerAsync(MFWebApiClient client, MFWebApiOption option, CancellationToken token)
        {
            var result = 0;

            if (client.TokenRefreshed)
            {
                var setting = client.WebApiSetting;
                setting.UpdateBy = option.LoginUserId;
                result           = await addWebApiSettingQueryProcessor.SaveAsync(setting, token);

                client.TokenRefreshed = false;
            }
            return(result);
        }
Example #8
0
        /// <summary>登録・認証処理</summary>
        /// <param name="option"></param>
        /// <param name="token"></param>
        /// <returns>0:成功, -1:認証失敗, -2:登録失敗</returns>
        public async Task <int> SaveSettingAsync(MFWebApiOption option, CancellationToken token = default(CancellationToken))
        {
            const int Success = 0;
            const int AuthenticationFailure = -1;
            const int SaveFailure           = -2;

            var setting = await LoadWebApiSettingAsync(option, token);

            client.AuthorizationCode = option.AuthorizationCode;
            client.WebApiSetting     = setting;

            var authResult = false;

            if (!string.IsNullOrEmpty(option.AuthorizationCode))
            {
                authResult = await client.AuthorizeAsync();
            }
            else
            {
                authResult = await client.ValidateToken();
            }
            if (!authResult)
            {
                return(AuthenticationFailure);
            }

            setting = client.WebApiSetting;
            var saveResult = await addWebApiSettingQueryProcessor.SaveAsync(setting, token);

            if (saveResult != 1)
            {
                return(SaveFailure);
            }

            return(Success);
        }
Example #9
0
 public async Task <ActionResult <MFModels.partner> > GetPartner(MFWebApiOption option, CancellationToken token)
 => await mfWebApiProcessor.GetPartnersAsync(option, token);
Example #10
0
 public async Task <ActionResult <bool> > PatchBillings(MFWebApiOption option, CancellationToken token)
 => await mfWebApiProcessor.PatchBillings(option, token);
Example #11
0
 public async Task <ActionResult <bool> > ValidateToken(MFWebApiOption option, CancellationToken token)
 => await mfWebApiProcessor.ValidateToken(option, token);
Example #12
0
 public async Task <ActionResult <MFModels.Office> > GetOffice(MFWebApiOption option, CancellationToken token)
 => await mfWebApiProcessor.GetOfficesAsync(option, token);
Example #13
0
 public async Task <ActionResult <IEnumerable <MFModels.billing> > > GetBillings(MFWebApiOption option, CancellationToken token)
 => (await mfWebApiProcessor.GetBillingsAsync(option, token)).ToArray();
Example #14
0
 public async Task <ActionResult <int> > Save(MFWebApiOption option, CancellationToken token)
 => await mfWebApiProcessor.SaveSettingAsync(option, token);