https://github.com/onesignal/onesignal-go-api
The official OneSignal API client for Go
https://github.com/onesignal/onesignal-go-api
api api-client email go golang in-app-messaging notifications onesignal push push-notifications rest-api sms
Last synced: 11 months ago
JSON representation
The official OneSignal API client for Go
- Host: GitHub
- URL: https://github.com/onesignal/onesignal-go-api
- Owner: OneSignal
- License: mit
- Created: 2022-04-15T19:03:33.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-20T18:12:45.000Z (over 2 years ago)
- Last Synced: 2024-11-08T21:17:12.553Z (over 1 year ago)
- Topics: api, api-client, email, go, golang, in-app-messaging, notifications, onesignal, push, push-notifications, rest-api, sms
- Homepage:
- Size: 520 KB
- Stars: 13
- Watchers: 33
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Welcome to the official OneSignal Go Client 👋
A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client.
- API version: 5.1.0
- Package version: 5.1.1-beta1
- Build package: org.openapitools.codegen.languages.GoClientCodegen
For more information, please visit [https://onesignal.com](https://onesignal.com)
## Installation
```shell
go get github.com/OneSignal/onesignal-go-api
```
Install the following dependencies:
```shell
go get golang.org/x/oauth2
```
Put the package under your project folder and add the following in import:
```golang
import "github.com/OneSignal/onesignal-go-api"
```
To use a proxy, set the environment variable `HTTP_PROXY`:
```golang
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
```
## Configuration of Server URL
Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification.
### Select Server Configuration
For using other server than the one defined on index 0 set context value `sw.ContextServerIndex` of type `int`.
```golang
ctx := context.WithValue(context.Background(), onesignal.ContextServerIndex, 1)
```
### Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value `sw.ContextServerVariables` of type `map[string]string`.
```golang
ctx := context.WithValue(context.Background(), onesignal.ContextServerVariables, map[string]string{
"basePath": "v2",
})
```
Note, enum values are always validated and all unused variables are silently ignored.
### URLs Configuration per Operation
Each operation can use different server URL defined using `OperationServers` map in the `Configuration`.
An operation is uniquely identified by `"{classname}Service.{nickname}"` string.
Similar rules for overriding default operation server index and variables applies by using `sw.ContextOperationServerIndices` and `sw.ContextOperationServerVariables` context maps.
```
ctx := context.WithValue(context.Background(), onesignal.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), onesignal.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
```
## Documentation for API Endpoints
All URIs are relative to *https://api.onesignal.com*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**CancelNotification**](docs/DefaultApi.md#cancelnotification) | **Delete** /notifications/{notification_id} | Stop a scheduled or currently outgoing notification
*DefaultApi* | [**CreateAlias**](docs/DefaultApi.md#createalias) | **Patch** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity |
*DefaultApi* | [**CreateAliasBySubscription**](docs/DefaultApi.md#createaliasbysubscription) | **Patch** /apps/{app_id}/subscriptions/{subscription_id}/user/identity |
*DefaultApi* | [**CreateApp**](docs/DefaultApi.md#createapp) | **Post** /apps | Create an app
*DefaultApi* | [**CreateNotification**](docs/DefaultApi.md#createnotification) | **Post** /notifications | Create notification
*DefaultApi* | [**CreateSegment**](docs/DefaultApi.md#createsegment) | **Post** /apps/{app_id}/segments | Create Segment
*DefaultApi* | [**CreateSubscription**](docs/DefaultApi.md#createsubscription) | **Post** /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions |
*DefaultApi* | [**CreateUser**](docs/DefaultApi.md#createuser) | **Post** /apps/{app_id}/users |
*DefaultApi* | [**DeleteAlias**](docs/DefaultApi.md#deletealias) | **Delete** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete} |
*DefaultApi* | [**DeleteSegment**](docs/DefaultApi.md#deletesegment) | **Delete** /apps/{app_id}/segments/{segment_id} | Delete Segment
*DefaultApi* | [**DeleteSubscription**](docs/DefaultApi.md#deletesubscription) | **Delete** /apps/{app_id}/subscriptions/{subscription_id} |
*DefaultApi* | [**DeleteUser**](docs/DefaultApi.md#deleteuser) | **Delete** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*DefaultApi* | [**ExportEvents**](docs/DefaultApi.md#exportevents) | **Post** /notifications/{notification_id}/export_events?app_id={app_id} | Export CSV of Events
*DefaultApi* | [**ExportSubscriptions**](docs/DefaultApi.md#exportsubscriptions) | **Post** /players/csv_export?app_id={app_id} | Export CSV of Subscriptions
*DefaultApi* | [**GetAliases**](docs/DefaultApi.md#getaliases) | **Get** /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity |
*DefaultApi* | [**GetAliasesBySubscription**](docs/DefaultApi.md#getaliasesbysubscription) | **Get** /apps/{app_id}/subscriptions/{subscription_id}/user/identity |
*DefaultApi* | [**GetApp**](docs/DefaultApi.md#getapp) | **Get** /apps/{app_id} | View an app
*DefaultApi* | [**GetApps**](docs/DefaultApi.md#getapps) | **Get** /apps | View apps
*DefaultApi* | [**GetNotification**](docs/DefaultApi.md#getnotification) | **Get** /notifications/{notification_id} | View notification
*DefaultApi* | [**GetNotificationHistory**](docs/DefaultApi.md#getnotificationhistory) | **Post** /notifications/{notification_id}/history | Notification History
*DefaultApi* | [**GetNotifications**](docs/DefaultApi.md#getnotifications) | **Get** /notifications | View notifications
*DefaultApi* | [**GetOutcomes**](docs/DefaultApi.md#getoutcomes) | **Get** /apps/{app_id}/outcomes | View Outcomes
*DefaultApi* | [**GetSegments**](docs/DefaultApi.md#getsegments) | **Get** /apps/{app_id}/segments | Get Segments
*DefaultApi* | [**GetUser**](docs/DefaultApi.md#getuser) | **Get** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
*DefaultApi* | [**TransferSubscription**](docs/DefaultApi.md#transfersubscription) | **Patch** /apps/{app_id}/subscriptions/{subscription_id}/owner |
*DefaultApi* | [**UnsubscribeEmailWithToken**](docs/DefaultApi.md#unsubscribeemailwithtoken) | **Post** /apps/{app_id}/notifications/{notification_id}/unsubscribe | Unsubscribe with token
*DefaultApi* | [**UpdateApp**](docs/DefaultApi.md#updateapp) | **Put** /apps/{app_id} | Update an app
*DefaultApi* | [**UpdateLiveActivity**](docs/DefaultApi.md#updateliveactivity) | **Post** /apps/{app_id}/live_activities/{activity_id}/notifications | Update a Live Activity via Push
*DefaultApi* | [**UpdateSubscription**](docs/DefaultApi.md#updatesubscription) | **Patch** /apps/{app_id}/subscriptions/{subscription_id} |
*DefaultApi* | [**UpdateUser**](docs/DefaultApi.md#updateuser) | **Patch** /apps/{app_id}/users/by/{alias_label}/{alias_id} |
## Documentation For Models
- [App](docs/App.md)
- [BasicNotification](docs/BasicNotification.md)
- [BasicNotificationAllOf](docs/BasicNotificationAllOf.md)
- [BasicNotificationAllOfAndroidBackgroundLayout](docs/BasicNotificationAllOfAndroidBackgroundLayout.md)
- [Button](docs/Button.md)
- [CreateNotificationSuccessResponse](docs/CreateNotificationSuccessResponse.md)
- [CreateSegmentConflictResponse](docs/CreateSegmentConflictResponse.md)
- [CreateSegmentSuccessResponse](docs/CreateSegmentSuccessResponse.md)
- [CreateUserConflictResponse](docs/CreateUserConflictResponse.md)
- [CreateUserConflictResponseErrorsInner](docs/CreateUserConflictResponseErrorsInner.md)
- [CreateUserConflictResponseErrorsItemsMeta](docs/CreateUserConflictResponseErrorsItemsMeta.md)
- [DeliveryData](docs/DeliveryData.md)
- [ExportEventsSuccessResponse](docs/ExportEventsSuccessResponse.md)
- [ExportSubscriptionsRequestBody](docs/ExportSubscriptionsRequestBody.md)
- [ExportSubscriptionsSuccessResponse](docs/ExportSubscriptionsSuccessResponse.md)
- [Filter](docs/Filter.md)
- [FilterExpression](docs/FilterExpression.md)
- [GenericError](docs/GenericError.md)
- [GenericSuccessBoolResponse](docs/GenericSuccessBoolResponse.md)
- [GetNotificationHistoryRequestBody](docs/GetNotificationHistoryRequestBody.md)
- [GetSegmentsSuccessResponse](docs/GetSegmentsSuccessResponse.md)
- [LanguageStringMap](docs/LanguageStringMap.md)
- [Notification](docs/Notification.md)
- [NotificationAllOf](docs/NotificationAllOf.md)
- [NotificationHistorySuccessResponse](docs/NotificationHistorySuccessResponse.md)
- [NotificationSlice](docs/NotificationSlice.md)
- [NotificationTarget](docs/NotificationTarget.md)
- [NotificationWithMeta](docs/NotificationWithMeta.md)
- [NotificationWithMetaAllOf](docs/NotificationWithMetaAllOf.md)
- [Operator](docs/Operator.md)
- [OutcomeData](docs/OutcomeData.md)
- [OutcomesData](docs/OutcomesData.md)
- [PlatformDeliveryData](docs/PlatformDeliveryData.md)
- [PlatformDeliveryDataEmailAllOf](docs/PlatformDeliveryDataEmailAllOf.md)
- [PlatformDeliveryDataSmsAllOf](docs/PlatformDeliveryDataSmsAllOf.md)
- [PropertiesBody](docs/PropertiesBody.md)
- [PropertiesDeltas](docs/PropertiesDeltas.md)
- [PropertiesObject](docs/PropertiesObject.md)
- [Purchase](docs/Purchase.md)
- [RateLimitError](docs/RateLimitError.md)
- [Segment](docs/Segment.md)
- [SegmentData](docs/SegmentData.md)
- [SegmentNotificationTarget](docs/SegmentNotificationTarget.md)
- [Subscription](docs/Subscription.md)
- [SubscriptionBody](docs/SubscriptionBody.md)
- [SubscriptionNotificationTarget](docs/SubscriptionNotificationTarget.md)
- [TransferSubscriptionRequestBody](docs/TransferSubscriptionRequestBody.md)
- [UpdateLiveActivityRequest](docs/UpdateLiveActivityRequest.md)
- [UpdateLiveActivitySuccessResponse](docs/UpdateLiveActivitySuccessResponse.md)
- [UpdateUserRequest](docs/UpdateUserRequest.md)
- [User](docs/User.md)
- [UserIdentityBody](docs/UserIdentityBody.md)
- [WebButton](docs/WebButton.md)
## Documentation For Authorization
Use a OneSignal authentication context for each auth type:
- `RestApiKey` - For app-level REST API operations
- `OrganizationApiKey` - For organization-level operations
### organization_api_key
- **Type**: HTTP Bearer token authentication
Example
```golang
orgAuth := context.WithValue(context.Background(), onesignal.OrganizationApiKey, "YOUR_ORGANIZATION_API_KEY") // Organization API key is only required for creating new apps and other top-level endpoints
```
### rest_api_key
- **Type**: HTTP Bearer token authentication
Example
```golang
restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, "YOUR_REST_API_KEY") // App REST API key required for most endpoints
```
## Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains
a number of utility functions to easily obtain pointers to values of basic types.
Each of these functions takes a value of the given basic type and returns a pointer to it:
* `PtrBool`
* `PtrInt`
* `PtrInt32`
* `PtrInt64`
* `PtrFloat`
* `PtrFloat32`
* `PtrFloat64`
* `PtrString`
* `PtrTime`
## Author
devrel@onesignal.com