public UploadController(WebShareContext dbContext, UploadDataService dataService, WebhookService webhookService, GeneratorService generatorService) { DbContext = dbContext; DataService = dataService; WebhookService = webhookService; GeneratorService = generatorService; }
private async Task CreateAppUninstalledWebhook(ShopifyStore shopifyStore) { if (shopifyStore == null) { throw new NullReferenceException(); } var shopifyWebhookService = new WebhookService(shopifyStore.Shop, shopifyStore.AccessToken); try { await shopifyWebhookService.CreateAsync(new Webhook { Address = GetWebhookAddress(ShopifyWebhookTopic.AppUninstalled, shopifyStore.Id), CreatedAt = DateTime.Now, Format = ShopifyConstants.Format, Topic = ShopifyWebhookTopic.AppUninstalled }); } catch (ShopifyException e) { string message = $"Couldn't create {ShopifyWebhookTopic.AppUninstalled} webhook for {shopifyStore.Shop}. Reason: " + string.Join(", ", e.Errors); _logger.Error(message); } }
public async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "broadcaster")] HttpRequest req, ILogger log) { TelemetryClient.TrackEvent("Stop"); using (LoggerService.Init(log)) { ConfigurationModel config = ConfigurationService.GetConfiguration(); try { AzureMediaServicesClient client = await AuthenticationService.GetClientAsync(config); InputRequestService inputRequestService = new InputRequestService(client, config); StopController stopController = new StopController(client, config); InputRequestModel inputModel = await inputRequestService.GetInputRequestModelAsync(req); StatusChangeOutputModel outputModel = await stopController.StopServicesAsync(inputModel); await WebhookService.CallWebhookAsync(config.WebhookStartSuccess, ActionEnum.Stop, outputModel.Status.Summary.Name); return(SuccessResponseService.CreateResponse(outputModel)); } catch (AppException e) { return(await ReportErrorAsync(config, e)); } catch (Exception e) { return(await ReportErrorAsync(config, e)); } } }
public async Task <string> Allhooks() { var service = new WebhookService(shopifyurl, token); var webhooks = await service.ListAsync(); return(""); }
async Task CleverbotHandlerAsync(SocketMessage Message, GuildModel Config) { string UserMessage = Message.Content.ToLower().Replace("valerie", string.Empty); if (!Message.Content.ToLower().StartsWith("valerie") || string.IsNullOrWhiteSpace(UserMessage) || Message.Channel.Id != Config.CleverbotWebhook.TextChannel) { return; } Response CleverResponse; if (!CleverbotTracker.ContainsKey(Config.CleverbotWebhook.TextChannel)) { CleverResponse = await ConfigHandler.Cookie.Cleverbot.TalkAsync(UserMessage); CleverbotTracker.Add(Config.CleverbotWebhook.TextChannel, CleverResponse); } else { CleverbotTracker.TryGetValue(Config.CleverbotWebhook.TextChannel, out CleverResponse); CleverResponse = await ConfigHandler.Cookie.Cleverbot.TalkAsync(UserMessage); CleverbotTracker[Config.CleverbotWebhook.TextChannel] = CleverResponse; } await WebhookService.SendMessageAsync(new WebhookOptions { Message = CleverResponse.CleverOutput, Name = "Cleverbot", Webhook = Config.CleverbotWebhook }); }
private static async Task <HttpResponseMessage> ReportErrorAsync(ConfigurationModel config, Exception exception) { LoggerService.CaptureException(exception); await WebhookService.CallWebhookAsync(config.WebhookStartFailure, ActionEnum.Start, ResourceStatusEnum.Error); return(ErrorResponseService.CreateResponse(exception)); }
public async Task AddHookValid() { var config = new TriggrConfig(); config.Url = "http://www.triggr.com/"; config.Webhook = true; var repo = new Data.Repository(); repo.Token = "1"; repo.Url = "http://github.com/lyzerk/TriggrTestProject"; repo.OwnerName = "lyzerk"; repo.Name = "TriggrTestProject"; var mockResult = new RepositoryHook(1, null, null, null, DateTimeOffset.Now, DateTimeOffset.Now, null, null, false, null); var mockConfig = new Mock <IOptions <TriggrConfig> >(); var mockClient = new Mock <GithubWrapper>(); mockConfig.Setup(i => i.Value).Returns(config); mockClient.Setup(i => i.CreateWebhook(repo.OwnerName, repo.Name, config.Url + "GithubWebhook/HandlerForPush", "1")) .ReturnsAsync(mockResult); WebhookService service = new WebhookService(null, mockConfig.Object, mockClient.Object); var result = await service.AddHookAsync(repo); Assert.True(result); Assert.True(repo.WebHook); Assert.NotNull(repo.WebHookId); }
public async Task <bool> CreateWebhook(string domain, string token) { bool isSuccess = false; try { var serviceWebhook = new WebhookService(domain, token); var hook = new Webhook() { Address = ApplicationEngine.Address_ChargeResult_UnInstall, CreatedAt = DateTime.Now, Format = "json", Topic = "app/uninstalled", }; hook = await serviceWebhook.CreateAsync(hook); var shopUpdateWebhook = new Webhook() { Address = ApplicationEngine.Url_Path + "/api/services/updateshopdetails", CreatedAt = DateTime.Now, Format = "json", Topic = "shop/update", }; shopUpdateWebhook = await serviceWebhook.CreateAsync(shopUpdateWebhook); isSuccess = true; } catch (ShopifyException e) { Log.Error("Error on creating webhook", e); throw e; } return(isSuccess); }
public NewsController(ILogger <NewsController> logger) { this.logger = logger; configurationService = new ConfigurationService(CONFIG_FILE_PATH); parseService = new ParseService(); webhookService = new WebhookService(configurationService.GetConfig(WEBHOOK_TOKEN_KEY)); }
public async Task Can_Post_Simple_Error_Message() { // Arrange IWebhookService webhookService = new WebhookService(); // Act bool result = await webhookService.PostAsync("https://webhooks.gitter.im/e/cdf519d88a935d54a6d2", "A simple error message", MessageLevel.Error); // Assert Assert.IsTrue(result); }
internal async Task UserLeftAsync(SocketGuildUser User) { var Config = GuildHandler.GetGuild(User.Guild.Id); await WebhookService.SendMessageAsync(new WebhookOptions { Name = Client.CurrentUser.Username, Webhook = Config.LeaveWebhook, Message = !Config.LeaveMessages.Any() ? $"**{User.Username}** abandoned us! {Emotes.Squint}" : StringHelper.Replace(Config.LeaveMessages[Random.Next(0, Config.LeaveMessages.Count)], User.Guild.Name, User.Username) }); }
public EventHelper(Random random, GuildHelper GH, DiscordSocketClient client, ConfigHandler CH, MethodHelper MH, WebhookService WS) { Client = client; Random = random; GuildHelper = GH; ConfigHandler = CH; MethodHelper = MH; WebhookService = WS; XPUserList = new Dictionary <ulong, DateTime>(); CleverbotTracker = new Dictionary <ulong, Response>(); }
private static GitterChatMessageResult PostToIncomingWebHook(ICakeContext context, string message, GitterChatMessageSettings messageSettings) { context.Verbose("Posting to incoming webhook {0}...", string.Concat(messageSettings.IncomingWebHookUrl.TrimEnd('/').Reverse().SkipWhile(c => c != '/').Reverse())); var gitterWebHookService = new WebhookService(); var result = gitterWebHookService.PostAsync(messageSettings.IncomingWebHookUrl, message, messageSettings.MessageLevel == GitterMessageLevel.Error ? MessageLevel.Error : MessageLevel.Info); var parsedResult = new GitterChatMessageResult(result.Result, DateTime.UtcNow.ToString("u"), string.Empty); context.Debug("Result parsed: {0}", parsedResult); return(parsedResult); }
public EventsHandler(GuildHandler guild, ConfigHandler config, DiscordSocketClient client, CommandService command, Random random, GuildHelper guildH, WebhookService webhookS, EventHelper eventHelper) { Client = client; Random = random; GuildHandler = guild; GuildHelper = guildH; ConfigHandler = config; EventHelper = eventHelper; CommandService = command; WebhookService = webhookS; CancellationToken = new CancellationTokenSource(); }
private static void CheckMatches(Action <string, bool> log) { var newMatchesFound = 0; var start = DateTime.Now; try { var ids = ServiceManager.LastMatchService.GetTrackedIds(); foreach (var id in ids) { var player = ServiceManager.PlayerService.GetPlayer(id); var lastMatch = ServiceManager.LastMatchService.GetLastMatch(id); foreach (var match in player.LastMatches) { if (match.Id > lastMatch) { newMatchesFound++; log.Invoke($"Discovered new match for player {player.Name}.", false); log.Invoke(Helper.FormatPlayer(player.Name, match), false); WebhookService.PostMessage(Helper.FormatPlayer(player.Name, match), log); ServiceManager.LastMatchService.SetLastMatch(id, match.Id); ServiceManager.LastMatchService.SetName(id, player.Name); } } } } catch (Exception e) { newMatchesFound = -1; try { WebhookService.PostMessage($"{e.GetType().FullName}: {e.Message}", log, true); WebhookService.PostMessage($"```{e.StackTrace}```", log, true); } catch (Exception ex) { log.Invoke($"Problem posting error message to discord: {e.GetType().FullName}: {ex.Message}. StackTrace: {ex.StackTrace}", true); } throw; } UpdateJSON(newMatchesFound, start, DateTime.Now); }
public OpenpayAPI( string api_key, string merchant_id,bool production = false) { this.httpClient = new OpenpayHttpClient(api_key, merchant_id, production); CustomerService = new CustomerService(this.httpClient); CardService = new CardService(this.httpClient); BankAccountService = new BankAccountService(this.httpClient); ChargeService = new ChargeService(this.httpClient); PayoutService = new PayoutService(this.httpClient); TransferService = new TransferService(this.httpClient); FeeService = new FeeService(this.httpClient); PlanService = new PlanService(this.httpClient); SubscriptionService = new SubscriptionService(this.httpClient); OpenpayFeesService = new OpenpayFeesService(this.httpClient); WebhooksService = new WebhookService (this.httpClient); }
public async Task <string> CreateUninstallHook(string shopifyurl, string token) { var service = new WebhookService(shopifyurl, token); var webhooks = await service.ListAsync(); if (webhooks.Items?.FirstOrDefault() != null) { foreach (var item in webhooks.Items) { long itemid = Convert.ToInt64(item.Id); await service.DeleteAsync(itemid); } } return(""); }
public void IsSupportInvalid() { var config = new TriggrConfig(); config.Url = "http://www.triggr.com/"; config.Webhook = true; var mock = new Mock <IOptions <TriggrConfig> >(); mock.Setup(i => i.Value).Returns(config); WebhookService service = new WebhookService(null, mock.Object, null); Assert.False(service.IsSupport("http://bitbucket.com/lyzerk/TriggrTestProject")); }
public void WebhookUrlWithEmptyString() { var config = new TriggrConfig(); config.Url = string.Empty; config.Webhook = true; var mock = new Mock <IOptions <TriggrConfig> >(); mock.Setup(i => i.Value).Returns(config); WebhookService service = new WebhookService(null, mock.Object, null); Action action = () => service.WebhookUrl(); Assert.ThrowsAny <UriFormatException>(action); }
public OpenpayAPI(string api_key, string merchant_id, bool production = false) { this.httpClient = new OpenpayHttpClient(api_key, merchant_id, production); CustomerService = new CustomerService(this.httpClient); CardService = new CardService(this.httpClient); BankAccountService = new BankAccountService(this.httpClient); ChargeService = new ChargeService(this.httpClient); PayoutService = new PayoutService(this.httpClient); TransferService = new TransferService(this.httpClient); FeeService = new FeeService(this.httpClient); PlanService = new PlanService(this.httpClient); SubscriptionService = new SubscriptionService(this.httpClient); OpenpayFeesService = new OpenpayFeesService(this.httpClient); WebhooksService = new WebhookService(this.httpClient); PayoutReportService = new PayoutReportService(this.httpClient); MerchantService = new MerchantService(this.httpClient); }
public void WebhookUrlWithValid() { var config = new TriggrConfig(); config.Url = "http://www.triggr.com/"; config.Webhook = true; var mock = new Mock <IOptions <TriggrConfig> >(); mock.Setup(i => i.Value).Returns(config); WebhookService service = new WebhookService(null, mock.Object, null); var result = service.WebhookUrl(); Assert.Equal(config.Url + "GithubWebhook/HandlerForPush", result); }
public void WebhookUrlWithLocalhostAndNoProtocol() { var config = new TriggrConfig(); config.Url = "localhost"; config.Webhook = true; var mock = new Mock <IOptions <TriggrConfig> >(); mock.Setup(i => i.Value).Returns(config); WebhookService service = new WebhookService(null, mock.Object, null); var result = service.WebhookUrl(); Assert.Equal($"http://{config.Url}/GithubWebhook/HandlerForPush", result); }
internal async Task UserJoinedAsync(SocketGuildUser User) { var Config = GuildHandler.GetGuild(User.Guild.Id); await WebhookService.SendMessageAsync(new WebhookOptions { Name = Client.CurrentUser.Username, Webhook = Config.JoinWebhook, Message = !Config.JoinMessages.Any() ? $"**{User.Username}** is here to rock our world! Yeah, baby!" : StringHelper.Replace(Config.JoinMessages[Random.Next(0, Config.JoinMessages.Count)], User.Guild.Name, User.Mention) }); var Role = User.Guild.GetRole(Config.Mod.JoinRole); if (Role != null) { await User.AddRoleAsync(Role).ConfigureAwait(false); } }
/// <summary> /// Creates the webhook asynchronously. /// </summary> /// <param name="myShopifyDomain">The myshopify URL.</param> /// <param name="shopifyAccessToken">The shopify access token.</param> /// <param name="webhook">Valid webhook object.</param> /// <returns></returns> public async Task <ShopifyWebhookObject> CreateWebhookAsync(string myShopifyDomain, string shopifyAccessToken, ShopifyWebhookObject webhook) { _CheckmyShopifyDomain(myShopifyDomain); _CheckShopAccessToken(shopifyAccessToken); if (webhook == null) { _Logger.LogError($"Web hook object cannot be null for shop {myShopifyDomain}"); throw new Exception("Web hook object cannot be null"); } _Logger.LogInformation($"Sending request to create webhook for '{myShopifyDomain}' on topic '{webhook.Topic}'"); WebhookService service = new WebhookService(myShopifyDomain, shopifyAccessToken); var data = await service.CreateAsync(new Webhook() { Address = webhook.Address, CreatedAt = webhook.CreatedAt, Fields = webhook.Fields, Format = webhook.Format, MetafieldNamespaces = webhook.MetafieldNamespaces, Topic = webhook.Topic, UpdatedAt = webhook.UpdatedAt }); if (data == null) { _Logger.LogError("Failed creating webhook. Server response was NULL."); throw new Exception("Failed creating webhook.Server responded NULL."); } else { var ret = new ShopifyWebhookObject() { Address = data.Address, CreatedAt = data.CreatedAt, Fields = data.Fields, Format = data.Format, MetafieldNamespaces = data.MetafieldNamespaces, Topic = data.Topic, UpdatedAt = data.UpdatedAt, Id = data.Id }; _Logger.LogInformation($"Done creating webhook for '{myShopifyDomain}' on topic '{webhook.Topic}' where id = '{ret.Id}'"); return(ret); } }
public IContext(IDiscordClient ClientParam, IUserMessage MessageParam, IServiceProvider ServiceProvider) { Client = ClientParam; Message = MessageParam; User = MessageParam.Author; Channel = MessageParam.Channel; Guild = (MessageParam.Channel as IGuildChannel).Guild; Random = ServiceProvider.GetRequiredService <Random>(); HttpClient = ServiceProvider.GetRequiredService <HttpClient>(); GuildHelper = ServiceProvider.GetRequiredService <GuildHelper>(); RedditService = ServiceProvider.GetRequiredService <RedditService>(); GuildHandler = ServiceProvider.GetRequiredService <GuildHandler>(); Config = ServiceProvider.GetRequiredService <ConfigHandler>().Config; MethodHelper = ServiceProvider.GetRequiredService <MethodHelper>(); ConfigHandler = ServiceProvider.GetRequiredService <ConfigHandler>(); WebhookService = ServiceProvider.GetRequiredService <WebhookService>(); Session = ServiceProvider.GetRequiredService <IDocumentStore>().OpenSession(); Server = ServiceProvider.GetRequiredService <GuildHandler>().GetGuild(Guild.Id); }
public async Task AddHookInvalid() { var config = new TriggrConfig(); config.Url = "http://www.triggr.com/"; config.Webhook = true; var mock = new Mock <IOptions <TriggrConfig> >(); mock.Setup(i => i.Value).Returns(config); WebhookService service = new WebhookService(null, mock.Object, null); var repo = new Data.Repository(); repo.Token = "1"; repo.Url = "http://githu1b.com/lyzerk/TriggrTestProject"; var result = await service.AddHookAsync(repo); Assert.False(result); }
public async Task <bool> CreateWebHook(string shopifyurl, string token, string Address, string Topic) { try { var service = new WebhookService(shopifyurl, token); Webhook hook = new Webhook() { Address = Address, // Address CreatedAt = DateTime.Now, //Fields = new List<string>() { "id", "updated_at","FirstName" }, Format = "json", //MetafieldNamespaces = new List<string>() { "metafield1", "metafield2" }, Topic = Topic, // Topic }; hook = await service.CreateAsync(hook); } catch (Exception ex) { return(false); } return(true); }
private async Task CreateFulfillmentsCreateWebhook(ShopifyStore shopifyStore) { var shopifyWebhookService = new WebhookService(shopifyStore.Shop, shopifyStore.AccessToken); try { await shopifyWebhookService.CreateAsync(new Webhook { Address = GetWebhookAddress(ShopifyWebhookTopic.FulfillmentsCreate, shopifyStore.Id), CreatedAt = DateTime.Now, Format = ShopifyConstants.Format, Topic = ShopifyWebhookTopic.FulfillmentsCreate }); } catch (ShopifyException e) { string message = $"Couldn't create {ShopifyWebhookTopic.FulfillmentsCreate} webhook for {shopifyStore.Shop}. Reason: " + string.Join(", ", e.Errors); _logger.Error(message); } }
public BitGoClient(BitGoNetwork network, string token = null) { _network = network; _baseUrl = new Uri(network == BitGoNetwork.Main ? MainBaseUrl : TestBaseUrl); if (!string.IsNullOrEmpty(token)) { _token = ConvertToSecureString(token); } _sjcl = new SjclManaged(); Keychains = new KeychainService(this); Wallets = new WalletService(this); WalletAddresses = new WalletAddressService(this); User = new UserService(this); Labels = new LabelService(this); Market = new MarketService(this); Transactions = new TransactionService(this); Instant = new InstantService(this); Billing = new BillingService(this); Webhooks = new WebhookService(this); PendingApprovals = new PendingApprovalService(this); }
/// <summary> /// POSTメソッド /// </summary> /// <param name="requestToken">リクエストトークン</param> /// <returns>常にステータス200のみを返す</returns> public async Task <HttpResponseMessage> Post(JToken requestToken) { Trace.TraceInformation("Webhook API Start"); // Webhook Serviceの実行 await WebhookService.Execute( // Webhook Serviceの設定 new WebhookServiceConfig() { RequestJToken = requestToken, RequestHeaders = this.Request.Headers, RequestContent = this.Request.Content, // 署名の検証は行わない IsExecuteVerifySign = false, // ロングタームチャンネルアクセストークンを使用する IsUseLongTermChannelAccessToken = true, // フォローイベント FollowEventHandler = async(channelAccessToken, replyToken) => await this.ExecuteFollowEvent(channelAccessToken, replyToken), // 参加イベント JoinEventHandler = async(channelAccessToken, replyToken) => await this.ExecuteJoinEvent(channelAccessToken, replyToken), // テキストイベント TextMessageEventHandler = async(channelAccessToken, source, replyToken, text) => await this.ExecuteTextMessageEvent(channelAccessToken, source, replyToken, text) } ).ConfigureAwait(false); Trace.TraceInformation("Webhook API End"); return(new HttpResponseMessage(HttpStatusCode.OK)); }
public ShortUrlController(WebShareContext dbContext, GeneratorService generatorService, WebhookService webhookService) { DbContext = dbContext; GeneratorService = generatorService; WebhookService = webhookService; }