Categorygithub.com/forestvpn/api-client-go
repositorypackage
0.0.0-20230208125554-97cd4e2df380
Repository: https://github.com/forestvpn/api-client-go.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

Go API client for forestvpn_api

ForestVPN - Fast, secure, and modern VPN. It offers Distributed Computing, Crypto Mining, P2P, Ad Blocking, TOR over VPN, 30+ locations, and a free version with unlimited data.

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import forestvpn_api "github.com/forestvpn/api-client-go"

To use a proxy, set the environment variable HTTP_PROXY:

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.

ctx := context.WithValue(context.Background(), forestvpn_api.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.

ctx := context.WithValue(context.Background(), forestvpn_api.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(), forestvpn_api.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), forestvpn_api.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://api.forestvpn.com/v2

ClassMethodHTTP requestDescription
AdsApiCreateAdUnitRequestLogPost /ads/request-logs/Create ad unit request log
AdsApiListAdPlacementsGet /ads/placements/Get ad placement list
AnalyticsApiGetDataUsageStatsGet /analytics/data-usage/Data Usage Stats
AppApiGetCurrentUserDeviceGet /app/devices/current/Get user device info
AppApiUpdateCurrentUserDevicePatch /app/devices/current/Update user device
AppleApiVerifyAppStoreReceiptPost /purchase/apple/verify/App store receipt verification
AuthApiAuthorizeAccessTokenRequestPost /auth/access-token-requests/{requestID}/authorize/Authorize access token request
AuthApiCreateAccessTokenRequestPost /auth/access-token-requests/Create access token request
AuthApiGetAccessTokenRequestGet /auth/access-token-requests/{requestID}/Get access token request details
AuthApiLoginTokenPost /auth/token/login/Login with JWT token
AuthApiMigrateLegacyAuthGet /legacy/auth/Legacy auth migration
AuthApiObtainTokenGet /auth/token/obtain/Obtain JWT token
AuthApiRevokeAccessTokenRequestPost /auth/access-token-requests/{requestID}/revoke/Revoke access token request
AuthApiUpdateUserProfilePatch /auth/profile/Update profile
AuthApiUserProfileGet /auth/profile/Profile
AuthApiWhoAmIGet /auth/whoami/Who am I
BillingApiCancelSubscriptionDelete /billing/subscriptions/{subscriptionID}/Cancel subscription
BillingApiCreatePaymentMethodStripeSetupIntentPost /billing/payment-methods/stripe/setup-intents/Create stripe's setup intent for add new payment method.
BillingApiCreateSubscriptionPost /billing/subscriptions/Create subscription
BillingApiDeletePaymentMethodDelete /billing/payment-methods/{paymentMethodID}/Delete payment method
BillingApiGetBillingAccountGet /billing/account/Billing account info
BillingApiGetBillingBundleGet /billing/bundles/{bundleID}/Bundle info
BillingApiGetBillingPaymentOptionGet /billing/payment-options/{paymentOptionID}/Payment option info
BillingApiGetBillingProductGet /billing/products/{productID}/Product info
BillingApiGetPaymentMethodGet /billing/payment-methods/{paymentMethodID}/Payment method info
BillingApiGetSubscriptionGet /billing/subscriptions/{subscriptionID}/Subscription info
BillingApiGetSubscriptionItemGet /billing/subscription-items/{subscriptionItemID}/Subscription item info
BillingApiListBillingBundlesGet /billing/bundles/Billing bundles list
BillingApiListBillingFeaturesGet /billing/features/Billing feature list
BillingApiListBillingPaymentOptionsGet /billing/payment-options/Billing payment option list
BillingApiListBillingProductsGet /billing/products/Billing products list
BillingApiListPaymentMethodsGet /billing/payment-methods/Payment method list
BillingApiListSubscriptionItemsGet /billing/subscription-items/Subscription items list
BillingApiListSubscriptionsGet /billing/subscriptions/Billing subscriptions list
BillingApiReactivateSubscriptionPost /billing/subscriptions/{subscriptionID}/reactivate/Reactivate subscription
BillingApiUpdateBillingAccountPatch /billing/account/Update billing account
BillingApiUpdateSubscriptionItemPatch /billing/subscription-items/{subscriptionItemID}/Update subscription item
CheckoutApiApplyCouponCheckoutSessionPost /checkout/sessions/{sessionID}/apply_coupon/Apply coupon to session
CheckoutApiCreateCheckoutSessionPost /checkout/sessions/Create checkout session
CheckoutApiCreateWaitListRequestPost /checkout/wait-list/Create request to add country in wait list
CheckoutApiExpireCheckoutSessionPost /checkout/sessions/{sessionID}/expire/Expire checkout session
CheckoutApiGetCheckoutSessionGet /checkout/sessions/{sessionID}/Checkout session details
CheckoutApiGetStripeCheckoutSessionGet /checkout/sessions/{sessionID}/stripe/checkout/session/Stripe checkout session details
CheckoutApiGetStripePaymentIntentGet /checkout/sessions/{sessionID}/stripe/payment/intent/Stripe payment intent details
CheckoutApiProcessCloudPaymentsAuthPost /checkout/sessions/{sessionID}/cloud-payments/auth/Cloud payments auth
CheckoutApiProcessCloudPaymentsPost3dsPost /checkout/sessions/{sessionID}/cloud-payments/post3ds/Cloud payments post3ds
DeviceApiCreateDevicePost /devices/Create new device
DeviceApiCreateDevicePortForwardingPost /devices/{deviceID}/port-forwarding/Create new device port forwarding
DeviceApiDeleteDeviceDelete /devices/{deviceID}/Delete Device
DeviceApiDeleteDevicePortForwardingDelete /devices/{deviceID}/port-forwarding/{portForwardingID}/Delete Device's Port Forwarding
DeviceApiGetDeviceGet /devices/{deviceID}/Device Info
DeviceApiGetDeviceStatsGet /devices/{deviceID}/stats/{statsID}/Device's stats detail
DeviceApiGetDeviceWireGuardGet /devices/{deviceID}/wireguards/{wireGuardID}/Device's wireguard profile detail
DeviceApiListDeviceBindingsGet /devices/{deviceID}/bindings/Device bindings
DeviceApiListDeviceConnectionModesGet /devices/{deviceID}/connection-modes/Device connection modes
DeviceApiListDeviceDetailStatsGet /devices/{deviceID}/detail-stats/Device's detail stats list
DeviceApiListDevicePortForwardingsGet /devices/{deviceID}/port-forwarding/Device Port Forwarding List
DeviceApiListDeviceStatsGet /devices/{deviceID}/stats/Device's stats list
DeviceApiListDeviceWireGuardPeersGet /devices/{deviceID}/wireguards/{wireGuardID}/peers/Device's wireguard peers
DeviceApiListDeviceWireGuardsGet /devices/{deviceID}/wireguards/Device's wireguard profiles list
DeviceApiListDevicesGet /devices/Device List
DeviceApiUpdateDevicePatch /devices/{deviceID}/Update device properties
DeviceApiUpdateDevicePortForwardingPatch /devices/{deviceID}/port-forwarding/{portForwardingID}/Update device's port forwarding
FcmApiCreateFCMDevicePost /notification/fcm/Device registration for push notification through out Firebase Cloud Messaging
FcmApiDeleteFCMDeviceDelete /notification/fcm/{registrationID}/Delete fcm device
FcmApiGetFCMDeviceGet /notification/fcm/{registrationID}/Device info
FcmApiUpdateFCMDevicePatch /notification/fcm/{registrationID}/Update device fcm properties
FriendshipApiAcceptFriendshipInvitationPatch /friendship/invitations/{code}/Accept friendship invitation
FriendshipApiCreateFriendshipInvitationPost /friendship/invitations/Create friendship invitation
FriendshipApiDeleteFriendDelete /friendship/friends/{id}/Delete friend
FriendshipApiGetFriendGet /friendship/friends/{id}/Friend details
FriendshipApiGetFriendshipInvitationGet /friendship/invitations/{code}/Friendship invitation details
FriendshipApiListFriendsGet /friendship/friends/Get friends list
FriendshipApiRejectFriendshipInvitationDelete /friendship/invitations/{code}/Reject friendship invitation
GeoApiListCountriesGet /geo/countries/Countries list
GeoApiListCurrenciesGet /geo/currencies/Correncies list
GeoApiListLocationsGet /locations/Location list
GoogleApiVerifyPlayStorePurchasePost /purchase/google/verify/Play store purchase verification
NotificationsApiGetNotificationsUnreadCountGet /notifications/unread_count/Get unread notifications count
NotificationsApiListNotificationsGet /notifications/all_list/Get notifications list
NotificationsApiUpdateNotificationMarkReadGet /notifications/mark_as_read/{slug}/Mark notification as read by user
NotificationsApiUpdateNotificationMarkReadAllGet /notifications/mark_all_as_read/Mark all notifications as read by user
SupportApiCreateSupportTicketPost /support/tickets/Create support ticket
SupportApiGetSupportTicketCategoryGet /support/ticket-categories/Get ticket categories
WireguardApiGetWireGuardPeerInfoGet /wireguard/peers/{pubKey}/Wireguard peer info
WireguardApiListWireGuardPeersGet /wireguard/peers/Wireguard peers list

Documentation For Models

Documentation For Authorization

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

wireguardAuth

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Authorization and passed in as the auth context for each request.

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

ForestVPN - [email protected]

Credits