Skip to content

Latest commit

 

History

History
719 lines (593 loc) · 15.6 KB

examples.md

File metadata and controls

719 lines (593 loc) · 15.6 KB

Table of Contents

General Examples

Query Parameters

Query parameters must be of type string and follow the following pattern: key=value&key=value&key=value

// Get Users with query parameters
data, err := client.GetUsers("per_page=3&page=2")

// Get User with full dehydrate
user, err := client.GetUser("5bec6ebebaabfc00ab168fa0", "TEST_FINGERPRINT", "127.0.0.1", "full_dehydrate=yes")

Client Examples

Client

Initialize Client

// credentials used to set headers for each method request
var client = synapse.New(
"client_id_1239ABCdefghijk1092312309",
"client_secret_1239ABCdefghijk1092312309",
"1023918209480asdf8341098",
"1.2.3.132",
)

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

	var client = synapse.New(
	"CLIENT_ID",
  "CLIENT_SECRET",
	"FINGERPRINT",  
	"IP_ADDRESS",
	true,     // set to `false` to disable logging
	false,    // set to `true` to enable developer mode
	)

Authentication (Client)

Get Public Key

scope := "OAUTH|POST,USERS|POST,USERS|GET,USER|GET,USER|PATCH"

data, err := client.GetPublicKey(scope)

// (You can pass an optional user ID in the 2nd positional argument for a 24 hour key)

userId := "User ID Here"

data, err := client.GetPublicKey(scope, userId)

Nodes (Client)

Get Client Nodes

data, err := client.GetNodes()

Get Trade Market Data

data, err := client.GetTradeMarketData("AAPL")

Other (Client)

Get Crypto Market Data

data, err := client.GetCryptoMarketData()

GetCryptoQuotes

data, err := client.GetCryptoQuotes()

Get Institutions

data, err := client.GetInstitutions()

Locate ATMs

data, err = client.LocateATMs()

Verify Routing Number

body := `{
  "routing_num": "084008426",
  "type": "ACH-US"
}`

data, err := client.VerifyRoutingNumber(body)

Verify Address

address := `{
  "address_street": "170 St Germain St",
  "address_city": "SF",
  "address_subdivision": "CA",
  "address_country_code": "US",
  "address_postal_code": "94404"
}`
data, err := client.VerifyAddress(address)

Subscriptions (Client)

Get Client Subscriptions

data, err := client.GetSubscriptions()

Get Subscription

subsID := "589b6adec83e17002122196c"

data, err := client.GetSubscription(subsID)

Create Subscription

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

idempotencykey := "123456789"

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

Update Subscription

subID := "589b6adec83e17002122196c"
body := `{
    "scope": [
        "USERS|POST",
        "USER|PATCH",
        "NODES|POST",
        ...
      ]
    }`

data, err := client.UpdateSubscription(subID, body)

Get Subscription Logs

data, err := client.GetWebhookLogs()

Transactions (Client)

Get Client Transactions

data, err := client.GetTransactions()

Users (Client)

Get Users

data, err := client.GetUsers()

Get User

// set FullDehydrate to true
userID = "594e0fa2838454002ea317a0"
userFingerprint = "TEST_FINGERPRINT" // or client.Fingerprint
userIP = "127.0.0.1" // or client.IP

user, err := client.GetUser(userID, userFingerprint, userIP)

Create User

body := `{
  "logins": [
    {
      "email": "[email protected]"
    }
  ],
  "phone_numbers": [
    "901.111.1111",
    "[email protected]"
  ],
  "legal_names": [
    "Test User"
  ],
  ...
}`

userFingerprint = "TEST_FINGERPRINT" // or client.Fingerprint
userIP = "127.0.0.1" // or client.IP

user, err := client.CreateUser(body, userFingerprint, userIP)

User Examples

Authentication

To perform user actions, users must be authenticated

  • If performing user actions with a new user (i.e. created during the current session), further authentication is not necessary
  • If performing user actions with any other user, please authenticate the user
  • User authentication is only required at the start of a new session (user.AuthKey == nil), the wrapper will handle future authentication sessions

Authenticate

body := `{
  "refresh_token":"refresh_Y5beJdBLtgvply3KIzrh72UxWMEqiTNoVAfDs98G",
  "scope":[
      "USER|PATCH",
      "USER|GET",
      ...
  ]
}`

