# NotificationsApi

All URIs are relative to *http://localhost*

| Method | HTTP request | Description |
|------------- | ------------- | -------------|
| [**waitNotification**](NotificationsApi.md#waitnotification) | **GET** /api/v1/notifications/wait | Long-poll for wallet notifications |
| [**websocketTicket**](NotificationsApi.md#websocketticket) | **GET** /api/v1/notifications/ws/ticket | Create a websocket ticket |



## waitNotification

> WaitNotificationResponse waitNotification(since)

Long-poll for wallet notifications

Long-polls for wallet notifications. Returns all notifications received since the given timestamp. If no timestamp is provided, returns all notifications in the buffer. Returned notifications are sorted by timestamp in ascending order.

### Example

```ts
import {
  Configuration,
  NotificationsApi,
} from '@secondts/barkd';
import type { WaitNotificationRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new NotificationsApi(config);

  const body = {
    // Date | The timestamp to start waiting for notifications from. If not provided, returns all notifications in the buffer. (optional)
    since: 2013-10-20T19:20:30+01:00,
  } satisfies WaitNotificationRequest;

  try {
    const data = await api.waitNotification(body);
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters


| Name | Type | Description  | Notes |
|------------- | ------------- | ------------- | -------------|
| **since** | `Date` | The timestamp to start waiting for notifications from. If not provided, returns all notifications in the buffer. | [Optional] [Defaults to `undefined`] |

### Return type

[**WaitNotificationResponse**](WaitNotificationResponse.md)

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: `application/json`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns notifications received during the long-poll window if any. Otherwise returns an empty array with provided &#x60;since&#x60; argument as &#x60;last_pushed_at&#x60; field |  -  |
| **400** | Invalid query parameters |  -  |
| **500** | Internal server error |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)


## websocketTicket

> string websocketTicket()

Create a websocket ticket

Creates a single-use ticket that authenticates a websocket connection at &#x60;ws://&lt;host&gt;/api/v1/notifications/ws?ticket&#x3D;&lt;ticket&gt;&#x60;. The ticket must be used within 10 minutes of creation; the resulting websocket connection is long-lived.

### Example

```ts
import {
  Configuration,
  NotificationsApi,
} from '@secondts/barkd';
import type { WebsocketTicketRequest } from '@secondts/barkd';

async function example() {
  console.log("🚀 Testing @secondts/barkd SDK...");
  const config = new Configuration({ 
    // Configure HTTP bearer authorization: bearer
    accessToken: "YOUR BEARER TOKEN",
  });
  const api = new NotificationsApi(config);

  try {
    const data = await api.websocketTicket();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

// Run the test
example().catch(console.error);
```

### Parameters

This endpoint does not need any parameter.

### Return type

**string**

### Authorization

[bearer](../README.md#bearer)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: `text/plain`


### HTTP response details
| Status code | Description | Response headers |
|-------------|-------------|------------------|
| **200** | Returns the websocket ticket. Valid to open a websocket connection in the next 10 minutes. |  -  |
| **401** | Unauthorized |  -  |

[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)

