MessageMedia Webhooks SDK

Webhooks Management API allows you to manage your webhooks configuration. You can subscribe to one or several events, retrieve the webhooks, update them or even delete them if needed.

License

License

GroupId

GroupId

com.messagemedia.sdk
ArtifactId

ArtifactId

webhooks
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

MessageMedia Webhooks SDK
Webhooks Management API allows you to manage your webhooks configuration. You can subscribe to one or several events, retrieve the webhooks, update them or even delete them if needed.
Project URL

Project URL

http://github.com/messagemedia/webhooks-java-sdk
Project Organization

Project Organization

MessageMedia
Source Code Management

Source Code Management

https://github.com/messagemedia/webhooks-java-sdk

Download webhooks

How to add to project

<!-- https://jarcasting.com/artifacts/com.messagemedia.sdk/webhooks/ -->
<dependency>
    <groupId>com.messagemedia.sdk</groupId>
    <artifactId>webhooks</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.messagemedia.sdk/webhooks/
implementation 'com.messagemedia.sdk:webhooks:1.0.0'
// https://jarcasting.com/artifacts/com.messagemedia.sdk/webhooks/
implementation ("com.messagemedia.sdk:webhooks:1.0.0")
'com.messagemedia.sdk:webhooks:jar:1.0.0'
<dependency org="com.messagemedia.sdk" name="webhooks" rev="1.0.0">
  <artifact name="webhooks" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.messagemedia.sdk', module='webhooks', version='1.0.0')
)
libraryDependencies += "com.messagemedia.sdk" % "webhooks" % "1.0.0"
[com.messagemedia.sdk/webhooks "1.0.0"]

Dependencies

compile (9)

Group / Artifact Type Version
com.squareup.okhttp3 : okhttp jar 3.10.0
com.fasterxml.jackson.core : jackson-databind jar 2.9.0
com.fasterxml.jackson.core : jackson-core jar 2.9.0
com.fasterxml.jackson.core : jackson-annotations jar 2.9.0
org.apache.httpcomponents : httpasyncclient jar 4.0.1
org.apache.httpcomponents : httpclient jar 4.4.1
org.apache.httpcomponents : httpcore jar 4.4.1
org.apache.httpcomponents : httpmime jar 4.3.4
org.apache.httpcomponents : httpcore-nio jar 4.3.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

MessageMedia Webhooks Java SDK

Travis Build Status Pull Requests Welcome maven

The MessageMedia Webhooks allows you to subscribe to one or several events and when one of those events is triggered, an HTTP request is sent to the URL of your choice along with the message or payload. In simpler terms, it allows applications to "speak" to one another and get notified automatically when something new happens.

Webhooks Flow

Table of Contents

๐Ÿ” Authentication

Authentication is done via API keys. Sign up at https://developers.messagemedia.com/register/ to get your API keys.

Requests are authenticated using HTTP Basic Auth or HMAC. Provide your API key as the auth_user_name and API secret as the auth_password.

โ‰๏ธ Errors

Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The most common status codes are listed below.

HTTP Status Codes

Code Title Description
400 Invalid Request The request was invalid
401 Unauthorized Your API credentials are invalid
403 Disabled feature Feature not enabled
404 Not Found The resource does not exist
50X Internal Server Error An error occurred with our API

๐Ÿ“ฐ Information

Slack and Mailing List

If you have any questions, comments, or concerns, please join our Slack channel: https://developers.messagemedia.com/collaborate/slack/

Alternatively you can email us at: [email protected]

Bug reports

If you discover a problem with the SDK, we would like to know about it. You can raise an issue or send an email to: [email protected]

Contributing

We welcome your thoughts on how we could best provide you with SDKs that would simplify how you consume our services in your application. You can fork and create pull requests for any features you would like to see or raise an issue

โญ Installation

At present the jars are available from a public maven repository.

Use the following dependency in your project to grab via Maven:

<dependency>
    <groupId>com.messagemedia.sdk</groupId>
    <artifactId>webhooks</artifactId>
    <version>1.0.0</version>
</dependency>

๐ŸŽฌ Get Started

It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below.

Create a webhook

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.messagemedia.webhooks.MessageMediaWebhooksClient;
import com.messagemedia.webhooks.controllers.WebhooksController;
import com.messagemedia.webhooks.models.CreateWebhookRequest;

public class Main {

