number

package
v0.0.0-...-32ef62a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	DefaultApi *DefaultApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the Numbers API API v1.0.18 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath changes base path to allow switching to mocks

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

APIResponse stores the API response returned by the server.

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

NewAPIResponse returns a new APIResonse object.

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

NewAPIResponseWithError returns a new APIResponse object with the provided error message.

type AvailableNumbers

type AvailableNumbers struct {
	// The total amount of numbers available in the pool.
	Count int32 `json:"count,omitempty"`
	// A paginated array of available numbers and their details.
	Numbers []Availablenumber `json:"numbers,omitempty"`
}

AvailableNumbers struct for AvailableNumbers

type Availablenumber

type Availablenumber struct {
	// The two character country code in ISO 3166-1 alpha-2 format
	Country string `json:"country,omitempty"`
	// An available inbound virtual number.
	Msisdn string `json:"msisdn,omitempty"`
	// The type of number: `landline`, `landline-toll-free` or `mobile-lvn`
	Type string `json:"type,omitempty"`
	// The monthly rental cost for this number, in Euros
	Cost string `json:"cost,omitempty"`
	// The capabilities of the number: `SMS` or `VOICE` or `SMS,VOICE` or `SMS,MMS` or `VOICE,MMS` or `SMS,MMS,VOICE`
	Features []string `json:"features,omitempty"`
}

Availablenumber struct for Availablenumber

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type BuyANumberOpts

type BuyANumberOpts struct {
	TargetApiKey optional.String
}

BuyANumberOpts Optional parameters for the method 'BuyANumber'

type CancelANumberOpts

type CancelANumberOpts struct {
	TargetApiKey optional.String
}

CancelANumberOpts Optional parameters for the method 'CancelANumber'

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

type DefaultApiService

type DefaultApiService service

DefaultApiService DefaultApi service

func (*DefaultApiService) BuyANumber

func (a *DefaultApiService) BuyANumber(ctx _context.Context, country string, msisdn string, localVarOptionals *BuyANumberOpts) (Response, *_nethttp.Response, error)

BuyANumber Buy a number Request to purchase a specific inbound number.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param country The two character country code in ISO 3166-1 alpha-2 format
  • @param msisdn An available inbound virtual number.
  • @param optional nil or *BuyANumberOpts - Optional Parameters:
  • @param "TargetApiKey" (optional.String) - If you’d like to perform an action on a subaccount, provide the `api_key` of that account here. If you’d like to perform an action on your own account, you do not need to provide this field.

@return Response

func (*DefaultApiService) CancelANumber

func (a *DefaultApiService) CancelANumber(ctx _context.Context, country string, msisdn string, localVarOptionals *CancelANumberOpts) (Response, *_nethttp.Response, error)

CancelANumber Cancel a number Cancel your subscription for a specific inbound number.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param country The two character country code in ISO 3166-1 alpha-2 format
  • @param msisdn An available inbound virtual number.
  • @param optional nil or *CancelANumberOpts - Optional Parameters:
  • @param "TargetApiKey" (optional.String) - If you’d like to perform an action on a subaccount, provide the `api_key` of that account here. If you’d like to perform an action on your own account, you do not need to provide this field.

@return Response

func (*DefaultApiService) GetAvailableNumbers

func (a *DefaultApiService) GetAvailableNumbers(ctx _context.Context, country string, localVarOptionals *GetAvailableNumbersOpts) (AvailableNumbers, *_nethttp.Response, error)

GetAvailableNumbers Search available numbers Retrieve inbound numbers that are available for the specified country.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param country The two character country code to filter on (in ISO 3166-1 alpha-2 format)
  • @param optional nil or *GetAvailableNumbersOpts - Optional Parameters:
  • @param "Type_" (optional.String) - Set this parameter to filter the type of number, such as mobile or landline
  • @param "Pattern" (optional.String) - The number pattern you want to search for. Use in conjunction with `search_pattern`.
  • @param "SearchPattern" (optional.Int32) - The strategy you want to use for matching: * `0` - Search for numbers that start with `pattern` (Note: all numbers are in E.164 format, so the starting pattern includes the country code, such as 1 for USA) * `1` - Search for numbers that contain `pattern` * `2` - Search for numbers that end with `pattern`
  • @param "Features" (optional.String) - Available features are `SMS`, `VOICE` and `MMS`. To look for numbers that support multiple features, use a comma-separated value: `SMS,MMS,VOICE`.
  • @param "Size" (optional.Int32) - Page size
  • @param "Index" (optional.Int32) - Page index

@return AvailableNumbers

func (*DefaultApiService) GetOwnedNumbers

