ui/offering.go
func (h *Handler) GetAgentOfferings(tkn, product string, statuses []string,
	offset, limit uint) (*GetAgentOfferingsResult, error) {
	logger := h.logger.Add("method", "GetAgentOfferings",
		"product", product, "status", statuses)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	conditions, args := h.getAgentOfferingsConditions(product, statuses)

	count, err := h.numberOfObjects(
		logger, data.OfferingTable.Name(), conditions, args)
	if err != nil {
		return nil, err
	}

	offsetLimit := h.offsetLimit(offset, limit)

	sorting := `ORDER BY block_number_updated DESC`

	tail := fmt.Sprintf("%s %s %s", conditions, sorting, offsetLimit)

	result, err := h.selectAllFrom(
		logger, data.OfferingTable, tail, args...)
	if err != nil {
		return nil, err
	}

	offerings := make([]data.Offering, len(result))

	for k, v := range result {
		offerings[k] = *v.(*data.Offering)
	}

	return &GetAgentOfferingsResult{offerings, count}, nil
}
func (h *Handler) GetAgentOfferings(tkn, product string, statuses []string,
	offset, limit uint) (*GetAgentOfferingsResult, error) {
	logger := h.logger.Add("method", "GetAgentOfferings",
		"product", product, "status", statuses)

	if !h.token.Check(tkn) {
		logger.Warn("access denied")
		return nil, ErrAccessDenied
	}

	conditions, args := h.getAgentOfferingsConditions(product, statuses)

	count, err := h.numberOfObjects(
		logger, data.OfferingTable.Name(), conditions, args)
	if err != nil {
		return nil, err
	}

	offsetLimit := h.offsetLimit(offset, limit)

	sorting := `ORDER BY block_number_updated DESC`

	tail := fmt.Sprintf("%s %s %s", conditions, sorting, offsetLimit)

	result, err := h.selectAllFrom(
		logger, data.OfferingTable, tail, args...)
	if err != nil {
		return nil, err
	}

	offerings := make([]data.Offering, len(result))

	for k, v := range result {
		offerings[k] = *v.(*data.Offering)
	}

	return &GetAgentOfferingsResult{offerings, count}, nil
}
func ( h * Handler ) GetAgentOfferings ( tkn , product string , statuses [ ] string , offset , limit uint ) ( * GetAgentOfferingsResult , error ) { logger := h . logger . Add ( " " , " " , " " , product , " " , statuses ) if ! h . token . Check ( tkn ) { logger . Warn ( " " ) return nil , ErrAccessDenied } conditions , args := h . getAgentOfferingsConditions ( product , statuses ) count , err := h . numberOfObjects ( logger , data . OfferingTable . Name ( ) , conditions , args ) if err != nil { return nil , err } offsetLimit := h . offsetLimit ( offset , limit ) sorting := `ORDER BY block_number_updated DESC` tail := fmt . Sprintf ( " " , conditions , sorting , offsetLimit ) result , err := h . selectAllFrom ( logger , data . OfferingTable , tail , args ... ) if err != nil { return nil , err } offerings := make ( [ ] data . Offering , len ( result ) ) for k , v := range result { offerings [ k ] = * v . ( * data . Offering ) } return & GetAgentOfferingsResult { offerings , count } , nil }
// GetAgentOfferings returns active offerings available for a agent.
GetAgentOfferings returns active offerings available for a agent .