Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added code for Node.js SDK #314

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 146 additions & 1 deletion api-reference/subscribers/get-subscriber.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,149 @@
openapi: get /v1/subscribers/{subscriberId}
---

<Snippet file="apikey-warning.mdx" />
<Snippet file="apikey-warning.mdx" />

<RequestExample>

```javascript Node.js
import { Novu } from '@novu/node';

const novu = new Novu("<NOVU_API_KEY>");

const response = await novu.subscribers.get("subscriberId");
console.log(response.data);
```

```bash cURL
curl --request GET \
--url https://api.novu.co/v1/subscribers/{subscriberId} \
--header 'Authorization: <authorization>'
```

```python Python
import requests

url = "https://api.novu.co/v1/subscribers/{subscriberId}"

headers = {"Authorization": "<authorization>"}

response = requests.request("GET", url, headers=headers)

print(response.text)
```

```js JavaScript
const options = {method: 'GET', headers: {Authorization: '<authorization>'}};

fetch('https://api.novu.co/v1/subscribers/{subscriberId}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
```

```php PHP
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.novu.co/v1/subscribers/{subscriberId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
```

```go Go
package main

import (
"fmt"
"net/http"
"io/ioutil"
)

func main() {

url := "https://api.novu.co/v1/subscribers/{subscriberId}"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "<authorization>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)

fmt.Println(res)
fmt.Println(string(body))

}
```

```java Java
HttpResponse<String> response = Unirest.get("https://api.novu.co/v1/subscribers/{subscriberId}")
.header("Authorization", "<authorization>")
.asString();
```

</RequestExample>

<ResponseExample>

```json Response
{
"data": {
"_id": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"phone": "string",
"avatar": "string",
"locale": "string",
"subscriberId": "string",
"channels": [
{
"providerId": "slack",
"integrationIdentifier": "string",
"credentials": {
"webhookUrl": "string",
"channel": "string",
"deviceTokens": [
"string"
]
},
"_integrationId": "string"
}
],
"isOnline": "boolean",
"lastOnlineAt": "string",
"_organizationId": "string",
"_environmentId": "string",
"deleted": "boolean",
"createdAt": "string",
"updatedAt": "string",
"__v": "number"
}
}
```

</ResponseExample>