request

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 13 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) Authorization

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

Authorization 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) 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(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:

  • 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).

type HTTPClient

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

Jump to

Keyboard shortcuts

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