Subscribe to an Event
Now that we have a Subscriber we can use to assign our subscriptions to, let's create one.
Parameters
You'll need 3 different parameters to create a Subscription:
SubscriberId(this is the id of theSubscriberthat we just created)Type(this is the eventTypeyou want to subscribe to. In this example, we will subscribe to a member account being created, but all types can be found in the Event Type Dictionary.)HttpEndpoint(this is the URL of your application where you want to receive the event)
Example
Using the example below, replace the placeholder values for SubscriberId, Type, and HttpEndpoint.
using WellViaSDK.Event;
string subscriberId = "your_subscriber_id";
string eventType = "event_type";
Uri endpoint = new Uri("your_endpoint");
var myNewSubscription = await evntClient.CreateSubscriptionAsync(
subscriberId: subscriberId,
type: eventType,
httpEndpoint: endpoint
);Final Solution
That's all there is to it! Here's what the end product should look like:
using WellViaSDK.Event;
string subscriberName = "your_subscriber_name";
var myNewSubscriber = await evntClient.CreateSubscriberAsync(name: subscriberName);
string subscriberId = myNewSubscriber.id;
string eventType = "event_type";
Uri endpoint = new Uri("your_endpoint");
var myNewSubscription = await evntClient.CreateSubscriptionAsync(
subscriberId: subscriberId,
type: eventType,
httpEndpoint: endpoint
);Updated 7 months ago
