uphold

package module
v0.0.0-...-2ac5c51 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Uphold Golang SDK

This repository contains a Golang implementation of the Uphold API (see https://uphold.com/en/developer/api/documentation).

The package is not yet feature complete. A list of supported APIs will be documented here.

Installation

go get github.com/kthomas/uphold-sdk-golang

Ideally, you should use a package manager such as glide, in which case you can run glide get github.com/kthomas/uphold-sdk-golang.

Supported APIs

The following Uphold APIs are currently supported by this package:

Applications

Not yet supported.

Authentication
Webapp Authorization

Documentation forthcoming.

Client Credentials

Documentation forthcoming.

One-Time Password

Not yet supported.

Currencies

Not yet supported.

Tickers

Not yet supported.

Entities

Not yet supported.

Accounts

Not yet supported.

Cards

Not yet supported.

Transactions

Not yet supported.

Contacts

Not yet supported.

Users

Not yet supported.

Transparency

Not yet supported.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPhone

func AddPhone(token, countryCode, phone string) error

AddPhone adds a phone to an uphold account

func AuthorizeClientCredentials

func AuthorizeClientCredentials(scope string) (*string, error)

AuthorizeClientCredentials synchronously authorizes an uphold API user using the environment-configured client id and secret

func CreateDocument

func CreateDocument(token, documentType string, value interface{}) error

CreateDocument upserts a document on behalf of an uphold account holder

func WebAuthorizationAllScopesURL

func WebAuthorizationAllScopesURL() string

WebAuthorizationAllScopesURL returns the webapp authorization URL requesting all supported scopes

func WebAuthorizationURL

func WebAuthorizationURL(scope string) string

WebAuthorizationURL returns the webapp authorization URL for the given scope

Types

type APIClient

type APIClient struct {
	Host     string
	Path     string
	Scheme   string
	Token    *string
	Username *string
	Password *string
}

APIClient is a generic base class for calling the uphold API

func NewUnauthorizedAPIClient

func NewUnauthorizedAPIClient(baseURI *string) (*APIClient, error)

NewUnauthorizedAPIClient initializes an APIClient without API credentials

func NewUpholdAPIClient

func NewUpholdAPIClient(token, baseURI *string) (*APIClient, error)

NewUpholdAPIClient initializes an APIClient using the environment-configured client id and secret to construct an HTTP basic authorization header, unless a non-nil bearer access token is provided.

func (*APIClient) Delete

func (c *APIClient) Delete(uri string) (status int, err error)

Delete constructs and synchronously sends an API DELETE request

func (*APIClient) Get

func (c *APIClient) Get(uri string, params map[string]interface{}, response interface{}) (status int, err error)

Get constructs and synchronously sends an API GET request

func (*APIClient) Post

func (c *APIClient) Post(uri string, params map[string]interface{}, response interface{}) (status int, err error)

Post constructs and synchronously sends an API POST request

func (*APIClient) PostWWWFormURLEncoded

func (c *APIClient) PostWWWFormURLEncoded(uri string, params map[string]interface{}, response interface{}) (status int, err error)

PostWWWFormURLEncoded constructs and synchronously sends an API POST request using

func (*APIClient) Put

func (c *APIClient) Put(uri string, params map[string]interface{}, response interface{}) (status int, err error)

Put constructs and synchronously sends an API PUT request

type Denomination

type Denomination struct {
	Amount   float64 `json:"amount"`
	Currency string  `json:"currency"`
	Pair     *string `json:"pair"`
	Rate     *string `json:"rate"`
}

Denomination describes the value being transacted, in terms of a specific currency

type Destination

type Destination struct {
	CardID      string  `json:"CardId"`      // the ID of the card credited. Only visible to the user who receives the transaction.
	Amount      float64 `json:"amount"`      // the amount credited, including commissions and fees.
	Base        float64 `json:"base"`        // the amount to credit, before commissions or fees.
	Comission   float64 `json:"comission"`   // the commission charged by Uphold to process the transaction. Commissions are only charged when currency is converted into a different denomination.
	Currency    string  `json:"currency"`    // the denomination of the funds at the time they were sent/received.
	Description *string `json:"description"` // the name of the recipient. In the case where money is sent via email, the description will contain the email address of the recipient.
	Fee         float64 `json:"fee"`         // the Bitcoin network Fee, if destination is a BTC address but origin is not.
	IsMember    *bool   `json:"isMember"`    // a boolean signaling if the destination user has completed the membership process.
	Node        *string `json:"node"`        // the details about the transaction destination node.
	Rate        *string `json:"rate"`        // the rate for conversion between origin and destination, as expressed in the currency at destination (the inverse of origin.rate).
	Type        *string `json:"type"`        //	the type of endpoint. Possible values are 'email’, 'card’ and 'external’.
}

Destination contains properites regarding how the transaction affects the destination of the funds

type Fee

type Fee struct {
	Amount     float64 `json:"amount"`
	Currency   string  `json:"currency"`
	Percentage *string `json:"percentage"`
	Target     *string `json:"target"`
	Type       *string `json:"type"`
}

Fee describes an applied transaction fee

type Normalized

type Normalized struct {
	Amount    float64 `json:"amount"`    // the amount to be transacted.
	Comission float64 `json:"comission"` // the total commission taken on this transaction, either at origin or at destination.
	Currency  string  `json:"currency"`  // the currency in which the amount and commission are expressed. The value is always USD.
	Fee       float64 `json:"fee"`       // the normalized fee amount.
	Rate      *string `json:"rate"`      // the exchange rate for this pair.
	Target    *string `json:"type"`      //	can be origin or destination and determines where the fee was applied.
}

Normalized tx property contains the normalized amount and commission values in USD

type OAuthResponse

type OAuthResponse struct {
	AccessToken  *string `json:"access_token"`
	ExpiresIn    *string `json:"expires_in"`
	TokenType    *string `json:"token_type"`
	RefreshToken *string `json:"refresh_token"`
	Scope        *string `json:"scope"`
}

OAuthResponse is the API response returned when an authorization code has been successfully upgraded to an access token

func AuthorizeBearerToken

func AuthorizeBearerToken(code string) (*OAuthResponse, error)

AuthorizeBearerToken synchronously authorizes a managed uphold API user using the environment-configured client id/secret and the given authorization code; note that it is the responsibility of the calling package to verify the provided state parameter, which should be a cryptographically secure random string used to protect against cross-site request forgery attacks. Packages which fail to verify the integrity of the state parameter provided alongside the code parameter passed into this function are vulnerable.

type Origin

type Origin struct {
	CardID      string              `json:"CardId"`      // the ID of the card debited. Only visible to the user who sends the transaction.
	Amount      float64             `json:"amount"`      // the amount debited, including commissions and fees.
	Base        float64             `json:"base"`        // the amount to debit, before commissions or fees.
	Comission   float64             `json:"comission"`   // the commission charged by Uphold to process the transaction.
	Currency    string              `json:"currency"`    // the currency of the funds at the origin.
	Description *string             `json:"description"` // the name of the sender.
	Fee         float64             `json:"fee"`         // the Bitcoin network Fee, if origin is in BTC but destination is not, or is a non-Uphold Bitcoin Address.
	IsMember    *bool               `json:"isMember"`    // a boolean signaling if the origin user has completed the membership process.
	Node        *string             `json:"node"`        // the details about the transaction origin node.
	Rate        *string             `json:"rate"`        // the rate for conversion between origin and destination, as expressed in the currency at origin (the inverse of destination.rate).
	Type        *string             `json:"type"`        //	the type of endpoint. Possible values are 'card’ and 'external’.
	Sources     []map[string]string `json:"sources"`     // the transactions where the value was originated from (id and amount).
	Username    string              `json:"username"`    // the username from the user that performed the transaction.
}

Origin contains properties regarding how the transaction affects the origin of the funds

type Transaction

type Transaction struct {
	ID           *uuid.UUID       `json:"id"`           // a unique ID on the Uphold Network associated with the transaction.
	CreatedAt    *time.Time       `json:"createdAt"`    // the date and time the transaction was initiated.
	Application  *string          `json:"application"`  // the application that created the transaction.
	Denomination *Denomination    `json:"denomination"` // a message or note provided by the user at the time the transaction was initiated, with the intent of communicating additional information and context about the nature/purpose of the transaction.
	Destination  *Destination     `json:"destination"`  // the funds to be transferred, as originally requested.
	Origin       *Origin          `json:"origin"`       // the fees that were applied to the transaction.
	Normalized   *Normalized      `json:"normalized"`   // the transaction details in USD.
	Fees         []*Fee           `json:"fees"`         // the fees that were applied to the transaction.
	Message      *string          `json:"message"`      // other parameters of this transaction.
	Network      *string          `json:"network"`      // the network of the transaction (uphold for internal transactions).
	Priority     *string          `json:"priority"`     // the priority of the transaction. Possible values are normal and fast.
	Reference    *string          `json:"reference"`    // A reference assigned to the transaction.
	Params       *json.RawMessage `json:"params"`       // other parameters of this transaction.
	Status       *string          `json:"status"`       // the current status of the transaction. Possible values are: pending, waiting, cancelled or completed.
	Type         *string          `json:"type"`         // the nature of the transaction. Possible values are deposit, transfer and withdrawal.
}

Transaction represents an uphold card transaction

func CommitTransaction

func CommitTransaction(token, cardID, transactionID string) (*Transaction, error)

CommitTransaction commits a previously quoted transaction

func CreateTransaction

func CreateTransaction(token, cardID, currency, destination string, amount float64) (*Transaction, error)

CreateTransaction submits a transaction to the Uphold platform but does not commit it for settlement

type User

type User struct {
	ID            *string                `json:"id"`
	Email         *string                `json:"email"`
	Username      *string                `json:"username"`
	FirstName     *string                `json:"firstName"`
	LastName      *string                `json:"lastName"`
	Name          *string                `json:"name"`
	Birthdate     *string                `json:"birthdate"`
	Currencies    []string               `json:"currencies"`
	Address       map[string]interface{} `json:"address"`
	State         *string                `json:"state"`
	Country       *string                `json:"country"`
	Settings      map[string]interface{} `json:"settings"`
	Status        *string                `json:"status"`
	MemberAt      *string                `json:"memberAt"`
	Balances      map[string]interface{} `json:"balances"`
	Verifications map[string]interface{} `json:"verifications"` // the transactions where the value was originated from (id and amount).
}

User represents an uphold user

func CreateUser

func CreateUser(email, password string, country, locale, accountType *string) (*User, error)

CreateUser creates a new Uphold user

func GetUser

func GetUser(token string) (*User, error)

GetUser fetches the user for the given bearer token

Jump to

Keyboard shortcuts

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