synapse

package module
v0.0.0-...-527a6cd Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

SynapseFI Go Library

status

Go-based API wrapper for Synapse REST API. This library handles the user authentication process. As long as the user's fingerprint is registered, further authentication is not necessary in the development flow.

Documentation

Main Docs API Reference

Installation

$ go get github.com/SynapseFI/SynapseGo

main.go

import github.com/SynapseFI/SynapseGo

Examples

Refer to examples and our API documentation for examples.

Testing

To run test-mock or test-api:
  1. Add your credentials to "client_credentials.sample.json" and rename it "client_credentials.json"
To run test-api:
  1. Open the file "request_test.go" and change the value of "var userID string" to a user that was generated on your platform

Functions that mock the Synapse API:

make test-mock

Other functions including (limited) API requests:

make test-api

Documentation

Overview

Package synapse is a wrapper library for the Synapse API (https://docs.synapsefi.com)

Instantiate client

// credentials used to set headers for each method request
var client = synapse.New(
"CLIENT_ID",
"CLIENT_SECRET",
"IP_ADDRESS",
"FINGERPRINT",
)

Examples

Enable logging & turn off developer mode (developer mode is true by default)

var client = synapse.New(
"CLIENT_ID",
"CLIENT_SECRET",
"IP_ADDRESS",
"FINGERPRINT",
true,
false,
)

Register Fingerprint

// payload response
{
	"error": {
			"en": "Fingerprint not registered. Please perform the MFA flow."
	},
	"error_code": "10",
	"http_code": "202",
	"phone_numbers": [
			"developer@email.com",
			"901-111-2222"
	],
	"success": false
}

// Submit a valid email address or phone number from "phone_numbers" list
res, err := user.Select2FA("developer@email.com")

// MFA sent to developer@email.com
res, err := user.VerifyPIN("123456")

Set an `IDEMPOTENCY_KEY` (for `POST` requests only)

scopeSettings := `{
		"scope": [
			"USERS|POST",
			"USER|PATCH",
			"NODES|POST",
			"NODE|PATCH",
			"TRANS|POST",
			"TRAN|PATCH"
		],
		"url": "https://requestb.in/zp216zzp"
	}`

idempotencyKey := `1234567890`

data, err := client.CreateSubscription(scopeSettings, idempotencyKey)

Submit optional query parameters

params := "per_page=3&page=2"

data, err := client.GetUsers(params)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionNotAllowed

type ActionNotAllowed struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ActionNotAllowed represents ERROR_CODE 410 Action Not Allowed on the object (either you do not have permissions or the action on this object is not supported)

func (*ActionNotAllowed) Error

func (e *ActionNotAllowed) Error() string

type ActionPending

type ActionPending struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ActionPending represents ERROR_CODE 10 Accepted, but action pending

func (*ActionPending) Error

func (e *ActionPending) Error() string

type Client

type Client struct {
	ClientID     string
	ClientSecret string
	Fingerprint  string
	IP           string
	// contains filtered or unexported fields
}

Client represents the credentials used by the developer to instantiate a client

func New

func New(clientID, clientSecret, fingerprint, ipAddress string, modes ...bool) *Client

New creates a client object

func (*Client) CreateSubscription

func (c *Client) CreateSubscription(data string, idempotencyKey ...string) (map[string]interface{}, error)

CreateSubscription creates a subscription and returns the subscription data

func (*Client) CreateUser

func (c *Client) CreateUser(data, fingerprint, ipAddress string, idempotencyKey ...string) (*User, error)

CreateUser creates a single user and returns the new user data

func (*Client) GetCryptoMarketData

func (c *Client) GetCryptoMarketData() (map[string]interface{}, error)

GetCryptoMarketData returns market data for cryptocurrencies

func (*Client) GetCryptoQuotes

func (c *Client) GetCryptoQuotes(queryParams ...string) (map[string]interface{}, error)

GetCryptoQuotes returns all of the quotes for crypto currencies

func (*Client) GetInstitutions

func (c *Client) GetInstitutions() (map[string]interface{}, error)

GetInstitutions returns a list of all available banking institutions

func (*Client) GetNodes

func (c *Client) GetNodes(queryParams ...string) (map[string]interface{}, error)

GetNodes returns all of the nodes

func (*Client) GetPublicKey

func (c *Client) GetPublicKey(scope ...string) (map[string]interface{}, error)

GetPublicKey returns a public key as a token representing client credentials

func (*Client) GetSubscription

func (c *Client) GetSubscription(subscriptionID string) (map[string]interface{}, error)

GetSubscription returns a single subscription

func (*Client) GetSubscriptions

func (c *Client) GetSubscriptions(queryParams ...string) (map[string]interface{}, error)

GetSubscriptions returns all of the nodes associated with a user

func (*Client) GetTradeMarketData

func (c *Client) GetTradeMarketData(tickerSymbol string) (map[string]interface{}, error)

GetTradeMarketData returns data on a stock based on its ticker symbol

func (*Client) GetTransactions

func (c *Client) GetTransactions(queryParams ...string) (map[string]interface{}, error)

GetTransactions returns all client transactions

func (*Client) GetUser

func (c *Client) GetUser(userID, fingerprint, ipAddress string, queryParams ...string) (*User, error)

GetUser returns a single user

func (*Client) GetUsers

func (c *Client) GetUsers(queryParams ...string) (map[string]interface{}, error)

GetUsers returns a list of users

func (*Client) GetWebhookLogs

func (c *Client) GetWebhookLogs() (map[string]interface{}, error)

GetWebhookLogs returns all of the webhooks sent to a specific client

func (*Client) LocateATMs

func (c *Client) LocateATMs(queryParams ...string) (map[string]interface{}, error)

LocateATMs returns a list of nearby ATMs

func (*Client) UpdateSubscription

func (c *Client) UpdateSubscription(subscriptionID string, data string) (map[string]interface{}, error)

UpdateSubscription updates an existing subscription

func (*Client) VerifyAddress

func (c *Client) VerifyAddress(data string) (map[string]interface{}, error)

VerifyAddress checks if an address if valid

func (*Client) VerifyRoutingNumber

func (c *Client) VerifyRoutingNumber(data string) (map[string]interface{}, error)

VerifyRoutingNumber checks and returns the bank details of a routing number

type DefaultError

type DefaultError struct {
	ErrorCode string "000"
	HTTPCode  string "000"
	Message   string "Error code not found"
}

DefaultError represents an unhandled HTTP error Pass this instead of nil

func (*DefaultError) Error

func (e *DefaultError) Error() string

type IdempotencyConflict

type IdempotencyConflict struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

IdempotencyConflict represents ERROR_CODE 450 Idempotency key already in use

func (*IdempotencyConflict) Error

func (e *IdempotencyConflict) Error() string

type IncorrectClientCredentials

type IncorrectClientCredentials struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

IncorrectClientCredentials represents ERROR_CODE 100 Incorrect Client Credentials

func (*IncorrectClientCredentials) Error

type IncorrectUserCredentials

type IncorrectUserCredentials struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

IncorrectUserCredentials represents ERROR_CODE 110 Incorrect User Credentials

func (*IncorrectUserCredentials) Error

func (e *IncorrectUserCredentials) Error() string

type IncorrectValues

type IncorrectValues struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

IncorrectValues represents ERROR_CODE 400 Incorrect Values Supplied (eg. Insufficient balance, wrong MFA response, incorrect micro deposits)

func (*IncorrectValues) Error

func (e *IncorrectValues) Error() string

type ObjectNotFound

type ObjectNotFound struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ObjectNotFound represents ERROR_CODE 404 Object not found

func (*ObjectNotFound) Error

func (e *ObjectNotFound) Error() string

type PayloadError

type PayloadError struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

PayloadError represents ERROR_CODE 200 Error in Payload (Error in payload formatting)

func (*PayloadError) Error

func (e *PayloadError) Error() string

type Request

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

Request represents the http request client

func (*Request) Delete

func (req *Request) Delete(url string) ([]byte, error)

Delete performs a DELETE request

func (*Request) Get

func (req *Request) Get(url string, params []string) ([]byte, error)

Get performs a GET request

func (*Request) Patch

func (req *Request) Patch(url, data string, params []string) ([]byte, error)

Patch performs a PATCH request

func (*Request) Post

func (req *Request) Post(url, data string, params []string) ([]byte, error)

Post performs a POST request

type RequestFailed

type RequestFailed struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

RequestFailed represents ERROR_CODE 460 Request Failed but not due to server error

func (*RequestFailed) Error

func (e *RequestFailed) Error() string

type ResponseError

type ResponseError struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ResponseError represents an error returned by the SynapseFI API

type ServerError

type ServerError struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ServerError represents ERROR_CODE 500 Server Error

func (*ServerError) Error

func (e *ServerError) Error() string

type ServerTimeout

type ServerTimeout struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ServerTimeout represents ERROR_CODE 504 Server Timeout

func (*ServerTimeout) Error

func (e *ServerTimeout) Error() string

type ServiceUnavailable

type ServiceUnavailable struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

ServiceUnavailable represents ERROR_CODE 503 Service Unavailable. The server is currently unable to handle the request due to a temporary overload or scheduled maintenance.

func (*ServiceUnavailable) Error

func (e *ServiceUnavailable) Error() string

type TooManyRequests

type TooManyRequests struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

TooManyRequests represents ERROR_CODE 429 Too many requests hit the API too quickly.

func (*TooManyRequests) Error

func (e *TooManyRequests) Error() string

type UnauthorizedAction

type UnauthorizedAction struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

UnauthorizedAction represents ERROR_CODE 300 Unauthorized action (User/Client not allowed to perform this action)

func (*UnauthorizedAction) Error

func (e *UnauthorizedAction) Error() string

type UnauthorizedFingerprint

type UnauthorizedFingerprint struct {
	ErrorCode string `json:"errorCode"`
	HTTPCode  string `json:"httpCode"`
	Message   string `json:"message"`
}

UnauthorizedFingerprint represents ERROR_CODE 120 Unauthorized Fingerprint

func (*UnauthorizedFingerprint) Error

func (e *UnauthorizedFingerprint) Error() string

type User

type User struct {
	AuthKey      string
	UserID       string `mapstructure:"_id"`
	RefreshToken string `mapstructure:"refresh_token"`
	Response     interface{}
	// contains filtered or unexported fields
}

User represents a single user object

func (*User) Authenticate

func (u *User) Authenticate(data, fingerprint, ipAddress string) (map[string]interface{}, error)

Authenticate returns an oauth key and sets it to the user object If the refresh token is expired the API will automatically send a new one Capture refresh token every time

func (*User) CancelTransaction

func (u *User) CancelTransaction(nodeID, transactionID string) (map[string]interface{}, error)

CancelTransaction deletes/cancels a transaction

func (*User) CommentOnTransactionStatus

func (u *User) CommentOnTransactionStatus(nodeID, transactionID, data string, idempotencyKey ...string) (map[string]interface{}, error)

CommentOnTransactionStatus adds comment to the transaction status

func (*User) CreateDummyTransaction

func (u *User) CreateDummyTransaction(nodeID string, queryParams ...string) (map[string]interface{}, error)

CreateDummyTransaction triggers external dummy transactions on internal accounts

func (*User) CreateNode

func (u *User) CreateNode(data string, idempotencyKey ...string) (map[string]interface{}, error)

CreateNode creates a node depending on the type of node specified

func (*User) CreateNodeStatements

func (u *User) CreateNodeStatements(nodeID, data string, idempotencyKey ...string) (map[string]interface{}, error)

CreateNodeStatements creates ad-hoc statements for the specified node

func (*User) CreateSubnet

func (u *User) CreateSubnet(nodeID, data string, idempotencyKey ...string) (map[string]interface{}, error)

CreateSubnet creates a subnet object

func (*User) CreateTransaction

func (u *User) CreateTransaction(nodeID, data string, idempotencyKey ...string) (map[string]interface{}, error)

CreateTransaction creates a transaction for the specified node

func (*User) CreateUBO

func (u *User) CreateUBO(data string) (map[string]interface{}, error)

CreateUBO creates and uploads an Ultimate Beneficial Ownership (UBO) and REG GG form as a physical document under the Business’s base document

func (*User) DeleteNode

func (u *User) DeleteNode(nodeID string) (map[string]interface{}, error)

DeleteNode deletes a node

func (*User) DisputeTransaction

func (u *User) DisputeTransaction(nodeID, transactionID, data string) (map[string]interface{}, error)

DisputeTransaction disputes a transaction for a user

func (*User) GetApplePayToken

func (u *User) GetApplePayToken(nodeID, data string) (map[string]interface{}, error)

GetApplePayToken generates tokenized info for Apple Wallet

func (*User) GetNode

func (u *User) GetNode(nodeID string) (map[string]interface{}, error)

GetNode returns a single node object

func (*User) GetNodeStatements

func (u *User) GetNodeStatements(nodeID string, queryParams ...string) (map[string]interface{}, error)

GetNodeStatements gets all of the node statements

func (*User) GetNodeSubnets

func (u *User) GetNodeSubnets(nodeID string, queryParams ...string) (map[string]interface{}, error)

GetNodeSubnets gets all subnets associated with a node

func (*User) GetNodeTransactions

func (u *User) GetNodeTransactions(nodeID string, queryParams ...string) (map[string]interface{}, error)

GetNodeTransactions returns transactions associated with a node

func (*User) GetNodes

func (u *User) GetNodes(queryParams ...string) (map[string]interface{}, error)

GetNodes returns all of the nodes associated with a user

func (*User) GetRefreshToken

func (u *User) GetRefreshToken() (map[string]interface{}, error)

GetRefreshToken performs a GET request and returns a new refresh token

func (*User) GetStatements

func (u *User) GetStatements(queryParams ...string) (map[string]interface{}, error)

GetStatements gets all of the user statements

func (*User) GetSubnet

func (u *User) GetSubnet(nodeID, subnetID string) (map[string]interface{}, error)

GetSubnet gets a single subnet object

func (*User) GetSubnets

func (u *User) GetSubnets(queryParams ...string) (map[string]interface{}, error)

GetSubnets gets all subnets associated with a user

func (*User) GetTransaction

func (u *User) GetTransaction(nodeID, transactionID string) (map[string]interface{}, error)

GetTransaction returns a specific transaction associated with a node

func (*User) GetTransactions

func (u *User) GetTransactions(queryParams ...string) (map[string]interface{}, error)

GetTransactions returns transactions associated with a user

func (*User) RegisterFingerprint

func (u *User) RegisterFingerprint(fp string) (map[string]interface{}, error)

RegisterFingerprint submits a new fingerprint and triggers the MFA flow

func (*User) ReinitiateMicroDeposits

func (u *User) ReinitiateMicroDeposits(nodeID string) (map[string]interface{}, error)

ReinitiateMicroDeposits reinitiates micro-deposits for an ACH-US node with AC/RT

func (*User) ResetCardNode

func (u *User) ResetCardNode(nodeID string) (map[string]interface{}, error)

ResetCardNode resets the debit card number, card cvv, and expiration date

func (*User) Select2FA

func (u *User) Select2FA(device string) (map[string]interface{}, error)

Select2FA sends the 2FA device selection to the API

func (*User) ShipCard

func (u *User) ShipCard(nodeID, subnetID, data string) (map[string]interface{}, error)

ShipCard ships a physical debit card out to the user

func (*User) ShipCardNode

func (u *User) ShipCardNode(nodeID, data string) (map[string]interface{}, error)

ShipCardNode ships a physical debit card out to the user

func (*User) SubmitMFA

func (u *User) SubmitMFA(data string) (map[string]interface{}, error)

SubmitMFA submits the access token and mfa answer

func (*User) Update

func (u *User) Update(data string) (*User, error)

Update updates a single user and returns the updated user information

func (*User) UpdateNode

func (u *User) UpdateNode(nodeID, data string) (map[string]interface{}, error)

UpdateNode updates a node

func (*User) UpdateSubnet

func (u *User) UpdateSubnet(nodeID, subnetID, data string) (map[string]interface{}, error)

UpdateSubnet updates a subnet object

func (*User) VerifyMicroDeposit

func (u *User) VerifyMicroDeposit(nodeID, data string) (map[string]interface{}, error)

VerifyMicroDeposit verifies micro-deposit amounts for a node

func (*User) VerifyPIN

func (u *User) VerifyPIN(pin string) (map[string]interface{}, error)

VerifyPIN sends the requested pin to the API to complete the 2FA process

type Users

type Users struct {
	Limit      int64  `mapstructure:"limit"`
	Page       int64  `mapstructure:"page"`
	PageCount  int64  `mapstructure:"page_count"`
	UsersCount int64  `mapstructure:"users_count"`
	Users      []User `mapstructure:"users"`
}

Users represents a collection of user objects

Jump to

Keyboard shortcuts

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