Skip to content

Latest commit

 

History

History
431 lines (333 loc) · 18 KB

README.md

File metadata and controls

431 lines (333 loc) · 18 KB

Subscribers

(subscribers())

Overview

A subscriber in Novu represents someone who should receive a message. A subscriber’s profile information contains important attributes about the subscriber that will be used in messages (name, email). The subscriber object can contain other key-value pairs that can be used to further personalize your messages.

https://docs.novu.co/subscribers/subscribers

Available Operations

create

Creates a subscriber entity, in the Novu platform. The subscriber will be later used to receive notifications, and access notification feeds. Communication credentials such as email, phone number, and 3 rd party credentials i.e slack tokens could be later associated to this entity.

Example Usage

package hello.world;

import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Novu sdk = Novu.builder()
                .apiKey("<YOUR_API_KEY_HERE>")
                .build();

            CreateSubscriberRequestDto req = CreateSubscriberRequestDto.builder()
                .subscriberId("<value>")
                .build();

            SubscribersControllerCreateSubscriberResponse res = sdk.subscribers().create()
                .request(req)
                .call();

            if (res.subscriberResponseDto().isPresent()) {
                // handle response
            }
        } catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
request co.novu.co.novu.sdk.models.components.CreateSubscriberRequestDto ✔️ The request object to use for the request.

Response

Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerCreateSubscriberResponse>

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx /

createBulk

  Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API.
  The bulk API is limited to 500 subscribers per request.

Example Usage

package hello.world;

import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Novu sdk = Novu.builder()
                .apiKey("<YOUR_API_KEY_HERE>")
                .build();

            BulkSubscriberCreateDto req = BulkSubscriberCreateDto.builder()
                .subscribers(java.util.List.of(
                        CreateSubscriberRequestDto.builder()
                            .subscriberId("<value>")
                            .build()))
                .build();

            SubscribersControllerBulkCreateSubscribersResponse res = sdk.subscribers().createBulk()
                .request(req)
                .call();

            // handle response
        } catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
request co.novu.co.novu.sdk.models.components.BulkSubscriberCreateDto ✔️ The request object to use for the request.

Response

Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerBulkCreateSubscribersResponse>

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx /

delete

Deletes a subscriber entity from the Novu platform

Example Usage

package hello.world;

import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Novu sdk = Novu.builder()
                .apiKey("<YOUR_API_KEY_HERE>")
                .build();

            SubscribersControllerRemoveSubscriberResponse res = sdk.subscribers().delete()
                .subscriberId("<value>")
                .call();

            if (res.deleteSubscriberResponseDto().isPresent()) {
                // handle response
            }
        } catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
subscriberId String ✔️ N/A

Response

Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerRemoveSubscriberResponse>

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx /

list

Returns a list of subscribers, could paginated using the page and limit query parameter

Example Usage

package hello.world;

import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Novu sdk = Novu.builder()
                .apiKey("<YOUR_API_KEY_HERE>")
                .build();

            SubscribersControllerListSubscribersResponse res = sdk.subscribers().list()
                .page(7685.78d)
                .limit(10d)
                .call();

            while (true) {
                if (res.object().isPresent()) {
                    // handle response
                    Optional<SubscribersControllerListSubscribersResponse> nextRes = res.next();
                    if (nextRes.isPresent()) {
                        res = nextRes.get();
                    } else {
                        break;
                    }
                }
            }
        } catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
page Optional<? extends Double> N/A
limit Optional<? extends Double> N/A

Response

Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerListSubscribersResponse>

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx /

retrieve

Get subscriber by your internal id used to identify the subscriber

Example Usage

package hello.world;

import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Novu sdk = Novu.builder()
                .apiKey("<YOUR_API_KEY_HERE>")
                .build();

            SubscribersControllerGetSubscriberResponse res = sdk.subscribers().retrieve()
                .subscriberId("<value>")
                .call();

            if (res.subscriberResponseDto().isPresent()) {
                // handle response
            }
        } catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
subscriberId String ✔️ N/A

Response

Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerGetSubscriberResponse>

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx /

update

Used to update the subscriber entity with new information

Example Usage

package hello.world;

import co.novu.co.novu.sdk.Novu;
import co.novu.co.novu.sdk.models.components.*;
import co.novu.co.novu.sdk.models.components.Security;
import co.novu.co.novu.sdk.models.operations.*;
import co.novu.co.novu.sdk.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;

public class Application {

    public static void main(String[] args) throws Exception {
        try {
            Novu sdk = Novu.builder()
                .apiKey("<YOUR_API_KEY_HERE>")
                .build();

            SubscribersControllerUpdateSubscriberResponse res = sdk.subscribers().update()
                .subscriberId("<value>")
                .updateSubscriberRequestDto(UpdateSubscriberRequestDto.builder()
                    .build())
                .call();

            if (res.subscriberResponseDto().isPresent()) {
                // handle response
            }
        } catch (co.novu.co.novu.sdk.models.errors.SDKError e) {
            // handle exception
            throw e;
        } catch (Exception e) {
            // handle exception
            throw e;
        }
    }
}

Parameters

Parameter Type Required Description
subscriberId String ✔️ N/A
updateSubscriberRequestDto co.novu.co.novu.sdk.models.components.UpdateSubscriberRequestDto ✔️ N/A

Response

Optional<? extends co.novu.co.novu.sdk.models.operations.SubscribersControllerUpdateSubscriberResponse>

Errors

Error Object Status Code Content Type
models/errors/SDKError 4xx-5xx /