session

package
v0.0.0-...-3d57616 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ItemMinPrice    = 100
	ItemMaxPrice    = 1000000
	ItemPriceErrMsg = "商品価格は100イスコイン以上、1,000,000イスコイン以下にしてください"
)
View Source
const (
	DefaultAPITimeout = 10
)

Variables

This section is empty.

Functions

func SetShareTargetURLs

func SetShareTargetURLs(appURL, targetHost, paymentURL, shipmentURL string) error

Types

type Category

type Category struct {
	ID                 int    `json:"id" db:"id"`
	ParentID           int    `json:"parent_id" db:"parent_id"`
	CategoryName       string `json:"category_name" db:"category_name"`
	ParentCategoryName string `json:"parent_category_name,omitempty" db:"-"`
}

type Item

type Item struct {
	ID          int64     `json:"id" db:"id"`
	SellerID    int64     `json:"seller_id" db:"seller_id"`
	BuyerID     int64     `json:"buyer_id" db:"buyer_id"`
	Status      string    `json:"status" db:"status"`
	Name        string    `json:"name" db:"name"`
	Price       int       `json:"price" db:"price"`
	Description string    `json:"description" db:"description"`
	ImageName   string    `json:"image_name" db:"image_name"`
	CategoryID  int       `json:"category_id" db:"category_id"`
	CreatedAt   time.Time `json:"-" db:"created_at"`
	UpdatedAt   time.Time `json:"-" db:"updated_at"`
}

type ItemDetail

type ItemDetail struct {
	ID                        int64       `json:"id"`
	SellerID                  int64       `json:"seller_id"`
	Seller                    *UserSimple `json:"seller"`
	BuyerID                   int64       `json:"buyer_id,omitempty"`
	Buyer                     *UserSimple `json:"buyer,omitempty"`
	Status                    string      `json:"status"`
	Name                      string      `json:"name"`
	Price                     int         `json:"price"`
	Description               string      `json:"description"`
	ImageURL                  string      `json:"image_url"`
	CategoryID                int         `json:"category_id"`
	Category                  *Category   `json:"category"`
	TransactionEvidenceID     int64       `json:"transaction_evidence_id,omitempty"`
	TransactionEvidenceStatus string      `json:"transaction_evidence_status,omitempty"`
	ShippingStatus            string      `json:"shipping_status,omitempty"`
	CreatedAt                 int64       `json:"created_at"`
}

type ItemSimple

type ItemSimple struct {
	ID         int64       `json:"id"`
	SellerID   int64       `json:"seller_id"`
	Seller     *UserSimple `json:"seller"`
	Status     string      `json:"status"`
	Name       string      `json:"name"`
	Price      int         `json:"price"`
	ImageURL   string      `json:"image_url"`
	CategoryID int         `json:"category_id"`
	Category   *Category   `json:"category"`
	CreatedAt  int64       `json:"created_at"`
}

type Session

type Session struct {
	UserID int64
	// contains filtered or unexported fields
}

func NewSession

func NewSession() (*Session, error)

func NewSessionForInialize

func NewSessionForInialize() (*Session, error)

func (*Session) Bump

func (s *Session) Bump(ctx context.Context, itemID int64) (int64, error)

func (*Session) Buy

func (s *Session) Buy(ctx context.Context, itemID int64, token string) (int64, error)

func (*Session) BuyWithFailed

func (s *Session) BuyWithFailed(ctx context.Context, itemID int64, token string, expectedStatus int, expectedMsg string) error

func (*Session) BuyWithFailedOnCampaign

func (s *Session) BuyWithFailedOnCampaign(ctx context.Context, itemID int64, token string) error

func (*Session) BuyWithMayFail

func (s *Session) BuyWithMayFail(ctx context.Context, itemID int64, token string) (int64, error)

人気者出品用。成功するかもしれないし、失敗するかもしれない。 この中では異質だが正常系ではあるのでここで定義する

func (*Session) BuyWithWrongCSRFToken

func (s *Session) BuyWithWrongCSRFToken(ctx context.Context, itemID int64, token string) error

func (*Session) Complete

func (s *Session) Complete(ctx context.Context, itemID int64) error

func (*Session) DecodeQRURLWithFailed

func (s *Session) DecodeQRURLWithFailed(ctx context.Context, apath string, expectedStatus int) error

func (*Session) Do

func (s *Session) Do(req *http.Request) (*http.Response, error)

func (*Session) DownloadItemImageURL

func (s *Session) DownloadItemImageURL(ctx context.Context, apath string) (md5Str string, err error)

func (*Session) DownloadQRURL

func (s *Session) DownloadQRURL(ctx context.Context, apath string) (md5Str string, err error)

func (*Session) DownloadStaticURL

func (s *Session) DownloadStaticURL(ctx context.Context, apath string) (md5Str string, err error)

func (*Session) Initialize

func (s *Session) Initialize(ctx context.Context, paymentServiceURL, shipmentServiceURL string) (int, string, error)

func (*Session) Item

func (s *Session) Item(ctx context.Context, itemID int64) (item ItemDetail, err error)

func (*Session) ItemEdit

func (s *Session) ItemEdit(ctx context.Context, itemID int64, price int) (int, error)

func (*Session) ItemEditWithNotOnSale

func (s *Session) ItemEditWithNotOnSale(ctx context.Context, itemID int64, price int) error

func (*Session) Login

func (s *Session) Login(ctx context.Context, accountName, password string) (*asset.AppUser, error)

func (*Session) LoginWithWrongPassword

func (s *Session) LoginWithWrongPassword(ctx context.Context, accountName, password string) error

func (*Session) NewCategoryItems

func (s *Session) NewCategoryItems(ctx context.Context, rootCategoryID int) (hasNext bool, rootCategoryName string, items []ItemSimple, err error)