    public static void main(String[] args) throws Throwable {
        // Configuration parameters and credentials
        String basicAuthUserName = "API_KEY"; // The username to use with basic authentication
        String basicAuthPassword = "API_SECRET"; // The password to use with basic authentication

        MessageMediaWebhooksClient client = new MessageMediaWebhooksClient(basicAuthUserName, basicAuthPassword);

        WebhooksController webhooks = client.getWebhooks();

        String bodyValue = "{\"url\": \"https://webhook.com\"," +
                "\"method\": \"POST\"," +
                "\"encoding\": \"JSON\"," +
                "\"events\": [ \"RECEIVED_SMS\" ]," +
                "\"template\": \"{\\\"id\\\":\\\"$mtId\\\", \\\"status\\\":\\\"$statusCode\\\"}\"" +
                "}";

        ObjectMapper mapper = new ObjectMapper();
        CreateWebhookRequest body = mapper.readValue(bodyValue,new TypeReference<CreateWebhookRequest>(){});

        webhooks.createWebhook(body);
    }
}

Retrieve all webhooks

import com.fasterxml.jackson.core.type.TypeReference;
import com.messagemedia.webhooks.MessageMediaWebhooksClient;
import com.messagemedia.webhooks.controllers.WebhooksController;

public class Main {

    public static void main(String[] args) throws Throwable {
        // Configuration parameters and credentials
        String basicAuthUserName = "API_KEY"; // The username to use with basic authentication
        String basicAuthPassword = "API_SECRET"; // The password to use with basic authentication

        MessageMediaWebhooksClient client = new MessageMediaWebhooksClient(basicAuthUserName, basicAuthPassword);

        WebhooksController webhooks = client.getWebhooks();

        Integer page = 0;
        Integer pageSize = 0;

        String result = (webhooks.retrieveWebhook(page, pageSize).parseAsString());
        System.out.print(result);
    }
}

Update a webhook

You can get a webhook ID by looking at the id of each webhook created from the response of the above example.

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.messagemedia.webhooks.MessageMediaWebhooksClient;
import com.messagemedia.webhooks.controllers.WebhooksController;
import com.messagemedia.webhooks.models.UpdateWebhookRequest;

public class Main {

    public static void main(String[] args) throws Throwable {
        // Configuration parameters and credentials
        String basicAuthUserName = "API_KEY"; // The username to use with basic authentication
        String basicAuthPassword = "API_SECRET"; // The password to use with basic authentication

        MessageMediaWebhooksClient client = new MessageMediaWebhooksClient(basicAuthUserName, basicAuthPassword);

        WebhooksController webhooks = client.getWebhooks();

        String webhookId = "WEBHOOK_ID";

        String bodyValue = "{\"url\": \"https://myurl.com\"," +
                "\"method\": \"POST\"," +
                "\"encoding\": \"JSON\"," +
                "\"events\": [ \"ENROUTE_DR\" ]," +
                "\"template\": \"{\\\"id\\\":\\\"$mtId\\\", \\\"status\\\":\\\"$statusCode\\\"}\"" +
                "}";

        ObjectMapper mapper = new ObjectMapper();
        UpdateWebhookRequest body = mapper.readValue(bodyValue,new TypeReference<UpdateWebhookRequest>(){});

        webhooks.updateWebhook(webhookId, body);
    }
}

Delete a webhook

You can get a webhook ID by looking at the id of each webhook created from the response of the retrieve webhooks example.

import com.fasterxml.jackson.core.type.TypeReference;
import com.messagemedia.webhooks.MessageMediaWebhooksClient;
import com.messagemedia.webhooks.controllers.WebhooksController;

public class Main {

    public static void main(String[] args) throws Throwable {
        // Configuration parameters and credentials
        String basicAuthUserName = "API_KEY"; // The username to use with basic authentication
        String basicAuthPassword = "API_SECRET"; // The password to use with basic authentication

        MessageMediaWebhooksClient client = new MessageMediaWebhooksClient(basicAuthUserName, basicAuthPassword);

        WebhooksController webhooks = client.getWebhooks();

        String webhookId = "WEBHOOK_ID";

        webhooks.deleteWebhook(webhookId);
    }
}

๐Ÿ“• API Reference Documentation

Check out the full API documentation for more detailed information.

๐Ÿ˜• Need help?

Please contact developer support at [email protected] or check out the developer portal at developers.messagemedia.com

๐Ÿ“ƒ License

Apache License. See the LICENSE file.

com.messagemedia.sdk

MessageMedia

Business SMS messaging. And so much more.

Versions

Version
1.0.0