golatch

package module
Version: v0.0.0-...-0a09373 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2017 License: LGPL-2.1 Imports: 14 Imported by: 2

README

golatch Build Status

golatch is a package that easily lets you integrate Latch in your Go applications. If you don't know what Latch is or how to use it please visit their official site.

Installation

You can download the package manually and put it in your /src folder or use go get:

$ go get github.com/millenc/golatch 

You can also use go get -u to update the package.

Usage

First you need to create the Latch struct that you will use to call all the operations of the API:

import "golatch"

// ...
latch := golatch.NewLatch("MyAppID", "MySecretKey")

where "MyAppID" and "MySecretKey" are your application's ID and secret key respectively. You can find this information in the developer's area of the official website once you create your application.

Pairing

You can use the Pair() method providing the pairing token supplied by the user:

response, err := latch.Pair("MyToken")

If everything goes well, this call will return a response containing the Account ID that has been paired:

if err == nil {
	account_id := response.AccountId()
	//Store the account id
}

You must store this account ID together with the user information to use it in future API calls.

Unpairing

Call the Unpair() method and pass the Account ID you want to unpair as argument:

if err := latch.Unpair("AccountID"); err != nil {
	//Handle error
}

If no error is returned, the account has been unpaired successfully.

Locking/unlocking

NOTE: These methods require a GOLD or PLATINUM subscription in order to work. If you don't have any of these types of subscriptions you will get an error.

You can change the status of an account (lock/unlock) using the Lock()/Unlock() methods:

err := latch.Lock("AccountID")
err := latch.Unlock("AccountID")

If you have created operations for an application you can lock and unlock them using the LockOperation() and UnlockOperation() methods:

err := latch.LockOperation("AccountID", "MyOperationID")
err := latch.UnlockOperation("AccountID", "MyOperationID")
Status

To get the current status of an account, you can use the Status() method:

if response, err := latch.Status("AccountID", false, false); err == nil {
	//Handle response
}

Upon success, this method will return a response struct of type LatchStatusResponse. If the second parameter is true (nootp), then the One-time password information will not be included in the response. If the third parameter is true (silent) Latch will not send a push notification to the user alerting of the access if the account's latch is on (this requires a SILVER, GOLD or PLATINUM subscription). You can easily access the information for the root application/operation:

Status(): Gets the account status:

status := response.Status()
if status == golatch.LATCH_STATUS_ON {
	//Account is ON (latch is deactivated), let the user log in (for example)
}

As you can see in the previous snippet, to determine the status of an account it's recommended that you use the golatch.LATCH_STATUS_ON (ON status) and golatch.LATCH_STATUS_OFF (OFF status) constants.

TwoFactor(): Gets the two factor authentication information:

two_factor LatchTwoFactor = reponse.TwoFactor()
if two_factor.Token != "" {
	token     := two_factor.Token
	generated := two_factor.Generated
	//Handle two factor authentication
}

Please note that this method will always return a LatchTwoFactor struct, even if the response didn't include this information. Hence you should always test for zero values before proceeding (two_factor.Token != "").

Operations(): Gets the child operations of the application:

operations := reponse.Operations()

An application (or operation) can have child operations. This method will return the status for these nested operations as a map of LatchOperationStatus indexed by operation ID. Each of these LatchOperationStatus structs have the following information:

status     := operation_status.Status
two_factor := operation_status.TwoFactor
operations := operation_status.Operations

The information contained in these fields is the same that has been previously discussed.

Operation Status

IMPORTANT: If you have created operations for your application you should not query the status of the application, but rather the status of individual operations. To do so, you can use the OperationStatus() method:

if response, err := latch.OperationStatus("AccountID", "MyOperationID", false, false); err == nil {
    //Handle response
}

If the third parameter is true (nootp), then no One-time password information will be included in the response. If the fourth parameter is true (silent) Latch will not send a push notification to the user alerting of the access if the operation's latch is on (this requires a SILVER, GOLD or PLATINUM subscription). The response is of the same type and contains the same information as the one returned by the Status() method.

Managing operations

