Skip to content

Commit

Permalink
Merge pull request #314 from codingis4noobs2/staging
Browse files Browse the repository at this point in the history
Added code for Node.js SDK
  • Loading branch information
sumitsaurabh927 authored Oct 30, 2023
2 parents b961929 + b0cb230 commit d47022f
Showing 1 changed file with 146 additions and 1 deletion.
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>

0 comments on commit d47022f

Please sign in to comment.