request

package
v0.0.0-...-9e8ec43 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RefreshAuth

func RefreshAuth() bool

Types

type AccessToken

type AccessToken struct {
	Error        pixivstruct.Error `json:"error"`
	AccessToken  string            `json:"access_token"`
	ExpiresIn    int               `json:"expires_in"`
	TokenType    string            `json:"token_type"`
	Scope        string            `json:"scope"`
	RefreshToken string            `json:"refresh_token"`
	User         struct {
		ProfileImageUrls struct {
			Px16X16   string `json:"px_16x16"`
			Px50X50   string `json:"px_50x50"`
			Px170X170 string `json:"px_170x170"`
		} `json:"profile_image_urls"`
		ID                     string `json:"id"`
		Name                   string `json:"name"`
		Account                string `json:"account"`
		MailAddress            string `json:"mail_address"`
		IsPremium              bool   `json:"is_premium"`
		XRestrict              int    `json:"x_restrict"`
		IsMailAuthorized       bool   `json:"is_mail_authorized"`
		RequirePolicyAgreement bool   `json:"require_policy_agreement"`
	} `json:"user"`
	Response struct {
		AccessToken  string `json:"access_token"`
		ExpiresIn    int    `json:"expires_in"`
		TokenType    string `json:"token_type"`
		Scope        string `json:"scope"`
		RefreshToken string `json:"refresh_token"`
		User         struct {
			ProfileImageUrls struct {
				Px16X16   string `json:"px_16x16"`
				Px50X50   string `json:"px_50x50"`
				Px170X170 string `json:"px_170x170"`
			} `json:"profile_image_urls"`
			ID                     string `json:"id"`
			Name                   string `json:"name"`
			Account                string `json:"account"`
			MailAddress            string `json:"mail_address"`
			IsPremium              bool   `json:"is_premium"`
			XRestrict              int    `json:"x_restrict"`
			IsMailAuthorized       bool   `json:"is_mail_authorized"`
			RequirePolicyAgreement bool   `json:"require_policy_agreement"`
		} `json:"user"`
	} `json:"response"`
}

func ChromeDriverLogin

func ChromeDriverLogin() (*AccessToken, error)

type Request

type Request struct {
	Path   string            // API Path
	Mode   string            // GET, POST, PUT
	Header map[string]string // Request Header
	Query  map[string]string // Query Params
	Params url.Values        // init in url.Values
	// contains filtered or unexported fields
}

func (*Request) AddHeader

func (req *Request) AddHeader(key string, value string)

func (*Request) AddParams

func (req *Request) AddParams(key, value string) *Request

func (*Request) EncodeParams

func (req *Request) EncodeParams(datas ...map[string]string) string

func (*Request) GetParams

func (req *Request) GetParams(key string) string

func (*Request) Headers

func (req *Request) Headers()

func (*Request) NewRequest

func (req *Request) NewRequest(Head ...map[string]string) *Response

func (*Request) QueryData

func (req *Request) QueryData() io.ReadCloser

type Response

type Response struct {
	Response *http.Response // Response from http.DefaultClient.Do
	Request  *Request       // Request from type Request
	Body     io.ReadCloser  // Body from Response
	// contains filtered or unexported fields
}

func Get

func Get(
	url_api string,
	params map[string]string,
	Head ...map[string]string,
) *Response

func Post

func Post(
	url_api string,
	params map[string]string,
	Head ...map[string]string,
) *Response

func Put

func Put(
	url_api string,
	params map[string]string,
	Head ...map[string]string,
) *Response

func (*Response) Content

func (resp *Response) Content() []byte

func (*Response) GetBody

func (resp *Response) GetBody() io.ReadCloser

func (*Response) GetCookies

func (resp *Response) GetCookies() (cookies []*http.Cookie)

func (*Response) Json

func (resp *Response) Json(value interface{}) interface{}

func (*Response) Text

func (resp *Response) Text() string

Jump to

Keyboard shortcuts

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