func (a *DefaultApiService) GetOwnedNumbers(ctx _context.Context, localVarOptionals *GetOwnedNumbersOpts) (InboundNumbers, *_nethttp.Response, error)

GetOwnedNumbers List the numbers you own Retrieve all the inbound numbers associated with your Nexmo account.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param optional nil or *GetOwnedNumbersOpts - Optional Parameters:
  • @param "ApplicationId" (optional.String) - The Application that you want to return the numbers for.
  • @param "HasApplication" (optional.Bool) - Set this optional field to `true` to restrict your results to numbers associated with an Application (any Application). Set to `false` to find all numbers not associated with any Application. Omit the field to avoid filtering on whether or not the number is assigned to an Application.
  • @param "Country" (optional.String) -
  • @param "Pattern" (optional.String) - The number pattern you want to search for. Use in conjunction with `search_pattern`.
  • @param "SearchPattern" (optional.Int32) - The strategy you want to use for matching: * `0` - Search for numbers that start with `pattern` (Note: all numbers are in E.164 format, so the starting pattern includes the country code, such as 1 for USA) * `1` - Search for numbers that contain `pattern` * `2` - Search for numbers that end with `pattern`
  • @param "Size" (optional.Int32) - Page size
  • @param "Index" (optional.Int32) - Page index

@return InboundNumbers

func (*DefaultApiService) UpdateANumber

func (a *DefaultApiService) UpdateANumber(ctx _context.Context, country string, msisdn string, localVarOptionals *UpdateANumberOpts) (Response, *_nethttp.Response, error)

UpdateANumber Update a number Change the behaviour of a number that you own.

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param country The two character country code in ISO 3166-1 alpha-2 format
  • @param msisdn An available inbound virtual number.
  • @param optional nil or *UpdateANumberOpts - Optional Parameters:
  • @param "AppId" (optional.String) - The Application that will handle inbound traffic to this number.
  • @param "MoHttpUrl" (optional.String) - An URL-encoded URI to the webhook endpoint that handles inbound messages. Your webhook endpoint must be active before you make this request. Nexmo makes a `GET` request to the endpoint and checks that it returns a `200 OK` response. Set this parameter's value to an empty string to remove the webhook.
  • @param "MoSmppSysType" (optional.String) - The associated system type for your SMPP client
  • @param "VoiceCallbackType" (optional.String) - Specify whether inbound voice calls on your number are forwarded to a SIP or a telephone number. This must be used with the `voiceCallbackValue` parameter. If set, `sip` or `tel` are prioritized over the Voice capability in your Application. *Note: The `app` value is deprecated and will be removed in future.*
  • @param "VoiceCallbackValue" (optional.String) - A SIP URI or telephone number. Must be used with the `voiceCallbackType` parameter.
  • @param "VoiceStatusCallback" (optional.String) - A webhook URI for Nexmo to send a request to when a call ends
  • @param "MessagesCallbackType" (optional.String) - <strong>DEPRECATED</strong> - We recommend that you use `app_id` instead. Specifies the Messages webhook type (always `app`) associated with this number and must be used with the `messagesCallbackValue` parameter.
  • @param "MessagesCallbackValue" (optional.String) - <strong>DEPRECATED</strong> - We recommend that you use `app_id` instead. Specifies the Application ID of your Messages application. It must be used with the `messagesCallbackType` parameter.

@return Response

type GenericOpenAPIError

type GenericOpenAPIError struct {
	// contains filtered or unexported fields
}

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type GetAvailableNumbersOpts

type GetAvailableNumbersOpts struct {
	Type_         optional.String
	Pattern       optional.String
	SearchPattern optional.Int32
	Features      optional.String
	Size          optional.Int32
	Index         optional.Int32
}

GetAvailableNumbersOpts Optional parameters for the method 'GetAvailableNumbers'

type GetOwnedNumbersOpts

type GetOwnedNumbersOpts struct {
	ApplicationId  optional.String
	HasApplication optional.Bool
	Country        optional.String
	Pattern        optional.String
	SearchPattern  optional.Int32
	Size           optional.Int32
	Index          optional.Int32
}

GetOwnedNumbersOpts Optional parameters for the method 'GetOwnedNumbers'

type InboundNumbers

type InboundNumbers struct {
	// The total amount of numbers owned by the account
	Count int32 `json:"count,omitempty"`
	// A paginated array of numbers and their details
	Numbers []Ownednumber `json:"numbers,omitempty"`
}

InboundNumbers struct for InboundNumbers

type InlineResponse401

type InlineResponse401 struct {
	// A code relating to this error
	ErrorCode string `json:"error-code,omitempty"`
	// Words describing the error that occurred
	ErrorCodeLabel string `json:"error-code-label,omitempty"`
}

