src

package
v0.0.0-...-2d984c1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIAccess

type APIAccess interface {
	Config(arr map[string]interface{})
	GetAPIURL(path string) string
	SetPath(path string)
	GetConfig() APIAccessStruct
	SetEndpoints(input []string)
	Send(path, input, payload string) map[string]interface{}
	Nonce() string
	Auth() string
	Post(input, payload string) map[string]interface{}
	GetEndpoints() []string
	Decode(result json.RawMessage) map[string]interface{}
}

APIAccess is interface that states which methods need to be implemented

type APIAccessStruct

type APIAccessStruct struct {
	Version   int
	Domain    string
	UserAgent string
	Path      string
	URL       string
	Endpoints []string
	Timeout   int64
	// contains filtered or unexported fields
}

APIAccessStruct is the object that will be implementing APIAcess interface

func New

func New(apiKey, apiSecret string) (apiAccessStruct *APIAccessStruct)

New is used as a constructor for APIAccessStruct, use it to create new APIAcess objects

func (*APIAccessStruct) Auth

func (apiAccessStruct *APIAccessStruct) Auth() (string, error)

Auth is a APIAccessStruct implementation of APIAccess interface function Auth It creates an authorization token passed to the API

func (*APIAccessStruct) Config

func (apiAccessStruct *APIAccessStruct) Config(arr map[string]interface{})

Config is a ApiAccessStruct implementation of APIAccess interface function Config It receives a map of key-value pairs with which APIAccessStruct can be initialized

func (*APIAccessStruct) Decode

func (apiAccessStruct *APIAccessStruct) Decode(result json.RawMessage) (map[string]interface{}, error)

Decode is a APIAccessStruct implementation of APIAccess interface function Decode It decodes bytes passed as arguments

func (*APIAccessStruct) GetAPIURL

func (apiAccessStruct *APIAccessStruct) GetAPIURL(path string) string

GetAPIURL is a APIAccessStruct implementation of APIAccess interface function GetAPIURL It returns full API URL by concatenating domain name with api version and path

func (*APIAccessStruct) GetConfig

func (apiAccessStruct *APIAccessStruct) GetConfig() APIAccessStruct

GetConfig is a APIAccessStruct implementation of APIAccess interface function GetConfig It returns configuration set up inside APIAccessStruct

func (*APIAccessStruct) GetEndpoints

func (apiAccessStruct *APIAccessStruct) GetEndpoints() []string

GetEndpoints is a APIAccessStruct implementation of APIAccess interface function GetEndpoints It returns list of endpoints inside the APIAccessStruct object

func (*APIAccessStruct) Nonce

func (apiAccessStruct *APIAccessStruct) Nonce() string

Nonce is a APIAccessStruct implementation of APIAccess interface function Nonce It creates a nonce like given in requirements

func (*APIAccessStruct) Post

func (apiAccessStruct *APIAccessStruct) Post(input, payload map[string]interface{}) (*PostResponse, error)

Post is a APIAccessStruct implementation of APIAccess interface function Post It executes a Post request

func (*APIAccessStruct) Send

func (apiAccessStruct *APIAccessStruct) Send(path string, input, payload map[string]interface{}) (*PostResponse, error)

Send is a APIAccessStruct implementation of APIAccess interface function Send It sets the path for API call and executes the POST request to API

func (*APIAccessStruct) SetEndpoints

func (apiAccessStruct *APIAccessStruct) SetEndpoints(input map[string]interface{}) error

SetEndpoints is a APIAccessStruct implementation of APIAccess interface function SetEndpoints It is used to set endpoints of the APIAccessStruct to response received from calling POST with given input

func (*APIAccessStruct) SetPath

func (apiAccessStruct *APIAccessStruct) SetPath(path string)

SetPath is a APIAccessStruct implementation of APIAccess interface function SetPath It sets the path inside the struct to the one that is passed as argument

type PostResponse

type PostResponse struct {
	Success  bool
	Returned map[string]interface{}
}

PostResponse contains data returned from POST request

Jump to

Keyboard shortcuts

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