Skip to content

Commit

Permalink
Merge pull request #39 from Lekso-Surameli/feat/bulk-create-subscribers
Browse files Browse the repository at this point in the history
Feature bulk create subscribers
  • Loading branch information
unicodeveloper authored Oct 3, 2023
2 parents f61a3c5 + 05f8435 commit 36eb7fd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ $subscriber = $novu->createSubscriber([
'avatar' => '<insert-avatar>', // optional
])->toArray();

// Bulk create subscribers
$response = $novu->bulkCreateSubscribers([
[
'subscriberId' => 'SUBSCRIBER_IDENTIFIER>',
'email' => '<insert-email>', // optional
'firstName' => '<insert-firstname>', // optional
'lastName' => '<insert-lastname>', // optional
'avatar' => '<insert-avatar>', // optional
],
[
'subscriberId' => 'SUBSCRIBER_IDENTIFIER>',
'email' => '<insert-email>', // optional
'firstName' => '<insert-firstname>', // optional
'lastName' => '<insert-lastname>', // optional
'avatar' => '<insert-avatar>', // optional
],
]);

// Get subscriber
$subscriber = $novu->getSubscriber($subscriberId)->toArray();

Expand Down
12 changes: 12 additions & 0 deletions src/Actions/ManagesSubscribers.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ public function createSubscriber(array $data, $wait = true)
return new Subscriber($subscriber, $this);
}

/**
* Bulk creates subscribers.
*
* @param array $data
*
* @return array
*/
public function bulkCreateSubscribers(array $data): array
{
return $this->post('subscribers/bulk', ['subscribers' => $data])['data'];
}

/**
* Update a given subscriber
*
Expand Down

0 comments on commit 36eb7fd

Please sign in to comment.