From b0cb230a77a058c5ac9354a0f23d903159155c05 Mon Sep 17 00:00:00 2001 From: Parth Shah <87560178+codingis4noobs2@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:15:07 +0530 Subject: [PATCH] Added code for Node.js SDK --- api-reference/subscribers/get-subscriber.mdx | 147 ++++++++++++++++++- 1 file changed, 146 insertions(+), 1 deletion(-) diff --git a/api-reference/subscribers/get-subscriber.mdx b/api-reference/subscribers/get-subscriber.mdx index 2d7927f9..8dfd175e 100644 --- a/api-reference/subscribers/get-subscriber.mdx +++ b/api-reference/subscribers/get-subscriber.mdx @@ -2,4 +2,149 @@ openapi: get /v1/subscribers/{subscriberId} --- - \ No newline at end of file + + + + +```javascript Node.js +import { Novu } from '@novu/node'; + +const novu = new Novu(""); + +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: ' +``` + +```python Python +import requests + +url = "https://api.novu.co/v1/subscribers/{subscriberId}" + +headers = {"Authorization": ""} + +response = requests.request("GET", url, headers=headers) + +print(response.text) +``` + +```js JavaScript +const options = {method: 'GET', headers: {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 + "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: " + ], +]); + +$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", "") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} +``` + +```java Java +HttpResponse response = Unirest.get("https://api.novu.co/v1/subscribers/{subscriberId}") + .header("Authorization", "") + .asString(); +``` + + + + + +```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" + } +} +``` + +