ringcentral

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvServerURL    = "RINGCENTRAL_SERVER_URL"
	EnvClientID     = "RINGCENTRAL_CLIENT_ID"
	EnvClientSecret = "RINGCENTRAL_CLIENT_SECRET"
	EnvAppName      = "RINGCENTRAL_APP_NAME"
	EnvAppVersion   = "RINGCENTRAL_APP_VERSION"
	EnvRedirectURL  = "RINGCENTRAL_OAUTH_REDIRECT_URL"
	EnvUsername     = "RINGCENTRAL_USERNAME"
	EnvExtension    = "RINGCENTRAL_EXTENSION"
	EnvPassword     = "RINGCENTRAL_PASSWORD"
)
View Source
const (
	ServerURLProduction  = "https://platform.ringcentral.com"
	ServerURLSandbox     = "https://platform.devtest.ringcentral.com"
	ProductionHostname   = "platform.ringcentral.com"
	SandboxHostname      = "platform.devtest.ringcentral.com"
	AuthURLFormat        = "https://%s/restapi/oauth/authorize"
	TokenURLFormat       = "https://%s/restapi/oauth/token"
	AuthURLPart          = "restapi/oauth/authorize"
	TokenURLPart         = "restapi/oauth/token"
	MeURL                = "/restapi/v1.0/account/~/extension/~"
	RestAPI1dot0Fragment = "restapi/v1.0"
)

Variables

View Source
var (
	Hostname = "platform.devtest.ringcentral.com"
)

Functions

func BuildURL

func BuildURL(serverURL, urlFragment string, addRestAPI bool, queryValues url.Values) string

func BuildURLPartial added in v0.3.0

func BuildURLPartial(urlFragment string, addRestAPI bool, queryValues url.Values) string

func NewClientPassword

func NewClientPassword(app ApplicationCredentials, pwd PasswordCredentials) (*http.Client, error)

NewClientPassword uses dedicated password grant handling.

func NewClientPasswordSimple added in v0.3.0

func NewClientPasswordSimple(app ApplicationCredentials, user PasswordCredentials) (*http.Client, error)

NewClientPasswordSimple uses OAuth2 package password grant handling.

func NewEndpoint

func NewEndpoint(hostnameOrBasePath string) oauth2.Endpoint

func NewHttpClientEnvFlexStatic added in v0.3.0

func NewHttpClientEnvFlexStatic(envPrefix string) (*http.Client, error)

func NewTokenPassword added in v0.3.0

func NewTokenPassword(app ApplicationCredentials, pwd PasswordCredentials) (*oauth2.Token, error)

func PasswordCredentialsToHash added in v0.3.0

func PasswordCredentialsToHash(pwdCreds PasswordCredentials, salt []byte) string

func RetrieveToken added in v0.3.0

func RetrieveToken(cfg oauth2.Config, params url.Values) (*oauth2.Token, error)

func SetHostnameForURL

func SetHostnameForURL(serverURLString string) error

func UsernameExtensionPasswordToHash added in v0.3.0

func UsernameExtensionPasswordToHash(username, extension, password string, salt []byte) string

func UsernameExtensionPasswordToString added in v0.3.0

func UsernameExtensionPasswordToString(username, extension, password string) string

Types

type ApplicationCredentials

type ApplicationCredentials struct {
	ServerURL       string `json:"serverURL,omitempty"`
	ApplicationID   string `json:"applicationID,omitempty"`
	ClientID        string `json:"clientID,omitempty"`
	ClientSecret    string `json:"clientSecret,omitempty"`
	RedirectURL     string `json:"redirectURL,omitempty"`
	AppName         string `json:"applicationName,omitempty"`
	AppVersion      string `json:"applicationVersion,omitempty"`
	OAuthEndpointID string `json:"oauthEndpointID,omitempty"`
	AccessTokenTTL  int64  `json:"accessTokenTTL,omitempty"`
	RefreshTokenTTL int64  `json:"refreshTokenTTL,omitempty"`
}

func NewApplicationCredentialsEnv added in v0.3.0

func NewApplicationCredentialsEnv() ApplicationCredentials

func (*ApplicationCredentials) AppNameAndVersion added in v0.3.0

func (ac *ApplicationCredentials) AppNameAndVersion() string

func (*ApplicationCredentials) Config

func (app *ApplicationCredentials) Config() oauth2.Config

func (*ApplicationCredentials) Exchange added in v0.3.0

func (app *ApplicationCredentials) Exchange(code string) (*RcToken, error)

type ClientUtil

type ClientUtil struct {
	Client *http.Client             `json:"-"`
	User   RingCentralExtensionInfo `json:"user,omitempty"`
}

ClientUtil is a client library to retrieve user info from the Facebook API.

func NewClientUtil

func NewClientUtil(client *http.Client) ClientUtil

func (*ClientUtil) GetSCIMUser

func (apiutil *ClientUtil) GetSCIMUser() (scim.User, error)

func (*ClientUtil) GetUserinfo

func (apiutil *ClientUtil) GetUserinfo() (RingCentralExtensionInfo, error)

GetUserinfo retrieves the userinfo from the https://graph.facebook.com/v2.9/{user-id} endpoint.

func (*ClientUtil) SetClient

func (apiutil *ClientUtil) SetClient(client *http.Client)

type Credentials added in v0.3.1

type Credentials struct {
	Application         ApplicationCredentials `json:"application,omitempty"`
	PasswordCredentials PasswordCredentials    `json:"passwordCredentials,omitempty"`
	Token               *oauth2.Token          `json:"token,omitempty"`
}

func NewCredentialsEnv added in v0.3.1

func NewCredentialsEnv() Credentials

func NewCredentialsJSON added in v0.3.1

func NewCredentialsJSON(jsonData []byte) (Credentials, error)

func (*Credentials) NewClient added in v0.3.1

func (creds *Credentials) NewClient() (*http.Client, error)

func (*Credentials) NewToken added in v0.3.1

func (creds *Credentials) NewToken() (*oauth2.Token, error)

type PasswordCredentials added in v0.3.0

type PasswordCredentials struct {
	GrantType            string `url:"grant_type"`
	AccessTokenTTL       int64  `url:"access_token_ttl"`
	RefreshTokenTTL      int64  `url:"refresh_token_ttl"`
	Username             string `json:"username" url:"username"`
	Extension            string `json:"extension" url:"extension"`
	Password             string `json:"password" url:"password"`
	EndpointId           string `url:"endpoint_id"`
	EngageVoiceAccountId int64  `json:"engageVoiceAccountId"`
}

func NewPasswordCredentialsEnv added in v0.3.0

func NewPasswordCredentialsEnv() PasswordCredentials

func (*PasswordCredentials) URLValues added in v0.3.0

func (pw *PasswordCredentials) URLValues() url.Values

func (*PasswordCredentials) UsernameSimple added in v0.3.1

func (uc *PasswordCredentials) UsernameSimple() string

type RcToken added in v0.3.0

type RcToken struct {
	AccessToken           string    `json:"access_token,omitempty"`
	TokenType             string    `json:"token_type,omitempty"`
	Scope                 string    `json:"scope,omitempty"`
	ExpiresIn             int64     `json:"expires_in,omitempty"`
	RefreshToken          string    `json:"refresh_token,omitempty"`
	RefreshTokenExpiresIn int64     `json:"refresh_token_expires_in,omitempty"`
	OwnerID               string    `json:"owner_id,omitempty"`
	EndpointID            string    `json:"endpoint_id,omitempty"`
	Expiry                time.Time `json:"expiry,omitempty"`
	RefreshTokenExpiry    time.Time `json:"refresh_token_expiry,omitempty"`
	// contains filtered or unexported fields
}

func RetrieveRcToken added in v0.3.0

func RetrieveRcToken(cfg oauth2.Config, params url.Values) (*RcToken, error)

func (*RcToken) Inflate added in v0.3.0

func (rcTok *RcToken) Inflate() error

func (*RcToken) OAuth2Token added in v0.3.0

func (rcTok *RcToken) OAuth2Token() (*oauth2.Token, error)

type RingCentralAccount

type RingCentralAccount struct {
	URI string `json:"uri,omitempty"`
	ID  string `json:"id,omitempty"`
}

type RingCentralContact

type RingCentralContact struct {
	FirstName string `json:"firstName,omitempty"`
	LastName  string `json:"lastName,omitempty"`
	Email     string `json:"email,omitempty"`
}

type RingCentralExtensionInfo

type RingCentralExtensionInfo struct {
	ID              int64              `json:"id,omitempty"`
	ExtensionNumber string             `json:"extensionNumber,omitempty"`
	Contact         RingCentralContact `json:"contact,omitempty"`
	Name            string             `json:"name,omitempty"`
	Account         RingCentralAccount `json:"account,omitempty"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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