userFingerprint = "TEST_FINGERPRINT" // or client.Fingerprint
userIP = "127.0.0.1" // or client.IP

data, err := user.Authenticate(body, userFingerprint, userIP)

Get Refresh Token

data, err := user.GetRefreshToken()

Register Fingerprint

// Submit a new fingerprint to be registered for the user
data, err := user.RegisterFingerprint("NEW_FINGERPRINT")
/*
{
	"error": {
		en": "Fingerprint not registered. Please perform the MFA flow."
	},
	"error_code": "10",
	"http_code": "202",
	"phone_numbers": [
		"[email protected]",
		"901-111-2222"
	],
	"success": false
}
*/

Select 2FA

// Submit a valid email address or phone number from "phone_numbers" list
data, err := user.Select2FA("[email protected]")

Submit MFA

body := `{
  "access_token":"fake_cd60680b9addc013ca7fb25b2b704ba82d3",
  "mfa_answer":"test_answer"
}`
data, err := user.SubmitMFA(body)

Verify PIN

// MFA sent to [email protected]
data, err := user.VerifyPIN("123456")

Nodes

Get Nodes

data, err := user.GetNodes()

Get Node

nodeID := "594e606212e17a002f2e3251"

data, err := user.GetNode(nodeID)

Create Node

Refer to the following docs for how to setup the payload for a specific Node type:

body := `{
  "type": "DEPOSIT-US",
  "info":{
      "nickname":"My Checking"
  }
}`

data, err := user.CreateNode(body)
Bank Login w/ MFA
body := `{
  "type": "ACH-US",
  "info":{
    "bank_id":"synapse_good",
    "bank_pw":"test1234",
    "bank_name":"fake"
  }
}`

data, err := user.CreateNode(body)

// parse `access_token` from `data`

// create MFA answer body

mfaBody := `{
  "access_token":"fake_cd60680b9addc013ca7fb25b2b704ba82d3",
  "mfa_answer":"test_answer"
}`

achData, achErr := user.SubmitMFA(mfaBody)

Update Node

nodeID := "5ba05ed620b3aa005882c52a"
body := `{
  "supp_id":"new_supp_id_1234"
}`

data, err := user.UpdateNode(nodeID, body)

Delete Node

nodeID := "594e606212e17a002f2e3251"

data, err := user.DeleteNode(nodeID)

Verify Micro Deposit

nodeID := "5ba05ed620b3aa005882c52a"
body := `{
  "micro":[0.1,0.1]
}`

data, err := user.VerifyMicroDeposit(nodeID, body)

Reinitiate Micro Deposits

nodeID := "5ba05ed620b3aa005882c52a"

data, err := user.ReinitiateMicroDeposits(nodeID)

Ship Card Node

nodeID := "5ba05ed620b3aa005882c52a"
body := `{
  "fee_node_id":"5ba05e7920b3aa006482c5ad",
  "expedite": True
}`

data, err := user.ShipCardNode(nodeID, body)

Reset Card Node

nodeID := "5ba05ed620b3aa005882c52a"

data, err := user.ResetCardNode(nodeID)

Get Apple Pay Token

nodeID := "5ba05ed620b3aa005882c52a"
body = `{
  "certificate": "your applepay cert",
  "nonce": "9c02xxx2",
  "nonce_signature": "4082f883ae62d0700c283e225ee9d286713ef74"
}`

data, err := user.GenerateApplePayToken(nodeID, body)

Statements

Get Statements

data, err := user.GetStatements()

Get Node Statements

nodeID := "594e606212e17a002f2e3251"

data, err := user.GetNodeStatements(nodeID)

Create Node Statements

nodeID := "5b4b2df145d1cc006d088f2e"
body := `{
  "date_start": 1525132800000,
  "date_end": 1525132800000,
  "webhook": "https://wh.synapsefi.com/gen_me_statement_001"
}`

data, err := user.CreateNodeStatements(nodeID, body)

Subnets

Get Subnets

data, err := user.GetSubnets()

Get Node Subnets

nodeID := "594e606212e17a002f2e3251"

data, err := user.GetNodeSubnets(nodeID, "page=4&per_page=10")

Get Subnet

nodeID := "594e606212e17a002f2e3251"
subID := "59c9f77cd412960028b99d2b"

data, err := user.GetSubnet(nodeID, subID)

Create Subnet

nodeID := "594e606212e17a002f2e3251"
body := `{
  "nickname":"Test AC/RT"
}`

data, err := user.CreateSubnet(nodeID, body)

Update Subnet

nodeID := "594e606212e17a002f2e3251"
subnetID := "5bc920f2fff373002bf0d51b"
body := `{
  "preferences": {
    "allow_foreign_transactions":true,
    "daily_atm_withdrawal_limit":10,
    "daily_transaction_limit":1000
  }
}`

data, err := user.UpdateSubnet(nodeID, subnetID, body)

Ship Card

nodeID := "594e606212e17a002f2e3251"
subnetID := "5bc920f2fff373002bf0d51b"
body := `{
  "fee_node_id":"5bba781485411800991b606b",
  "expedite":false,
  "card_style_id":"555"
}`

data, err := user.ShipCard(nodeID, subnetID, body)

Push to Wallet

Synapse Docs

nodeID := "594e606212e17a002f2e3251"
subnetID := "5bc920f2fff373002bf0d51b"
body := `{
		"type": "APPLE_PUSH",
		"nonce": "RH0jOQ==",
		"nonce_signature": "QNyNZuyDO...EFg/Q",
		"certificates": [
			"MIICzD....OPQ7"
		]
	}`

data, err := user.PushToWallet(nodeID, subnetID, body)

Get Card Shipment

nodeID := "594e606212e17a002f2e3251"
subnetID := "5bc920f2fff373002bf0d51b"

data, err := user.GetCardShipment(nodeID, subnetID)

Transactions

Get Transactions

data, err := user.GetTransactions()

Get Node Transactions

nodeID := "594e606212e17a002f2e3251"

data, err := user.GetNodeTransactions(nodeID)

Get Transaction

nodeID := "594e606212e17a002f2e3251"
transID := "594e72124599e8002fe62e4f"

data, err := user.GetTransaction(nodeID, transID)

Create Transaction

nodeID := "594e606212e17a002f2e3251"
body := `{
  "to": {
    "type": "ACH-US",
    "id": "594e6e6c12e17a002f2e39e4"
  },
  "amount": {
    "amount": 20.1,
    "currency": "USD"
  },
  "extra": {
    "ip": "192.168.0.1"
  }
}`

data, err := user.CreateTransaction(nodeID, body)

Cancel Transaction

nodeID := "594e606212e17a002f2e3251"
transID := "594e72124599e8002fe62e4f"

data, err := user.CancelTransaction(nodeID, transID)

Comment on Transaction Status

nodeID := "594e606212e17a002f2e3251"
transID := "594e72124599e8002fe62e4f"

data, err := user.CommentOnTransactionStatus(nodeID, transID, "Pending verification...")

Dispute Transaction

nodeID := "594e606212e17a002f2e3251"
transID := "594e72124599e8002fe62e4f"
body := `{
  "dispute_reason": "CHARGE_BACK"
}`

data, err := user.DisputeTransaction(nodeID, transID, body)

Create Dummy Transaction

nodeID := "594e606212e17a002f2e3251"
queryParams := "is_credit=YES&type=INTERCHANGE&subnetid=5caac735e1232a0029ee649c&foreign_transaction=NO"

data, err := user.CreateDummyTransaction(nodeID, queryParams)

Users

Update User or Update/Add Documents

body := `{
  "update":{
    "login":{
      "email":"[email protected]"
    },
    "remove_login":{
      "email":"[email protected]"
    },
    "phone_number":"901-111-2222",
    "remove_phone_number":"901.111.1111"
    }
}`

data, err := user.Update(body)

Generate UBO

body := `{
   "entity_info": {
      "cryptocurrency": True,
      "msb": {
         "federal": True,
         "states": ["AL"]
      },
      "public_company": False,
      "majority_owned_by_listed": False,
      "registered_SEC": False,
      "regulated_financial": False,
      "gambling": False,
      "document_id": "2a4a5957a3a62aaac1a0dd0edcae96ea2cdee688ec6337b20745eed8869e3ac8"
   ...
}`

data, err := user.CreateUBO(body)