You can create/edit/delete operations directly from your application:

Create operation:

if response, err := latch.AddOperation(parentId, name, twoFactor, lockOnRequest); err == nil {
	//Get the ID of the newly created operation
	operationId := response.OperationId()
}

where:

  • parentId: Id of this operation's parent (application or another operation).
  • name: Name of the operation.
  • twoFactor: Use of two factor authentication. One of these values:
    • OPT_IN (optional): golatch.OPT_IN
    • MANDATORY (mandatory): golatch.MANDATORY
    • DISABLED (disabled): golatch.DISABLED
  • lockOnRequest: Takes the same values as twoFactor.

Modify operation:

err := latch.UpdateOperation(operationId, name, twoFactor, lockOnRequest)

where:

  • operationId: Id of the operation you want to modify.
  • name: Name of the operation.
  • twoFactor: This is optional, use the value golatch.NOT_SET if you want to leave the existing value.
  • lockOnRequest: This is optional, use the value golatch.NOT_SET if you want to leave the existing value.

Delete operation:

err := DeleteOperation(operationId)

Get operation information:

Get all the operations:

if response, err := latch.ShowOperation(""); err == nil {
	for id, operation := range response.Operations() {
		name := operation.Name
		two_factor := operation.TwoFactor
		lock_on_request := operation.LockOnRequest
		operations := operation.Operations
	}
}

