All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sinch.sdk.domains.numbers.api.v1.adapters.WebHooksService Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.sinch.sdk.domains.numbers.api.v1.adapters;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.sinch.sdk.core.exceptions.ApiMappingException;
import com.sinch.sdk.core.utils.databind.Mapper;
import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent;
import java.util.Map;

public class WebHooksService implements com.sinch.sdk.domains.numbers.api.v1.WebHooksService {
  private final NumbersWebhooksAuthenticationValidation authenticationChecker;

  public WebHooksService(NumbersWebhooksAuthenticationValidation authenticationChecker) {
    this.authenticationChecker = authenticationChecker;
  }

  @Override
  public boolean validateAuthenticationHeader(
      String secret, Map headers, String jsonPayload) {
    return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload);
  }

  @Override
  public NumberEvent parseEvent(String jsonPayload) throws ApiMappingException {

    try {
      return Mapper.getInstance().readValue(jsonPayload, NumberEvent.class);
    } catch (JsonProcessingException e) {
      throw new ApiMappingException(jsonPayload, e);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy