spb

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Errors                        = errorx.NewNamespace("OurSpbHttp")
	ErrTooManyRequests            = Errors.NewType("TooManyRequests")
	ErrBadRequest                 = Errors.NewType("BadRequest")
	ErrFailedRequest              = Errors.NewType("FailedRequest")
	ErrUnauthorized               = Errors.NewType("Unauthorized")
	ErrExpectingNotBuildingCoords = Errors.NewType("ExpectingNotBuildingCoords")
	ErrMatchesCoordsAndCategory   = Errors.NewType("MatchesCoordsAndCategory")
)

Functions

This section is empty.

Types

type BuildingResponse

type BuildingResponse struct {
	Id        int64   `json:"id"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	Address   string  `json:"full_address"`
}

type CategoryResponse

type CategoryResponse struct {
	Id      int64            `json:"id"`
	Name    string           `json:"name"`
	Reasons []ReasonResponse `json:"reasons"`
}

type CityResponse

type CityResponse struct {
	Id         int64              `json:"id"`
	Name       string             `json:"name"`
	Categories []CategoryResponse `json:"categories"`
}

type Client

type Client interface {
	Login(login string, password string) (*TokenResponse, error)
	GetNearestBuildings(latitude float64, longitude float64) (*NearestBuildingResponse, error)
	GetReasons() ([]CityResponse, error)
	Send(token string, fields map[string]string, files map[string][]byte) (*SentMessageResponse, error)
	CreateSendProblemRequest(reasonId int64, body string, latitude float64, longitude float64) (
		map[string]string, error,
	)
}

type CreateBuildingProblemRequest

type CreateBuildingProblemRequest struct {
	CreateStreetProblemRequest
	Building int64 `json:"building"`
}

type CreateNearBuildingProblemRequest

type CreateNearBuildingProblemRequest struct {
	CreateStreetProblemRequest
	NearestBuilding int64 `json:"nearest_building"`
}

type CreateProblemRequest

type CreateProblemRequest interface {
}

type CreateStreetProblemRequest

type CreateStreetProblemRequest struct {
	Body                   string  `json:"body"`
	ReasonId               int64   `json:"reason"`
	Latitude               float64 `json:"latitude"`
	Longitude              float64 `json:"longitude"`
	ManuallySelectedReason bool    `json:"manually_selected_reason"`
}

type ErrorResponse

type ErrorResponse map[string]any

func (*ErrorResponse) String

func (r *ErrorResponse) String() string

type Message

type Message struct {
	CategoryId  int
	FileUrls    []string
	Description string
}

type NearestBuildingResponse

type NearestBuildingResponse struct {
	Buildings []BuildingResponse `json:"buildings"`
}

type PositionType

type PositionType int
const (
	PositionTypeBuilding     PositionType = 1
	PositionTypeStreet       PositionType = 2
	PositionTypeNearBuilding PositionType = 4
	//PositionTypeNearBuilding2 I have no idea why there are two types for the same thing
	PositionTypeNearBuilding2 PositionType = 5
)

type ReasonResponse

type ReasonResponse struct {
	Id           int64        `json:"id"`
	Name         string       `json:"name"`
	PositionType PositionType `json:"wizard_widget"`
}

type ReqClient

type ReqClient struct {
	// contains filtered or unexported fields
}

func NewReqClient added in v0.20.0

func NewReqClient(logger *zap.Logger, conf *config.Config) *ReqClient

func (*ReqClient) CreateSendProblemRequest

func (r *ReqClient) CreateSendProblemRequest(
	reasonId int64, body string, latitude float64, longitude float64,
) (map[string]string, error)

func (*ReqClient) GetNearestBuildings

func (r *ReqClient) GetNearestBuildings(latitude float64, longitude float64) (*NearestBuildingResponse, error)

func (*ReqClient) GetReasons

func (r *ReqClient) GetReasons() ([]CityResponse, error)

func (*ReqClient) Login

func (r *ReqClient) Login(login string, password string) (*TokenResponse, error)

func (*ReqClient) Send

func (r *ReqClient) Send(token string, fields map[string]string, files map[string][]byte) (
	*SentMessageResponse, error,
)

type SentMessageResponse added in v1.0.0

type SentMessageResponse struct {
	Id int `json:"id"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
}

Jump to

Keyboard shortcuts

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