InlineResponse401 struct for InlineResponse401

type NumberDetails

type NumberDetails struct {
	// The two character country code in ISO 3166-1 alpha-2 format
	Country string `json:"country"`
	// An available inbound virtual number.
	Msisdn string `json:"msisdn"`
	// If you’d like to perform an action on a subaccount, provide the `api_key` of that account here. If you’d like to perform an action on your own account, you do not need to provide this field.
	TargetApiKey string `json:"target_api_key,omitempty"`
}

NumberDetails struct for NumberDetails

type NumberDetailsUpdate

type NumberDetailsUpdate struct {
	// The two character country code in ISO 3166-1 alpha-2 format
	Country string `json:"country"`
	// An available inbound virtual number.
	Msisdn string `json:"msisdn"`
	// The Application that will handle inbound traffic to this number.
	AppId string `json:"app_id,omitempty"`
	// An URL-encoded URI to the webhook endpoint that handles inbound messages. Your webhook endpoint must be active before you make this request. Nexmo makes a `GET` request to the endpoint and checks that it returns a `200 OK` response. Set this parameter's value to an empty string to remove the webhook.
	MoHttpUrl string `json:"moHttpUrl,omitempty"`
	// The associated system type for your SMPP client
	MoSmppSysType string `json:"moSmppSysType,omitempty"`
	// Specify whether inbound voice calls on your number are forwarded to a SIP or a telephone number.  This must be used with the `voiceCallbackValue` parameter. If set, `sip` or `tel` are prioritized over the Voice capability in your Application.  *Note: The `app` value is deprecated and will be removed in future.*
	VoiceCallbackType string `json:"voiceCallbackType,omitempty"`
	// A SIP URI or telephone number. Must be used with the `voiceCallbackType` parameter.
	VoiceCallbackValue string `json:"voiceCallbackValue,omitempty"`
	// A webhook URI for Nexmo to send a request to when a call ends
	VoiceStatusCallback string `json:"voiceStatusCallback,omitempty"`
	// <strong>DEPRECATED</strong> - We recommend that you use `app_id` instead.  Specifies the Messages webhook type (always `app`) associated with this number and must be used with the `messagesCallbackValue` parameter.
	MessagesCallbackType string `json:"messagesCallbackType,omitempty"`
	// <strong>DEPRECATED</strong> - We recommend that you use `app_id` instead.  Specifies the Application ID of your Messages application. It must be used with the `messagesCallbackType` parameter.
	MessagesCallbackValue string `json:"messagesCallbackValue,omitempty"`
}

NumberDetailsUpdate struct for NumberDetailsUpdate

type Ownednumber

type Ownednumber struct {
	// The two character country code in ISO 3166-1 alpha-2 format
	Country string `json:"country,omitempty"`
	// An available inbound virtual number.
	Msisdn string `json:"msisdn,omitempty"`
	// The URL of the webhook endpoint that handles inbound messages
	MoHttpUrl string `json:"moHttpUrl,omitempty"`
	// The type of number: `landline`, `landline-toll-free` or `mobile-lvn`
	Type string `json:"type,omitempty"`
	// The capabilities of the number: `SMS` or `VOICE` or `SMS,VOICE` or `SMS,MMS` or `VOICE,MMS` or `SMS,MMS,VOICE`
	Features []string `json:"features,omitempty"`
	// The messages webhook type: always `app`
	MessagesCallbackType string `json:"messagesCallbackType,omitempty"`
	// An Application ID
	MessagesCallbackValue string `json:"messagesCallbackValue,omitempty"`
	// The voice webhook type: `sip`, `tel`, or `app`
	VoiceCallbackType string `json:"voiceCallbackType,omitempty"`
	// A SIP URI, telephone number or Application ID
	VoiceCallbackValue string `json:"voiceCallbackValue,omitempty"`
}

Ownednumber struct for Ownednumber

type Response

type Response struct {
	// The status code of the response. `200` indicates a successful request.
	ErrorCode string `json:"error-code,omitempty"`
	// The status code description
	ErrorCodeLabel string `json:"error-code-label,omitempty"`
}

Response struct for Response

type UpdateANumberOpts

type UpdateANumberOpts struct {
	AppId                 optional.String
	MoHttpUrl             optional.String
	MoSmppSysType         optional.String
	VoiceCallbackType     optional.String
	VoiceCallbackValue    optional.String
	VoiceStatusCallback   optional.String
	MessagesCallbackType  optional.String
	MessagesCallbackValue optional.String
}

UpdateANumberOpts Optional parameters for the method 'UpdateANumber'

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL