polynym

package module
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 9 Imported by: 0

README

go-polynym

The unofficial Go implementation for the Polynym API

Release Build Status Report codecov Go Sponsor Donate


Table of Contents


Installation

go-polynym requires a supported release of Go.

go get -u github.com/mrz1836/go-polynym

Documentation

View the generated documentation

GoDoc

Features
Library Deployment

goreleaser for easy binary or library deployment to Github and can be installed via: brew install goreleaser.

The .goreleaser.yml file is used to configure goreleaser.

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production.

Makefile Commands

View all makefile commands

make help

List of all current commands:

all                   Runs multiple commands
clean                 Remove previous builds and any test cache data
clean-mods            Remove all the Go mod cache
coverage              Shows the test coverage
diff                  Show the git diff
generate              Runs the go generate command in the base of the repo
godocs                Sync the latest tag with GoDocs
help                  Show this help message
install               Install the application
install-go            Install the application (Using Native Go)
install-releaser      Install the GoReleaser application
lint                  Run the golangci-lint application (install if not found)
release               Full production release (creates release in Github)
release               Runs common.release then runs godocs
release-snap          Test the full release (build binaries)
release-test          Full production test release (everything except deploy)
replace-version       Replaces the version in HTML/JS (pre-deploy)
run-examples          Runs all the examples
tag                   Generate a new tag and push (tag version=0.0.0)
tag-remove            Remove a tag if found (tag-remove version=0.0.0)
tag-update            Update an existing tag to current commit (tag-update version=0.0.0)
test                  Runs lint and ALL tests
test-ci               Runs all tests via CI (exports coverage)
test-ci-no-race       Runs all tests via CI (no race) (exports coverage)
test-ci-short         Runs unit tests via CI (exports coverage)
test-no-lint          Runs just tests
test-short            Runs vet, lint and tests (excludes integration tests)
test-unit             Runs tests and outputs coverage
uninstall             Uninstall the application (and remove files)
update-linter         Update the golangci-lint package (macOS only)
vet                   Run the Go vet application

Examples & Tests

All unit tests and examples run via Github Actions and uses Go version 1.16.x. View the configuration file.

Run all tests (including integration tests)

make test

Run tests (excluding integration tests)

make test-short

Benchmarks

Run the Go benchmarks:

make bench

Code Standards

Read more about this Go project's code standards.


Usage

View the polynym examples above

Basic implementation:

package main

import (
	"log"

	"github.com/mrz1836/go-polynym"
)

func main() {
	client := polynym.NewClient(nil)
	resp, _ := polynym.GetAddress(client, "mrz@relayx.io")

	log.Println("address: ", resp.Address)
}

Maintainers

MrZ
MrZ

Contributing

View the contributing guidelines and follow the code of conduct.

How can I help?

All kinds of contributions are welcome 🙌! The most basic way to show your support is to star 🌟 the project, or to raise issues 💬. You can also support this project by becoming a sponsor on GitHub 👏 or by making a bitcoin donation to ensure this journey continues indefinitely! 🚀

Stars

Credits

@Dean & BitPing for their hard work on the Polynym project

Looking for a Javascript version? Check out the Polynym npm package.


License

License

Documentation

Overview

Package polynym is the unofficial golang implementation for the Polynym API

Example:

// Create a new client client, _ := polynym.NewClient(nil)

// Get address resp, _ := client.GetAddress("1mrz")

// What's the address? log.Println("address:", resp.Address)

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandCashConvert added in v0.3.0

func HandCashConvert(handle string, isBeta bool) string

HandCashConvert now converts $handle to paymail: handle@handcash.io or handle@beta.handcash.io

Example

ExampleHandCashConvert example using HandCashConvert()

paymail := HandCashConvert("$mr-z", false)
fmt.Println(paymail)
Output:

mr-z@handcash.io

func RelayXConvert added in v0.4.3

func RelayXConvert(handle string) string

RelayXConvert now converts 1handle to paymail: handle@relayx.io

Example

ExampleHandCashConvert example using RelayXConvert()

paymail := RelayXConvert("1mr-z")
fmt.Println(paymail)
Output:

mr-z@relayx.io

Types

type Client

type Client struct {
	UserAgent string // (optional for changing user agents)
	// contains filtered or unexported fields
}

Client is the parent struct that wraps the heimdall client

func NewClient

func NewClient(options *Options) (c Client)

NewClient will make a new http client based on the options provided

Example

ExampleNewClient example using NewClient()

client := NewClient(nil)
fmt.Println(client.UserAgent)
Output:

go-polynym: v0.4.7

type GetAddressResponse

type GetAddressResponse struct {
	Address      string       `json:"address"`
	ErrorMessage string       `json:"error"`
	LastRequest  *LastRequest `json:"-"`
}

GetAddressResponse is what polynym returns (success or fail)

func GetAddress added in v0.3.0

func GetAddress(client Client, handleOrPaymail string) (response *GetAddressResponse, err error)

GetAddress returns the address of a given 1handle, $handcash, paymail, Twetch user id or BitcoinSV address

Example

ExampleGetAddress example using GetAddress()

client := newMockClient(defaultUserAgent)
resp, _ := GetAddress(client, "16ZqP5Tb22KJuvSAbjNkoiZs13mmRmexZA")
fmt.Println(resp.Address)
Output:

16ZqP5Tb22KJuvSAbjNkoiZs13mmRmexZA

type LastRequest

type LastRequest struct {
	Method     string `json:"method"`      // Method is the HTTP method used
	StatusCode int    `json:"status_code"` // StatusCode is the last code from the request
	URL        string `json:"url"`         // URL is the url used for the request
}

LastRequest is used to track what was submitted via the Request

type Options added in v0.2.0

type Options struct {
	BackOffExponentFactor          float64       `json:"back_off_exponent_factor"`
	BackOffInitialTimeout          time.Duration `json:"back_off_initial_timeout"`
	BackOffMaximumJitterInterval   time.Duration `json:"back_off_maximum_jitter_interval"`
	BackOffMaxTimeout              time.Duration `json:"back_off_max_timeout"`
	DialerKeepAlive                time.Duration `json:"dialer_keep_alive"`
	DialerTimeout                  time.Duration `json:"dialer_timeout"`
	RequestRetryCount              int           `json:"request_retry_count"`
	RequestTimeout                 time.Duration `json:"request_timeout"`
	TransportExpectContinueTimeout time.Duration `json:"transport_expect_continue_timeout"`
	TransportIdleTimeout           time.Duration `json:"transport_idle_timeout"`
	TransportMaxIdleConnections    int           `json:"transport_max_idle_connections"`
	TransportTLSHandshakeTimeout   time.Duration `json:"transport_tls_handshake_timeout"`
	UserAgent                      string        `json:"user_agent"`
}

Options holds all the configuration for connection, dialer and transport

func ClientDefaultOptions added in v0.2.0

func ClientDefaultOptions() (clientOptions *Options)

ClientDefaultOptions will return an clientOptions struct with the default settings Useful for starting with the base defaults and then modifying as needed

Directories

Path Synopsis
Package main is an example package using go-polynym
Package main is an example package using go-polynym

Jump to

Keyboard shortcuts

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