Ejemplo n.º 1
0
 public async Task <GetUsageResponse> Get(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.Usage.Get());
     }
 }
 public async Task <ListDomainWhitelistResponse> List(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.DomainWhitelist.List());
     }
 }
Ejemplo n.º 3
0
 public async Task <ApiKeyResponse> Update(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.ApiKeyApi.Update());
     }
 }
Ejemplo n.º 4
0
 public async Task <ListUsageResponse> List(ListUsageRequest request, AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.Usage.List(request));
     }
 }
 public async Task<BillingAddressResponse> Get(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return await api.BillingAddress.Get();
     }
 }
Ejemplo n.º 6
0
        public async static Task <GetUsageResponse> Get(GetAddesssApi api, string path,
                                                        AdminKey adminKey, int day, int month, int year)
        {
            var fullPath = $"{path}{day}/{month}/{year}";

            return(await Get(api, fullPath, adminKey));
        }
 public async Task <TestWebhookResponse> Test(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.FirstLimitReachedWebhook.Test());
     }
 }
Ejemplo n.º 8
0
 public async Task <SubscriptionResponse> Subscription(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.Subscription.Get());
     }
 }
Ejemplo n.º 9
0
 public async Task <AddWebhookResponse> Add(AddWebhookRequest request, AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.PaymentFailedWebhook.Add(request));
     }
 }
 public async Task <GetInvoiceCCResponse> Get(GetInvoiceCCRequest request, AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.InvoiceCC.Get(request));
     }
 }
 public async Task <ListWebhookResponse> List(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.ExpiredWebhook.List());
     }
 }
 public async Task <DistanceResponse> Get(DistanceRequest request, AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.Distance.Get(request));
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Генерируем новый ключ для оператора.
        /// </summary>
        /// <returns></returns>
        private async Task <IActionResult> GenerateKey()
        {
            string hash = GeneralFunction.GenerateHash();

            if (hash != null)
            {
                using (MarketBotDbContext db = new MarketBotDbContext())
                {
                    AdminKey key = new AdminKey {
                        DateAdd = DateTime.Now, Enable = false, KeyValue = hash
                    };
                    db.AdminKey.Add(key);

                    if (db.SaveChanges() > 0)
                    {
                        await SendMessage(new BotMessage { TextMessage = "Пользователь который должен получить права оператора должен ввести следующую команду:" + Bot.BotMessage.NewLine() + Bot.BotMessage.Italic("/key " + key.KeyValue) });

                        return(OkResult);
                    }

                    else
                    {
                        return(NotFoundResult);
                    }
                }
            }

            else
            {
                return(NotFoundResult);
            }
        }
 public async Task <GetWebhookResponse> Get(GetWebhookRequest request, AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.ExpiredWebhook.Get(request));
     }
 }
Ejemplo n.º 15
0
 public async Task <AddPermissionResponse> Add(AddPermissionRequest request, AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.Permission.Add(request));
     }
 }
 public async Task <ListInvoiceCCResponse> List(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, httpClient))
     {
         return(await api.InvoiceCC.List());
     }
 }
Ejemplo n.º 17
0
 public async Task <ListPermissionResponse> List(AdminKey adminKey = null, HttpClient httpClient = null)
 {
     using (var api = new GetAddesssApi(adminKey ?? AdminKey, HttpClient ?? httpClient))
     {
         return(await api.Permission.List());
     }
 }
Ejemplo n.º 18
0
        protected AdminApiBase(AdminKey adminKey, GetAddesssApi api) : base(api)
        {
            if (adminKey == null)
            {
                throw new ArgumentNullException(nameof(adminKey));
            }

            AdminKey = adminKey;
        }
Ejemplo n.º 19
0
        public async static Task <GetInvoiceResponse> Get(GetAddesssApi api, string path,
                                                          AdminKey adminKey, GetInvoiceRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var fullPath = $"{path}{request.Number}";

            return(await GetInternal(api, fullPath, adminKey, request.Number));
        }