func (*Session) NewCategoryItemsWithItemIDAndCreatedAt

func (s *Session) NewCategoryItemsWithItemIDAndCreatedAt(ctx context.Context, rootCategoryID int, itemID, createdAt int64) (hasNext bool, rootCategoryName string, items []ItemSimple, err error)

func (*Session) NewItems

func (s *Session) NewItems(ctx context.Context) (hasNext bool, items []ItemSimple, err error)

func (*Session) NewItemsWithItemIDAndCreatedAt

func (s *Session) NewItemsWithItemIDAndCreatedAt(ctx context.Context, itemID, createdAt int64) (hasNext bool, items []ItemSimple, err error)

func (*Session) Reports

func (s *Session) Reports(ctx context.Context) (transactionEvidences []TransactionEvidence, err error)

func (*Session) Sell

func (s *Session) Sell(ctx context.Context, fileName, name string, price int, description string, categoryID int) (int64, error)

func (*Session) SellWithWrongCSRFToken

func (s *Session) SellWithWrongCSRFToken(ctx context.Context, fileName, name string, price int, description string, categoryID int) error

func (*Session) SellWithWrongPrice

func (s *Session) SellWithWrongPrice(ctx context.Context, fileName, name string, price int, description string, categoryID int) error

func (*Session) SetSettings

func (s *Session) SetSettings(ctx context.Context) error

func (*Session) Ship

func (s *Session) Ship(ctx context.Context, itemID int64) (reserveID, apath string, err error)

func (*Session) ShipDone

func (s *Session) ShipDone(ctx context.Context, itemID int64) error

func (*Session) ShipDoneWithFailed

func (s *Session) ShipDoneWithFailed(ctx context.Context, itemID int64, expectedStatus int, expectedMsg string) error

func (*Session) ShipDoneWithWrongCSRFToken

func (s *Session) ShipDoneWithWrongCSRFToken(ctx context.Context, itemID int64) error

func (*Session) ShipWithFailed

func (s *Session) ShipWithFailed(ctx context.Context, itemID int64, expectedStatus int, expectedMsg string) error

func (*Session) ShipWithWrongCSRFToken

func (s *Session) ShipWithWrongCSRFToken(ctx context.Context, itemID int64) error

func (*Session) UserItems

func (s *Session) UserItems(ctx context.Context, userID int64) (hasNext bool, user *UserSimple, items []ItemSimple, err error)

func (*Session) UserItemsWithItemIDAndCreatedAt

func (s *Session) UserItemsWithItemIDAndCreatedAt(ctx context.Context, userID, itemID, createdAt int64) (hasNext bool, user *UserSimple, items []ItemSimple, err error)

func (*Session) UsersTransactions

func (s *Session) UsersTransactions(ctx context.Context) (hasNext bool, items []ItemDetail, err error)

func (*Session) UsersTransactionsWithItemIDAndCreatedAt

func (s *Session) UsersTransactionsWithItemIDAndCreatedAt(ctx context.Context, itemID, createdAt int64) (hasNext bool, items []ItemDetail, err error)

type Shipping

type Shipping struct {
	TransactionEvidenceID int64     `json:"transaction_evidence_id" db:"transaction_evidence_id"`
	Status                string    `json:"status" db:"status"`
	ItemName              string    `json:"item_name" db:"item_name"`
	ItemID                int64     `json:"item_id" db:"item_id"`
	ReserveID             string    `json:"reserve_id" db:"reserve_id"`
	ReserveTime           int64     `json:"reserve_time" db:"reserve_time"`
	ToAddress             string    `json:"to_address" db:"to_address"`
	ToName                string    `json:"to_name" db:"to_name"`
	FromAddress           string    `json:"from_address" db:"from_address"`
	FromName              string    `json:"from_name" db:"from_name"`
	ImgBinary             []byte    `json:"-" db:"img_binary"`
	CreatedAt             time.Time `json:"-" db:"created_at"`
	UpdatedAt             time.Time `json:"-" db:"updated_at"`
}

type TargetURLs

type TargetURLs struct {
	AppURL      url.URL
	TargetHost  string
	PaymentURL  url.URL
	ShipmentURL url.URL
}
var (
	ShareTargetURLs *TargetURLs
)

type TransactionEvidence

type TransactionEvidence struct {
	ID                 int64  `json:"id" db:"id"`
	SellerID           int64  `json:"seller_id" db:"seller_id"`
	BuyerID            int64  `json:"buyer_id" db:"buyer_id"`
	Status             string `json:"status" db:"status"`
	ItemID             int64  `json:"item_id" db:"item_id"`
	ItemName           string `json:"item_name" db:"item_name"`
	ItemPrice          int    `json:"item_price" db:"item_price"`
	ItemDescription    string `json:"item_description" db:"item_description"`
	ItemCategoryID     int    `json:"item_category_id" db:"item_category_id"`
	ItemRootCategoryID int    `json:"item_root_category_id" db:"item_root_category_id"`
}

type User

type User struct {
	ID             int64     `json:"id" db:"id"`
	AccountName    string    `json:"account_name" db:"account_name"`
	HashedPassword []byte    `json:"-" db:"hashed_password"`
	Address        string    `json:"address,omitempty" db:"address"`
	NumSellItems   int       `json:"num_sell_items" db:"num_sell_items"`
	LastBump       time.Time `json:"-" db:"last_bump"`
	CreatedAt      time.Time `json:"-" db:"created_at"`
}

type UserSimple

type UserSimple struct {
	ID           int64  `json:"id"`
	AccountName  string `json:"account_name"`
	NumSellItems int    `json:"num_sell_items"`
}

Jump to

Keyboard shortcuts

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