/// <summary> /// Create a new webhook subscription /// </summary> /// <remarks> /// Client Credentials Flow required permissions: Webhooks or Webhooks.Write. /// /// Required permissions: Webhooks.Create. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <WebhookDto> PostAsync(this IWebhooks operations, WebhookDto body = default(WebhookDto), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.PostWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create a new webhook subscription /// </summary> /// <remarks> /// Required permissions: Webhooks.Create. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='webhookDto'> /// The entity to post /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <WebhookDto> PostAsync(this IWebhooks operations, WebhookDto webhookDto, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { using (var _result = await operations.PostWithHttpMessagesAsync(webhookDto, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
protected override void ProcessRecord() { var dto = new WebhookDto { Url = Url, Secret = Secret, Enabled = Enabled ?? true, AllowInsecureSsl = AllowInsecureSsl.IsPresent ? AllowInsecureSsl.ToBool() : false, }; if (ParameterSetName == AllEventsSet) { dto.Events = new List <WebhookEventDto>(); dto.SubscribeToAllEvents = true; } else { dto.Events = Events.Select(e => new WebhookEventDto { EventType = e }).ToList(); dto.SubscribeToAllEvents = false; } var webhook = Api_19_4.Webhooks.Post(dto); WriteObject(Webhook.FromDto(webhook)); }
internal static Webhook FromDto(WebhookDto dto) { return(new Webhook { Id = dto.Id, Url = dto.Url, Secret = dto.Secret, Enabled = dto.Enabled, AllowInsecureSsl = dto.AllowInsecureSsl, Events = dto.Events?.ToArray(), AllEvents = dto.SubscribeToAllEvents, }); }
public static Webhook ToModel(this WebhookDto dto) { return(new Webhook { Id = dto.Id, Name = dto.Name, Description = dto.Description, Event = dto.Event, Status = dto.Status, RequestList = dto.RequestList?.Select(x => x.ToModel()).ToArray(), TryCount = dto.TryCount, MembershipId = dto.MembershipId, Sys = dto.Sys?.ToModel() }); }
public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "v1/webhook")] WebhookDto webhookDto, ILogger log ) { try { log.LogInformation("[Function - Process Request]"); var cityName = webhookDto?.City; var response = await _weatherAgent.GetInformationByCity(cityName); var formattedResponse = $"No dia {response.Results.Date} às {response.Results.Time} a temperatura marca {response.Results.Temp} graus. " + $"Está {response.Results.Description.ToLower()}!"; return(new OkObjectResult(new { retorno = formattedResponse })); } catch (Exception ex) { log.LogError("[Function - Process Failed]", ex.Message); return(new StatusCodeResult(StatusCodes.Status500InternalServerError)); } }
internal static Webhook FromDto(WebhookDto dto) => dto.To <Webhook>();
/// <summary> /// Update entity in EntitySet Webhooks /// </summary> /// <remarks> /// Required permissions: Webhooks.Edit. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='id'> /// key: Id /// </param> /// <param name='webhookDto'> /// The entity to patch /// </param> public static WebhookDto PatchById(this IWebhooks operations, long id, WebhookDto webhookDto) { return(operations.PatchByIdAsync(id, webhookDto).GetAwaiter().GetResult()); }
/// <summary> /// Create a new webhook subscription /// </summary> /// <remarks> /// Required permissions: Webhooks.Create. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='webhookDto'> /// The entity to post /// </param> public static WebhookDto Post(this IWebhooks operations, WebhookDto webhookDto) { return(operations.PostAsync(webhookDto).GetAwaiter().GetResult()); }
/// <summary> /// Patches a webhook /// </summary> /// <remarks> /// Client Credentials Flow required permissions: Webhooks or Webhooks.Write. /// /// Required permissions: Webhooks.Edit. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='key'> /// </param> /// <param name='body'> /// </param> public static WebhookDto PatchById(this IWebhooks operations, long key, WebhookDto body = default(WebhookDto)) { return(operations.PatchByIdAsync(key, body).GetAwaiter().GetResult()); }
/// <summary> /// Create a new webhook subscription /// </summary> /// <remarks> /// Client Credentials Flow required permissions: Webhooks or Webhooks.Write. /// /// Required permissions: Webhooks.Create. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// </param> public static WebhookDto Post(this IWebhooks operations, WebhookDto body = default(WebhookDto)) { return(operations.PostAsync(body).GetAwaiter().GetResult()); }
public IActionResult Index([FromQuery(Name = "hash")] string hash, [FromBody] WebhookDto data) { if (string.IsNullOrEmpty(hash) || string.IsNullOrEmpty(data?.OrderNo) || !SecurityTools.VerifyPaymentHash(_jeebSetting.ApiKey, data.OrderNo, hash)) { return(Unauthorized()); } switch (data.State) { case Constants.PaymentState.PendingTransaction: // It means that Jeeb is waiting for a transaction on any given payment details. break; case Constants.PaymentState.PendingConfirmation: // It means that a transaction on a specific payment detail has occurred and Jeeb is waiting for network/external confirmations. break; case Constants.PaymentState.Completed: // It means that a transaction has confirmed and we can seal the payment. try { var result = _paymentClient.Seal(new SealDto { Token = data.Token }); if (result.IsSealed) { // Payment has been sealed by the merchant successfully so we are safe to close the order. } else { throw new Exception("Unable to seal the payment"); } } catch (Exception e) { // Probably a double-spending attempt has occurred. For security reasons log the HTTP request details. Otherwise, we can skip. } break; case Constants.PaymentState.Expired: // No transaction has occurred. it was either canceled or expiration due has passed. Display the corresponding view. break; case Constants.PaymentState.Rejected: // A transaction has occurred but rejection conditions have met. break; case Constants.PaymentState.Failed: // Payment has been failed on Jeeb. please contact Jeeb's support team. break; default: throw new ArgumentOutOfRangeException(); } return(Ok()); // Always return OK. }