Ejemplo n.º 20
0
        public async static Task <ListUsageResponse> List(GetAddesssApi api, string path,
                                                          AdminKey adminKey, ListUsageRequest request)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var fullPath = $"{path}/from/{request.From.Day}/{request.From.Month}/{request.From.Year}/To/{request.To.Day}/{request.To.Month}/{request.To.Year}";

            return(await List(api, fullPath, adminKey));
        }
Ejemplo n.º 21
0
 internal Hashgraph.TopicInfo ToTopicInfo()
 {
     return(new Hashgraph.TopicInfo
     {
         Memo = Memo,
         RunningHash = RunningHash.ToArray(),
         SequenceNumber = SequenceNumber,
         Expiration = ExpirationTime.ToDateTime(),
         Administrator = AdminKey?.ToEndorsement(),
         Participant = SubmitKey?.ToEndorsement(),
         AutoRenewPeriod = AutoRenewPeriod.ToTimeSpan(),
         RenewAccount = AutoRenewAccount?.ToAddress()
     });
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Добавить нового оператора
        /// </summary>
        /// <param name="KeyId"></param>
        /// <returns></returns>
        private async Task <IActionResult> AddNewOpearator(AdminKey adminKey)
        {
            using (MarketBotDbContext db = new MarketBotDbContext())
            {
                var admin = db.Admin.Where(a => a.FollowerId == FollowerId && a.Enable).Include(a => a.AdminKey).Include(a => a.Follower).FirstOrDefault();

                Admin adminnew = new Admin
                {
                    AdminKeyId   = adminKey.Id,
                    FollowerId   = FollowerId,
                    DateAdd      = DateTime.Now,
                    NotyfiActive = true,
                    Enable       = true,
                };


                if (admin != null)
                {
                    return(await SendAdminControlPanelMsg());
                }

                else
                {
                    Admin NewAdmin = new Admin
                    {
                        FollowerId   = FollowerId,
                        DateAdd      = DateTime.Now,
                        AdminKeyId   = adminKey.Id,
                        Enable       = true,
                        NotyfiActive = true
                    };

                    db.Admin.Add(NewAdmin);
                    adminKey.Enable = true;
                    if (db.SaveChanges() > 0)
                    {
                        string meessage = "Зарегистрирован новый оператор системы: " + db.Follower.Where(f => f.Id == FollowerId).FirstOrDefault().FirstName
                                          + Bot.BotMessage.NewLine() + "Ключ: " + adminKey.KeyValue;
                        await SendMessage(BotOwner, new BotMessage { TextMessage = meessage });

                        return(await SendAdminControlPanelMsg());
                    }
                    else
                    {
                        return(OkResult);
                    }
                }
            }
        }
Ejemplo n.º 23
0
 internal Hashgraph.ContractInfo ToContractInfo()
 {
     return(new Hashgraph.ContractInfo
     {
         Contract = ContractID.ToAddress(),
         Address = AccountID.ToAddress(),
         SmartContractId = ContractAccountID,
         Administrator = AdminKey?.ToEndorsement(),
         Expiration = ExpirationTime.ToDateTime(),
         RenewPeriod = AutoRenewPeriod.ToTimeSpan(),
         Size = Storage,
         Memo = Memo,
         Balance = Balance,
         Tokens = TokenRelationships.ToBalances(),
         Deleted = Deleted
     });
 }
Ejemplo n.º 24
0
        private AdminKey AddOwnerKey(string key)
        {
            if (db == null)
            {
                db = new MarketBotDbContext();
            }

            AdminKey adminKey = new AdminKey
            {
                DateAdd  = DateTime.Now,
                Enable   = true,
                KeyValue = key
            };

            db.AdminKey.Add(adminKey);
            db.SaveChanges();
            return(adminKey);
        }
Ejemplo n.º 25
0
        public async Task GetAddress2()
        {
            var adminKey = new AdminKey("Your Admin Key");

            using (var api = new GetAddesssApi(adminKey))
            {
                var result = await api.Usage.Get();

                if (result.IsSuccess)
                {
                    var successfulResult = (GetUsageResponse.Success)result;

                    var count = successfulResult.Usage.Count;

                    var limit1 = successfulResult.Usage.Limit1;

                    var limit2 = successfulResult.Usage.Limit2;
                }
            }
        }
        private async Task GetAddressExpiredWebhookTest(AdminKey adminKey, IWebhookService getAddressExpiredWebhook)
        {
            var addResult = await getAddressExpiredWebhook.Add("https://enow375xiqy9k.x.pipedream.net/");

            Assert.IsTrue(addResult.IsSuccess);

            var getResult = await getAddressExpiredWebhook.Get(addResult.SuccessfulResult.Id);

            Assert.IsTrue(getResult.IsSuccess);

            var listResult = await getAddressExpiredWebhook.List();

            Assert.IsTrue(listResult.IsSuccess && listResult.SuccessfulResult.Webhooks.Any());

            var testResult = await getAddressExpiredWebhook.Test();

            Assert.IsTrue(testResult.IsSuccess);

            var removeResult = await getAddressExpiredWebhook.Remove(addResult.SuccessfulResult.Id);

            Assert.IsTrue(removeResult.IsSuccess);
        }
Ejemplo n.º 27
0
        public static Admin InsertAdmin(int FollowerId, AdminKey adminKey)
        {
            MarketBotDbContext db = new MarketBotDbContext();

            try
            {
                Admin NewAdmin = new Admin
                {
                    FollowerId   = FollowerId,
                    DateAdd      = DateTime.Now,
                    AdminKeyId   = adminKey.Id,
                    Enable       = true,
                    NotyfiActive = true
                };

                db.Admin.Add(NewAdmin);

                adminKey.Enable = true;

                db.Update <AdminKey>(adminKey);

                db.SaveChanges();

                NewAdmin.Follower = db.Follower.Find(FollowerId);

                return(NewAdmin);
            }

            catch
            {
                return(null);
            }

            finally
            {
                db.Dispose();
            }
        }
Ejemplo n.º 28
0
 internal Hashgraph.TokenInfo ToTokenInfo()
 {
     return(new Hashgraph.TokenInfo
     {
         Token = TokenId.ToAddress(),
         Symbol = Symbol,
         Name = Name,
         Treasury = Treasury.ToAddress(),
         Circulation = TotalSupply,
         Decimals = Decimals,
         Administrator = AdminKey?.ToEndorsement(),
         GrantKycEndorsement = KycKey?.ToEndorsement(),
         SuspendEndorsement = FreezeKey?.ToEndorsement(),
         ConfiscateEndorsement = WipeKey?.ToEndorsement(),
         SupplyEndorsement = SupplyKey?.ToEndorsement(),
         TradableStatus = (Hashgraph.TokenTradableStatus)DefaultFreezeStatus,
         KycStatus = (Hashgraph.TokenKycStatus)DefaultKycStatus,
         Expiration = Expiry.ToDateTime(),
         RenewPeriod = AutoRenewPeriod?.ToTimeSpan(),
         RenewAccount = AutoRenewAccount?.ToAddress(),
         Deleted = Deleted
     });
 }
Ejemplo n.º 29
0
        public static AdminKey InsertAdminKey(string Hash, bool Enable = false)
        {
            MarketBotDbContext db = new MarketBotDbContext();

            try
            {
                AdminKey key = new AdminKey {
                    DateAdd = DateTime.Now, Enable = false, KeyValue = Hash
                };
                db.AdminKey.Add(key);
                db.SaveChanges();
                return(key);
            }

            catch
            {
                return(null);
            }

            finally
            {
                db.Dispose();
            }
        }
Ejemplo n.º 30
0
 public UsageService(AdminKey adminKey, HttpClient httpClient = null)
 {
     AdminKey   = adminKey ?? throw new System.ArgumentNullException(nameof(adminKey));
     HttpClient = httpClient;
 }