request

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: MIT Imports: 15 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 {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(client HTTPClient, jar http.CookieJar) *Client

func (*Client) Authenticate added in v1.4.4

func (c *Client) Authenticate(login, password string) ([]*http.Cookie, error)

Authenticate performs user authentication by sending login credentials to the Bitrix Partner Portal.

It sends a POST request with the login and password as form data and checks the response for authentication success by verifying the presence of a "BITRIX_SM_LOGIN" cookie.

Returns a slice of cookies if authentication is successful or an error if authentication fails or an issue occurs during the request.

func (*Client) ChangeLabels added in v1.5.0

func (c *Client) ChangeLabels(
	module *module.Module,
	cookies []*http.Cookie,
	versions types.Versions,
) error

func (*Client) SessionId

func (c *Client) SessionId(module *module.Module, cookies []*http.Cookie) string

SessionId retrieves the session ID for a given module from the Bitrix Partner Portal.

The function sends a GET request to the edit page of the module, then parses the HTML response to extract the session ID. The session ID is needed for later operations like uploading data to the portal.

Parameters:

  • module: The module for which the session ID is being retrieved.
  • cookies: The cookies containing the authentication information.

Returns:

  • The session ID as a string if found, otherwise returns an empty string.

func (*Client) UploadZIP

func (c *Client) UploadZIP(
	ctx context.Context,
	module *module.Module,
	cookies []*http.Cookie,
) error

UploadZIP uploads a ZIP file containing the module's data to the Bitrix Partner Portal.

This function first validates that the module and cookies are provided. It then retrieves the session ID and prepares the ZIP file for upload. The request is sent with the necessary form data, including the session ID, module name, and the ZIP file. The response body is checked for the result of the upload operation.

Parameters:

  • ctx: context.Context.
  • module: The module whose ZIP file is being uploaded.
  • cookies: The cookies containing the authentication information.

Returns:

  • An error if any step fails (e.g., missing session, file errors, upload failure).

func (*Client) Versions added in v1.4.4

func (c *Client) Versions(
	ctx context.Context,
	module *module.Module,
	cookies []*http.Cookie,
) (types.Versions, error)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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