Get single operation (using it's operation ID):

if response, err := latch.ShowOperation(operationId); err == nil {
	id, operation := response.FirstOperation()
	
	name := operation.Name
	two_factor := operation.TwoFactor
	lock_on_request := operation.LockOnRequest
	operations := operation.Operations
}
History

NOTE: This method require a GOLD or PLATINUM subscription in order to work. If you don't have any of these types of subscriptions you will get an error.

You can get the history of an account (with it's accountId) between two dates (from and to) with the History() method:

if response, err := latch.History(accountId, from, to); err == nil {
	application := response.Application()
	lastSeen := response.LastSeen()
	clientVersion := response.ClientVersion()
	historyCount := response.HistoryCount()
	history := response.History()	
}

The from and to dates are optional. If you don't want to specify any of the dates you can pass an empty (non initialized) Time struct, that is time.Time{}. Once you have a response, you can use the following methods to get the information contained in it:

  • Application(): returns a struct of type LatchApplication with information about the application. This struct has the following fields:
    • Status: status of the application (on/off).
    • PairedOn: when the account was paired to the application.
    • Name: name of the application.
    • Description: description of the application.
    • ImageURL: URL of the application's image.
    • ContactPhone: contact phone of the application's administrator.
    • ContactEmail: contact email of the application's administrator.
    • TwoFactor: two factor setting.
    • LockOnRequest: lock on request setting.
    • Operations: array of LatchOperation structs containing information about the operations defined for the application.
  • LastSeen(): last time there was user activity for this account.
  • ClientVersion(): Contains information about the platforms and versions used by the client. The returned value is an array of structs LatchClientVersion where each value has the following fields:
    • Platform: Name of the platform ("Android" for example).
    • App: Version.
  • HistoryCount(): number of history entries in the response.
  • History(): history entries. Array of structs of type LatchHistoryEntry:
    • Time: time of this action.
    • Action: action (get,USER_UPDATE or DEVELOPER_UPDATE)
    • What: parameter that was affected by the action.
    • Was: previous value of the parameter.
    • Value: value of the parameter.
    • Name: name of the application or operation.
    • UserAgent: user agent of the user that performed the action.
    • IP: ip of the user that performed the action.

User API Usage

Starting with API version 1.0 there's a User API that you can use to manage applications and get information about your subscription. The usage is pretty similar to the application API described in the previous section. The main diference is that instead of using the Application ID you have to use your User ID. Please note that all the functions described in this section require a GOLD or PLATINUM subscription in order to work.

To start using this API, you have to create an instance of the LatchUser struct, that you will you use later to call the appropriate methods:

import "golatch"

// ...
latch := golatch.NewLatchUser("MyUserID", "MySecretKey")
Show applications

To get information about all the applications that you have defined in your account you can use the ShowApplications() function:

if response, err := latch.ShowApplications(); err == nil {
	applications := response.Applications()

	for applicationId, application := range applications {
		fmt.Println(applicationId)
		fmt.Println(application.Name)
		fmt.Println(application.Secret)
		fmt.Println(application.TwoFactor)
		fmt.Println(application.LockOnRequest)
		fmt.Println(application.ContactPhone)
		fmt.Println(application.ContactEmail)
		fmt.Println(application.ImageURL)
	}
}

This call will return a struct of type LatchShowApplicationsResponse. You can use the Applications() method of this struct to get the applications information as a map, where the key is the Application ID and the value is a struct of type LatchApplicationInfo with the following fields:

  • Name: Name of the application.
  • Secret: Secret key of the application.
  • TwoFactor: Two factor authentication.
  • LockOnRequest: Lock on request setting.
  • ContactPhone: Contact phone.
  • ContactEmail: Contact email.
  • ImageURL: Image URL
  • Operations: Map of LatchOperation structs with the application's operations.
Add application

You can create a new application programatically using the AddApplication() method. You need to provide a LatchApplicationInfo struct with the application information like in the following example:

applicationInfo := &golatch.LatchApplicationInfo{
	Name:          "My Application Name",
	ContactEmail:  "my@contact_email.com",
	ContactPhone:  "111222333",
	TwoFactor:     golatch.DISABLED, //optional, can also be golatch.MANDATORY, golatch.OPT_IN or golatch.NOT_SET (empty)
	LockOnRequest: golatch.OPT_IN,   //optional, same values as TwoFactor
}

if response, err := latch.AddApplication(applicationInfo); err == nil {
	fmt.Println(response.AppID())
	fmt.Println(response.Secret())
}

If everything goes well, you can use the AppID() and Secret() methods on the response struct to get the Application ID and Secret Key of the new application.

Update application

You can update the information of an existing application using the UpdateApplication() method. You must specify the Application's ID (first parameter) and the information you want to change (second parameter, which must be a struct of type LatchApplicationInfo). For example to change the name of the application you could this:

applicationInfo := &golatch.LatchApplicationInfo{
	Name: "Modified Application Name",
}

if err := latch.UpdateApplication("ApplicationID here", applicationInfo); err != nil {
	fmt.Println(err)
}

Because of the way the API works, only non empty values will be modified. For example if you don't fill the ContactPhone field and that field has a value, it will retain that value after the update.

Delete an application

You can delete an existing application using the DeleteApplication() function:

if err := latch.DeleteApplication("ApplicationID"); err == nil {
	//Application was deleted successfully!
}
Subscription

You can get your current subscription information using the Subscription() method:

if response, err := latch.Subscription(); err == nil {
	ID := response.ID()
	applications := response.Applications()
	users := response.Users()
	operations := response.Operations()
}

This method will return a struct of type LatchSubscriptionResponse with the following methods (that you can use to get information about your subscription):

  • ID(): Gets the ID of your account/subscription type (for example "vip" for a VIP account).
  • Applications(): Returns a struct of type LatchSubscriptionUsage with the following fields:
    • InUse: Number of applications currently being used.
    • Limit: Max number of applications that you can create (-1 for no limit).
  • Users(): Returns a struct of type LatchSubscriptionUsage with the current number of users (InUse) and max number of users allowed (Limit).
  • Operations(): Returns a map of LatchSubscriptionUsage keyed by application name that contains the current number of operations (InUse) and the max number of operations for each application (Limit).

Tests

You can run unit tests for this package using:

$ go test golatch

Documentation

Documentation is provided by godoc as usual:

$ godoc golatch

You can also view the godoc's HTML documentation starting a web server (godoc -http=:6060) and navigating to the URL http://localhost:6060/pkg/golatch/.

Aditionally you can browse the documentation online here.

Contributions

All contributions are welcome! This is my first Go package ever, so if you're an experienced Go developer and want to share some advice or suggest any improvement to the code it will be greatly appreciated.

Documentation

Index

Constants

View Source
const (
	//Latch related constants
	API_URL                                  = "https://latch.elevenpaths.com"
	API_PATH                                 = "/api"
	API_VERSION                              = "1.0"
	API_CHECK_STATUS_ACTION                  = "status"
	API_PAIR_ACTION                          = "pair"
	API_PAIR_WITH_ID_ACTION                  = "pairWithId"
	API_UNPAIR_ACTION                        = "unpair"
	API_LOCK_ACTION                          = "lock"
	API_UNLOCK_ACTION                        = "unlock"
	API_HISTORY_ACTION                       = "history"
	API_OPERATION_ACTION                     = "operation"
	API_APPLICATION_ACTION                   = "application"
	API_SUBSCRIPTION_ACTION                  = "subscription"
	API_NOOTP_SUFFIX                         = "nootp"
	API_SILENT_SUFFIX                        = "silent"
	API_AUTHENTICATION_METHOD                = "11PATHS"
	API_AUTHORIZATION_HEADER_NAME            = "Authorization"
	API_DATE_HEADER_NAME                     = "X-11Paths-Date"
	API_AUTHORIZATION_HEADER_FIELD_SEPARATOR = " "
	API_X_11PATHS_HEADER_PREFIX              = "X-11Paths-"
	API_X_11PATHS_HEADER_SEPARATOR           = ":"
	API_UTC_STRING_FORMAT                    = "2006-01-02 15:04:05" //format layout as defined here: http://golang.org/pkg/time/#pkg-constants

	//Possible values for the Two factor and Lock on request options
	//NOT_SET is used in the UpdateOperation() method to leave the existing value
	MANDATORY = "MANDATORY"
	OPT_IN    = "OPT_IN"
	DISABLED  = "DISABLED"
	NOT_SET   = ""

	//Possible status values for the latch
	LATCH_STATUS_ON  = "on"
	LATCH_STATUS_OFF = "off"

	//HTTP methods
	HTTP_METHOD_POST   = "POST"
	HTTP_METHOD_GET    = "GET"
	HTTP_METHOD_PUT    = "PUT"
	HTTP_METHOD_DELETE = "DELETE"

	//User agent
	HTTP_USER_AGENT = "Golatch 1.0"
)

Variables

This section is empty.

Functions

func GetLatchURL

func GetLatchURL(queryString string) *url.URL

Gets the complete url for a request

func NewLatchError

func NewLatchError(code int32, message string) error

Constructs a new error

Types

type Latch

type Latch struct {
	AppID     string
	SecretKey string
	LatchAPI
}

func NewLatch

func NewLatch(appID string, secretKey string) *Latch

Constructs a new Latch struct

func (*Latch) AddOperation

func (l *Latch) AddOperation(parentId string, name string, twoFactor string, lockOnRequest string) (response *LatchAddOperationResponse, err error)

Adds a new operation

func (*Latch) DeleteOperation

func (l *Latch) DeleteOperation(operationId string) (err error)

Deletes an existing operation

func (*Latch) History

func (l *Latch) History(accountId string, from t.Time, to t.Time) (response *LatchHistoryResponse, err error)

Gets the account's history between the from and to dates

func (*Latch) Lock

func (l *Latch) Lock(accountId string) (err error)

Locks an account, given it's account ID

func (*Latch) LockOperation

func (l *Latch) LockOperation(accountId string, operationId string) (err error)

Locks an operation, given it's account ID and oeration ID

func (*Latch) OperationStatus

func (l *Latch) OperationStatus(accountId string, operationId string, nootp bool, silent bool) (response *LatchStatusResponse, err error)

Gets the status of an operation, given it's account ID and operation ID If nootp is true, the one time password won't be included in the response If silent is true Latch will not send push notifications to the client (requires SILVER, GOLD or PLATINUM subscription)

func (*Latch) Pair

func (l *Latch) Pair(token string) (response *LatchPairResponse, err error)

Pairs an account with the provided pairing token

func (*Latch) ShowOperation

func (l *Latch) ShowOperation(operationId string) (response *LatchShowOperationResponse, err error)

Shows operations information If operationId is empty this function will retrieve all the operations of the app

func (*Latch) Status

func (l *Latch) Status(accountId string, nootp bool, silent bool) (response *LatchStatusResponse, err error)

Gets the status of an account, given it's account ID If nootp is true, the one time password won't be included in the response If silent is true Latch will not send push notifications to the client (requires SILVER, GOLD or PLATINUM subscription)

func (*Latch) StatusRequest

func (l *Latch) StatusRequest(query string) (response *LatchStatusResponse, err error)

Performs a status request (application or operation) against the query URL provided Returns a LatchStatusResponse struct on success

func (*Latch) Unlock

func (l *Latch) Unlock(accountId string) (err error)

Unlocks an account, given it's account ID

func (*Latch) UnlockOperation

func (l *Latch) UnlockOperation(accountId string, operationId string) (err error)

Unlocks an operation, given it's account ID and oeration ID

func (*Latch) Unpair

func (l *Latch) Unpair(accountId string) (err error)

Unpairs an account, given it's account ID

func (*Latch) UpdateOperation

func (l *Latch) UpdateOperation(operationId string, name string, twoFactor string, lockOnRequest string) (err error)

Updates an existing operation

type LatchAPI

type LatchAPI struct {
	Proxy             *url.URL
	OnRequestStart    func(request *LatchRequest)
	OnResponseReceive func(request *LatchRequest, response *http.Response, responseBody string)
}

func (*LatchAPI) DoRequest

func (l *LatchAPI) DoRequest(request *LatchRequest, responseType LatchResponse) (response *LatchResponse, err error)

func (*LatchAPI) SetProxy

func (l *LatchAPI) SetProxy(proxyURL *url.URL)

Sets the proxy URL to be used in all requests to the API

type LatchAddApplicationResponse

type LatchAddApplicationResponse struct {
	Data struct {
		AppID  string `json:"applicationId"`
		Secret string `json:"secret"`
	} `json:"data"`
}

func (*LatchAddApplicationResponse) AppID

func (*LatchAddApplicationResponse) Secret

func (l *LatchAddApplicationResponse) Secret() string

func (*LatchAddApplicationResponse) Unmarshal

func (l *LatchAddApplicationResponse) Unmarshal(Json string) (err error)

type LatchAddOperationResponse

type LatchAddOperationResponse struct {
	Data struct {
		OperationId string `json:"operationId"`
	} `json:"data"`
}

func (*LatchAddOperationResponse) OperationId

func (l *LatchAddOperationResponse) OperationId() string

func (*LatchAddOperationResponse) Unmarshal

func (l *LatchAddOperationResponse) Unmarshal(Json string) (err error)

type LatchApplication

type LatchApplication struct {
	Status   string `json:"status"`
	PairedOn int64  `json:"pairedOn"`
	LatchApplicationInfo
}

type LatchApplicationInfo

type LatchApplicationInfo struct {
	Name          string                    `json:"name"`
	Description   string                    `json:"description"`
	Secret        string                    `json:"secret"`
	ImageURL      string                    `json:"imageURL"`
	ContactPhone  string                    `json:"contactPhone"`
	ContactEmail  string                    `json:"contactEmail"`
	TwoFactor     string                    `json:"two_factor"`
	LockOnRequest string                    `json:"lock_on_request"`
	Operations    map[string]LatchOperation `json:"operations"`
}

type LatchClientVersion

type LatchClientVersion struct {
	Platform string `json:platform`
	App      string `json:app`
}

type LatchError

type LatchError struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

func (*LatchError) Error

func (e *LatchError) Error() string

Implementation of the error interface

type LatchErrorResponse

type LatchErrorResponse struct {
	Err LatchError `json:"error"`
}

func (*LatchErrorResponse) Unmarshal

func (l *LatchErrorResponse) Unmarshal(Json string) error

type LatchHistoryEntry

type LatchHistoryEntry struct {
	Time      int64  `json:"t"`
	Action    string `json:"action"`
	What      string `json:"what"`
	Value     string `json:"value"`
	Was       string `json:"was"`
	Name      string `json:"name"`
	UserAgent string `json:"userAgent"`
	IP        string `json:"ip"`
}

type LatchHistoryResponse

type LatchHistoryResponse struct {
	AppID string
	Data  struct {
		Application   LatchApplication     `json:"application"`
		LastSeen      int64                `json:"lastSeen"`
		ClientVersion []LatchClientVersion `json:"clientVersion"`
		HistoryCount  int                  `json:"count"`
		History       []LatchHistoryEntry  `json:"history"`
	} `json:"data"`
}

func (*LatchHistoryResponse) Application

func (l *LatchHistoryResponse) Application() LatchApplication

func (*LatchHistoryResponse) ClientVersion

func (l *LatchHistoryResponse) ClientVersion() []LatchClientVersion

func (*LatchHistoryResponse) History

func (l *LatchHistoryResponse) History() []LatchHistoryEntry

func (*LatchHistoryResponse) HistoryCount

func (l *LatchHistoryResponse) HistoryCount() int

func (*LatchHistoryResponse) LastSeen

func (l *LatchHistoryResponse) LastSeen() int64

func (*LatchHistoryResponse) Unmarshal

func (l *LatchHistoryResponse) Unmarshal(Json string) (err error)

type LatchOperation

type LatchOperation struct {
	Name          string                    `json:"name"`
	Status        string                    `json:"status"`
	TwoFactor     string                    `json:"two_factor"`
	LockOnRequest string                    `json:"lock_on_request"`
	Operations    map[string]LatchOperation `json:"operations"`
}

type LatchOperationStatus

type LatchOperationStatus struct {
	Status     string                          `json:"status"`
	TwoFactor  LatchTwoFactor                  `json:"two_factor"`
	Operations map[string]LatchOperationStatus `json:"operations"`
}

type LatchPairResponse

type LatchPairResponse struct {
	Data struct {
		AccountId string `json:"accountId"`
	} `json:"data"`
}

func (*LatchPairResponse) AccountId

func (l *LatchPairResponse) AccountId() string

func (*LatchPairResponse) Unmarshal

func (l *LatchPairResponse) Unmarshal(Json string) error

type LatchRequest

type LatchRequest struct {
	AppID      string
	SecretKey  string
	HttpMethod string
	URL        *url.URL
	XHeaders   map[string]string
	Params     url.Values
	Date       time.Time
}

func NewLatchRequest

func NewLatchRequest(appID string, secretKey string, httpMethod string, url *url.URL, xHeaders map[string]string, params url.Values, date time.Time) *LatchRequest

Returns a new LatchRequest initialized with the parameters provided

func (*LatchRequest) GetAuthenticationHeaders

func (l *LatchRequest) GetAuthenticationHeaders() (headers map[string]string)

Gets the authentication headers (Authorization and Date)

func (*LatchRequest) GetAuthorizationHeader

func (l *LatchRequest) GetAuthorizationHeader() string

Gets the Authorization header

func (*LatchRequest) GetFormattedDate

func (l *LatchRequest) GetFormattedDate() string

Gets the current UTC Date/Time as a string formatted using the layout specified in const(API_UTC_STRING_FORMAT)

func (*LatchRequest) GetHttpRequest

func (l *LatchRequest) GetHttpRequest() *http.Request

Gets the HTTP request for this Latch Request

func (*LatchRequest) GetRequestSignature

func (l *LatchRequest) GetRequestSignature() string

Gets the request signature

func (*LatchRequest) GetSerializedHeaders

func (l *LatchRequest) GetSerializedHeaders() string

Gets the serialized request headers (xHeaders) to use in the request signature

func (*LatchRequest) GetSerializedParams

func (l *LatchRequest) GetSerializedParams() string

Gets the serialized request headers (xHeaders) to use in the request signature

func (*LatchRequest) GetSignedRequestSignature

func (l *LatchRequest) GetSignedRequestSignature() string

Gets the signed request signature using HMAC-SHA1 (base64-encoded)

type LatchResponse

type LatchResponse interface {
	Unmarshal(Json string) error
}

type LatchShowApplicationsResponse

type LatchShowApplicationsResponse struct {
	Data struct {
		Applications map[string]LatchApplicationInfo `json:"operations"`
	} `json:"data"`
}

func (*LatchShowApplicationsResponse) Applications

func (*LatchShowApplicationsResponse) Unmarshal

func (l *LatchShowApplicationsResponse) Unmarshal(Json string) (err error)

type LatchShowOperationResponse

type LatchShowOperationResponse struct {
	Data struct {
		Operations map[string]LatchOperation `json:"operations"`
	} `json:"data"`
}

func (*LatchShowOperationResponse) FirstOperation

func (l *LatchShowOperationResponse) FirstOperation() (operationId string, operation LatchOperation)

func (*LatchShowOperationResponse) Operations

func (l *LatchShowOperationResponse) Operations() (operations map[string]LatchOperation)

func (*LatchShowOperationResponse) Unmarshal

func (l *LatchShowOperationResponse) Unmarshal(Json string) (err error)

type LatchStatusResponse

type LatchStatusResponse struct {
	Data struct {
		Operations map[string]LatchOperationStatus `json:"operations"`
	} `json:"data"`
}

func (*LatchStatusResponse) GetParentOperation

func (l *LatchStatusResponse) GetParentOperation() (operation LatchOperationStatus)

func (*LatchStatusResponse) Operations

func (l *LatchStatusResponse) Operations() map[string]LatchOperationStatus

func (*LatchStatusResponse) Status

func (l *LatchStatusResponse) Status() string

func (*LatchStatusResponse) TwoFactor

func (l *LatchStatusResponse) TwoFactor() LatchTwoFactor

func (*LatchStatusResponse) Unmarshal

func (l *LatchStatusResponse) Unmarshal(Json string) (err error)

type LatchSubscriptionResponse

type LatchSubscriptionResponse struct {
	Data struct {
		Subscription struct {
			ID           string                            `json:"id"`
			Applications LatchSubscriptionUsage            `json:"applications"`
			Operations   map[string]LatchSubscriptionUsage `json:"operations"`
			Users        LatchSubscriptionUsage            `json:"users"`
		} `json:"subscription"`
	} `json:"data"`
}

func (*LatchSubscriptionResponse) Applications

func (*LatchSubscriptionResponse) ID

func (*LatchSubscriptionResponse) Operations

func (*LatchSubscriptionResponse) Unmarshal

func (l *LatchSubscriptionResponse) Unmarshal(Json string) (err error)

func (*LatchSubscriptionResponse) Users

type LatchSubscriptionUsage

type LatchSubscriptionUsage struct {
	InUse int `json:"inUse"`
	Limit int `json:"limit"`
}

type LatchTwoFactor

type LatchTwoFactor struct {
	Token     string `json:"token"`
	Generated int64  `json:"generated"`
}

type LatchUser

type LatchUser struct {
	UserID    string
	SecretKey string
	LatchAPI
}

Struct to use the Latch User API

func NewLatchUser

func NewLatchUser(userID string, secretKey string) *LatchUser

Constructs a new LatchUser struct

func (*LatchUser) AddApplication

func (l *LatchUser) AddApplication(applicationInfo *LatchApplicationInfo) (response *LatchAddApplicationResponse, err error)

Adds a new application

func (*LatchUser) DeleteApplication

func (l *LatchUser) DeleteApplication(applicationId string) (err error)

Deletes an existing application

func (*LatchUser) ShowApplications

func (l *LatchUser) ShowApplications() (response *LatchShowApplicationsResponse, err error)

Shows existing applications

func (*LatchUser) Subscription

func (l *LatchUser) Subscription() (response *LatchSubscriptionResponse, err error)

Gets the user's subscription information

func (*LatchUser) UpdateApplication

func (l *LatchUser) UpdateApplication(appID string, applicationInfo *LatchApplicationInfo) (err error)

Updates application information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL