// ListMarketplacePurchasesForUser lists all GitHub marketplace purchases made by a user.
//
// GitHub API docs: https://developer.github.com/v3/apps/marketplace/#get-a-users-marketplace-purchases
502230
func (s *MarketplaceService) ListMarketplacePurchasesForUser(ctx context.Context, opt *ListOptions) ([]*MarketplacePurchase, *Response, error) {
	uri := "user/marketplace_purchases"
	if s.Stubbed {
		uri = "user/marketplace_purchases/stubbed"
	}

	u, err := addOptions(uri, opt)
	if err != nil {
		return nil, nil, err
	}

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var purchases []*MarketplacePurchase
	resp, err := s.client.Do(ctx, req, &purchases)
	if err != nil {
		return nil, resp, err
	}
	return purchases, resp, nil
}
79430
func (api *BaseAPI) getModelFilters(filters params.OfferFilters) (
	models map[string]Model,
	filtersPerModel map[string][]jujucrossmodel.ApplicationOfferFilter,
	_ error,
) {
	models = make(map[string]Model)
	filtersPerModel = make(map[string][]jujucrossmodel.ApplicationOfferFilter)

	// Group the filters per model and then query each model with the relevant filters
	// for that model.
	modelUUIDs := make(map[string]string)
	for _, f := range filters.Filters {
		if f.ModelName == "" {
			return nil, nil, errors.New("application offer filter must specify a model name")
		}
		var (
			modelUUID string
			ok        bool
		)
		if modelUUID, ok = modelUUIDs[f.ModelName]; !ok {
			var err error
			model, absModelPath, ok, err := api.modelForName(f.ModelName, f.OwnerName)
			if err != nil {
				return nil, nil, errors.Trace(err)
			}
			if !ok {
				err := errors.NotFoundf("model %q", absModelPath)
				return nil, nil, errors.Trace(err)
			}
			// Record the UUID and model for next time.
			modelUUID = model.UUID()
			modelUUIDs[f.ModelName] = modelUUID
			models[modelUUID] = model
		}

		// Record the filter and model details against the model UUID.
		filters := filtersPerModel[modelUUID]
		filter, err := makeOfferFilterFromParams(f)
		if err != nil {
			return nil, nil, errors.Trace(err)
		}
		filters = append(filters, filter)
		filtersPerModel[modelUUID] = filters
	}
	return models, filtersPerModel, nil
}
890983
func NewMarketplace() *MarketplaceClient {
	c := &MarketplaceClient{}
	c.common.backend = DefaultBackend()

	c.Credentials = (*CredentialsClient)(&c.common)
	c.Internal = (*InternalClient)(&c.common)
	c.Projects = (*ProjectsClient)(&c.common)
	c.Resources = (*ResourcesClient)(&c.common)

	return c
}
1283448
func (api *OffersAPI) ListApplicationOffers(filters params.OfferFilters) (params.QueryApplicationOffersResults, error) {
	var result params.QueryApplicationOffersResults
	offers, err := api.getApplicationOffersDetails(filters, permission.AdminAccess)
	if err != nil {
		return result, common.ServerError(err)
	}
	result.Results = offers
	return result, nil
}
41458
func (s *RepositoriesService) ListTrafficReferrers(ctx context.Context, owner, repo string) ([]*TrafficReferrer, *Response, error) {
	u := fmt.Sprintf("repos/%v/%v/traffic/popular/referrers", owner, repo)

	req, err := s.client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var trafficReferrers []*TrafficReferrer
	resp, err := s.client.Do(ctx, req, &trafficReferrers)
	if err != nil {
		return nil, resp, err
	}

	return trafficReferrers, resp, nil
}
983358
func (c *Client) ListImageStores(p *ListImageStoresParameter) ([]*ImageStore, error) {
	obj, err := c.Request("listImageStores", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*ImageStore), err
}
226299
func parseOwnerAndRepo(c *context.APIContext) (*models.User, *models.Repository) {
	owner, err := models.GetUserByName(c.Params(":username"))
	if err != nil {
		if errors.IsUserNotExist(err) {
			c.Error(422, "", err)
		} else {
			c.Error(500, "GetUserByName", err)
		}
		return nil, nil
	}

	repo, err := models.GetRepositoryByName(owner.ID, c.Params(":reponame"))
	if err != nil {
		if errors.IsRepoNotExist(err) {
			c.Status(404)
		} else {
			c.Error(500, "GetRepositoryByName", err)
		}
		return nil, nil
	}

	return owner, repo
}
64758
func (s *Service) AddOnListByUser(ctx context.Context, accountIdentity string, lr *ListRange) (AddOnListByUserResult, error) {
	var addOn AddOnListByUserResult
	return addOn, s.Get(ctx, &addOn, fmt.Sprintf("/users/%v/addons", accountIdentity), nil, lr)
}
293009
func (r Product_Item_Price) GetPackageReferences() (resp []datatypes.Product_Package_Item_Prices, err error) {
	err = r.Session.DoRequest("SoftLayer_Product_Item_Price", "getPackageReferences", nil, &r.Options, &resp)
	return
}
22671
func (self *InvoiceItemClient) CustomerList(id string) ([]*InvoiceItem, error) {
	return self.list(id, 10, 0)
}
708037
func TxConsumesOutpointWithAddress(msgTx *wire.MsgTx, addr string,
	c VerboseTransactionGetter, params *chaincfg.Params) (prevOuts []PrevOut, prevTxs []*TxWithBlockData) {
	// Send all the raw transaction requests
	type promiseGetRawTransaction struct {
		result rpcclient.FutureGetRawTransactionVerboseResult
		inIdx  int
	}
	numPrevOut := len(msgTx.TxIn)
	promisesGetRawTransaction := make([]promiseGetRawTransaction, 0, numPrevOut)

	for inIdx, txIn := range msgTx.TxIn {
		hash := &txIn.PreviousOutPoint.Hash
		if zeroHash.IsEqual(hash) {
			continue // coinbase or stakebase
		}
		promisesGetRawTransaction = append(promisesGetRawTransaction, promiseGetRawTransaction{
			result: c.GetRawTransactionVerboseAsync(hash),
			inIdx:  inIdx,
		})
	}

	// For each TxIn of this transaction, inspect the previous outpoint.
	for i := range promisesGetRawTransaction {
		// Previous outpoint for this TxIn
		inIdx := promisesGetRawTransaction[i].inIdx
		prevOut := &msgTx.TxIn[inIdx].PreviousOutPoint
		hash := prevOut.Hash

		prevTxRaw, err := promisesGetRawTransaction[i].result.Receive()
		if err != nil {
			fmt.Printf("Unable to get raw transaction for %v: %v\n", hash, err)
			return nil, nil
		}

		if prevTxRaw.Txid != hash.String() {
			fmt.Printf("%v != %v", prevTxRaw.Txid, hash.String())
			return nil, nil
		}

		prevTx, err := MsgTxFromHex(prevTxRaw.Hex)
		if err != nil {
			fmt.Printf("MsgTxFromHex failed: %s\n", err)
			continue
		}

		// prevOut.Index indicates which output.
		txOut := prevTx.TxOut[prevOut.Index]
		// Extract the addresses from this output's PkScript.
		_, txAddrs, _, err := txscript.ExtractPkScriptAddrs(
			txOut.Version, txOut.PkScript, params)
		if err != nil {
			fmt.Printf("ExtractPkScriptAddrs: %v\n", err.Error())
			continue
		}

		// For each address that matches the address of interest, record this
		// previous outpoint and the containing transactions.
		for _, txAddr := range txAddrs {
			addrstr := txAddr.EncodeAddress()
			if addr == addrstr {
				outpoint := wire.NewOutPoint(&hash,
					prevOut.Index, TxTree(prevTx))
				prevOuts = append(prevOuts, PrevOut{
					TxSpending:       msgTx.TxHash(),
					InputIndex:       inIdx,
					PreviousOutpoint: outpoint,
				})
				prevTxs = append(prevTxs, &TxWithBlockData{
					Tx:          prevTx,
					BlockHeight: prevTxRaw.BlockHeight,
					BlockHash:   prevTxRaw.BlockHash,
				})
			}
		}

	}
	return
}
358598
func (w *Wallet) ListAddressTransactions(pkHashes map[string]struct{}) ([]btcjson.ListTransactionsResult, error) {
	txList := []btcjson.ListTransactionsResult{}
	err := walletdb.View(w.db, func(tx walletdb.ReadTx) error {
		txmgrNs := tx.ReadBucket(wtxmgrNamespaceKey)

		// Get current block.  The block height used for calculating
		// the number of tx confirmations.
		syncBlock := w.Manager.SyncedTo()
		rangeFn := func(details []wtxmgr.TxDetails) (bool, error) {
		loopDetails:
			for i := range details {
				detail := &details[i]

				for _, cred := range detail.Credits {
					pkScript := detail.MsgTx.TxOut[cred.Index].PkScript
					_, addrs, _, err := txscript.ExtractPkScriptAddrs(
						pkScript, w.chainParams)
					if err != nil || len(addrs) != 1 {
						continue
					}
					apkh, ok := addrs[0].(*btcutil.AddressPubKeyHash)
					if !ok {
						continue
					}
					_, ok = pkHashes[string(apkh.ScriptAddress())]
					if !ok {
						continue
					}

					jsonResults := listTransactions(tx, detail,
						w.Manager, syncBlock.Height, w.chainParams)
					if err != nil {
						return false, err
					}
					txList = append(txList, jsonResults...)
					continue loopDetails
				}
			}
			return false, nil
		}

		return w.TxStore.RangeTransactions(txmgrNs, 0, -1, rangeFn)
	})
	return txList, err
}
22845
func (api *BaseAPI) getModelsFromOffers(offerURLs ...string) ([]offerModel, error) {
	// Cache the models found so far so we don't look them up more than once.
	modelsCache := make(map[string]Model)
	oneModel := func(offerURL string) (Model, error) {
		url, err := jujucrossmodel.ParseOfferURL(offerURL)
		if err != nil {
			return nil, errors.Trace(err)
		}
		modelPath := fmt.Sprintf("%s/%s", url.User, url.ModelName)
		if model, ok := modelsCache[modelPath]; ok {
			return model, nil
		}

		model, absModelPath, ok, err := api.modelForName(url.ModelName, url.User)
		if err != nil {
			return nil, errors.Trace(err)
		}
		if !ok {
			return nil, errors.NotFoundf("model %q", absModelPath)
		}
		return model, nil
	}

	result := make([]offerModel, len(offerURLs))
	for i, offerURL := range offerURLs {
		var om offerModel
		om.model, om.err = oneModel(offerURL)
		result[i] = om
	}
	return result, nil
}
657983
func FilterInPlace(sl interface{}, f interface{}) {
	v := reflect.ValueOf(sl).Elem()
	j := 0
	for i := 0; i < v.Len(); i++ {
		e := v.Index(i)
		if reflect.ValueOf(f).Call([]reflect.Value{e.Addr()})[0].Bool() {
			v.Index(j).Set(e)
			j++
		}
	}
	v.SetLen(j)
}
790719
func (api CompaniesAPI) GetCompanyList(w http.ResponseWriter, r *http.Request) {
	log.Warn("GetCompanyList is not implemented")
	http.Error(w, http.StatusText(http.StatusNotImplemented), http.StatusNotImplemented)
}
1141364
func (r Network_CdnMarketplace_Account) VerifyCdnAccountExists(vendorName *string) (resp bool, err error) {
	params := []interface{}{
		vendorName,
	}
	err = r.Session.DoRequest("SoftLayer_Network_CdnMarketplace_Account", "verifyCdnAccountExists", params, &r.Options, &resp)
	return
}
978032
func (s *UCSService) NewListUcsManagersParams() *ListUcsManagersParams {
	p := &ListUcsManagersParams{}
	p.p = make(map[string]interface{})
	return p
}