api

package
v0.0.0-...-ae089e8 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Oauth       *oauth2.Config
	Legged      *clientcredentials.Config
	QueryValues url.Values
	Types       int
	Code        string
	State       string
	AuthOpt     []oauth2.AuthCodeOption
	AuthExange  []oauth2.AuthCodeOption
	AuthStyle   int

	Connector Connector
	Headers   map[string]string
	Param     map[string]string
	Token     *oauth2.Token
	Host      string
	Client    *http.Client
	// contains filtered or unexported fields
}

Client is the request client

func (*Client) AddConnector

func (c *Client) AddConnector(connect Connector)

AddConnector add interface to client obj

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) (err error)

Authentification ask autorisation api

func (*Client) Body

func (c *Client) Body(payload interface{}) (body []byte, err error)

Body return []byte array for body send

func (*Client) Delete

func (f *Client) Delete(path string, body interface{}) (resp *http.Response, err error)

Delete create Delete request

func (*Client) Do

func (f *Client) Do(urls string, body []byte, types string) (resp *http.Response, err error)

Do create request with parameter

func (*Client) Get

func (f *Client) Get(path string, body interface{}) (resp *http.Response, err error)

Get Create Get request

func (*Client) GetURL

func (c *Client) GetURL() (url string)

GetURL return the url to call for authenticate

func (*Client) Parameter

func (c *Client) Parameter(u *http.Request) (r *http.Request)

Parameter add parameter in url example: "foo.html?tag=12"

func (*Client) Post

func (f *Client) Post(path string, body interface{}) (resp *http.Response, err error)

Post make Post request

func (*Client) Put

func (f *Client) Put(path string, body interface{}) (resp *http.Response, err error)

Put create Put request

func (*Client) Refresh

func (c *Client) Refresh(ctx context.Context)

func (*Client) SetCode

func (c *Client) SetCode(code string)

SetCode set Code string

func (*Client) SetHeader

func (c *Client) SetHeader(a, b string)

SetHeader add value to the header

func (*Client) SetParameter

func (c *Client) SetParameter(a, b string)

SetParameter add parametre

func (*Client) SetState

func (c *Client) SetState(state string)

SetState set state string

func (*Client) UnsetAllHeader

func (c *Client) UnsetAllHeader()

UnsetAllHeader destroy header

func (*Client) UnsetAllParam

func (c *Client) UnsetAllParam()

UnsetAllParam delete all parameter

func (*Client) UnsetHeader

func (c *Client) UnsetHeader(b string)

UnsetHeader delete on element of the header

func (*Client) UnsetParameter

func (c *Client) UnsetParameter(b string)

UnsetParameter unset one parameter

type Config

type Config struct {
	Types   int               `json:"type"`
	Oauth   Oauth             `json:"oauth"`
	Host    string            `json:"url"`
	BaseURL string            `json:"baseurl"`
	Key     string            `json:"key"`
	Headers map[string]string `json:"headers"`
	Param   map[string]string `json:"param"`
	Body    []byte            `json:"body"`
	Code    string            `json:"code"`
	State   string            `json:"state"`
}

Config represent the request

func NewConfig

func NewConfig(data []byte) (a *Config, err error)

New Config create APIConfig obj

func (*Config) NewClient

func (a *Config) NewClient() (c *Client, err error)

NewClient create new client obj

type Connector

type Connector interface {
	Connect(*Client) error
	Verify(*Client) error
}

Connector Is for interface connector

type Oauth

type Oauth struct {
	AuthParam    map[string]string
	AuthExange   map[string]string
	RedirectURL  string
	ClientID     string
	QV           map[string]string
	AuthStyle    int
	Scopes       []string
	AuthURL      string
	TokenURL     string
	ClientSecret string
}

Oauth is the oauth value of client

type Tok

type Tok struct {
	Token        string
	RefreshToken string
}

Jump to

Keyboard shortcuts

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