open_as_buyer

@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since  2013-10-03
423582
public function open_as_buyerAction()
    {
        $q  = $this->get('doctrine')
            ->getManager()
            ->createQuery('
                SELECT    o
                FROM      HarvestCloudCoreBundle:Order o
                LEFT JOIN o.buyer b
                LEFT JOIN o.seller s
                LEFT JOIN o.hub h
                WHERE     :profile = o.buyer
                ORDER BY  o.id DESC
            ')
            ->setParameter('profile', $this->getCurrentProfile())
        ;

        $orders = $q->getResult();

        return $this->render('HarvestCloudCoreBundle:Order/Dashboard:open_as_buyer.html.twig', array(
            'orders'  => $orders,
        ));
    }
1085006
function open()
    {
        if (!$this->_opened) {
            /* Use the DSN and options to create a database connection. */
            $this->_db = &MDB2::connect($this->_dsn, $this->_options);
            if (PEAR::isError($this->_db)) {
                return false;
            }

            /* Create a prepared statement for repeated use in log(). */
            if (!$this->_prepareStatement()) {
                return false;
            }

            /* We now consider out connection open. */
            $this->_opened = true;
        }

        return $this->_opened;
    }
223035
function (cb) {
    _metaBroker.tearUp(function (err) {
      if (!err) {
        _metaBroker.connected = true;
      }
      cb(err);
    });
  }
992695
def open(self, user):
        
        self.params.update({
            'user': user,
            })
        return FromUrl('https://slack.com/api/im.open', self._requests)(data=self.params).post()
334197
function(seller) {
    if( this instanceof pagseguro === false )
      return new pagseguro(seller);

    /**
     * Dados do vendedor
     */
    this.seller = seller;

    /**
     * Url base, define se está na Sandbox ou não
     * @type {string}
       */
    this.baseUri = 'https://ws.pagseguro.uol.com.br';

    if (process.env.PAGSEGURO_TEST) {
      this.baseUri = 'https://ws.sandbox.pagseguro.uol.com.br';
    }

    this.checkout = function(callback) {
      // cria a query de post com os dados informados
      var data = '';
      data += querystring.stringify(this.product._products);
      data += '&'+querystring.stringify(this.sender._sender);
      data += '&'+querystring.stringify(this.shipping._shipping);

      var options = {
        uri: this.baseUri + '/v2/checkout?'+querystring.stringify(this.seller),
        method: 'POST',
        body: data,
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
          'Content-Length': data.length
        }
      };

      request.post(options, function(err, res, body) {
        if( !!err === false ) {
          var body = parseXML(body, function(err_x, json) {
            callback(err, res, json);
          });
        }
        else {
          callback(err, res, body);
        }
      });
    };

    this.transactions = function(code, callback) {
      var uri = this.baseUri + '/v2/transactions/'+ code + '?'+ querystring.stringify(this.seller);

      var options = {
        uri: uri,
        method: 'GET',
        headers: {
          'Content-Type': 'application/text-plain; charset=utf-8'
        }
      };

      request.get(uri, options, function(err, res, body) {
        if( !!err === false ) {
          var body = parseXML(body, function(err_x, json) {
            callback(err, res, json);
          });
        }
        else {
          callback(err, res, body);
        }
      });
    };

    return this;
  }
1040812
def get_sell(self, sell_id, **params):
        """"""
        return self.api_client.get_sell(self.id, sell_id, **params)
944647
public function indexAction()
    {
        $q  = $this->get('doctrine')
            ->getManager()
            ->createQuery('
                SELECT    o
                FROM      HarvestCloudCoreBundle:Order o
                LEFT JOIN o.buyer b
                LEFT JOIN o.seller s
                LEFT JOIN o.hub h
                WHERE     :profile = o.buyer
                OR        :profile = o.seller
                OR        :profile = o.hub
                ORDER BY  o.id DESC
            ')
            ->setParameter('profile', $this->getCurrentProfile())
        ;

        $orders = $q->getResult();

        // For dev and demo purposes, just get all orders:
        $orders = $this->get('doctrine')
            ->getRepository('HarvestCloudCoreBundle:Order')
            ->findAll()
        ;

        return $this->render('HarvestCloudCoreBundle:Order/Default:index.html.twig', array(
            'profile' => $this->getCurrentProfile(),
            'orders'  => $orders,
            'order'   => $orders[0],
        ));
    }
970533
public static function create_and_buy($params = null, $apiKey = null)
    {
        $class = get_class();
        if (!isset($params['batch']) || !is_array($params['batch'])) {
            $clone = $params;
            unset($params);
            $params['batch'] = $clone;
        }

        $requestor = new Requestor($apiKey);
        $url = self::classUrl($class);
        list($response, $apiKey) = $requestor->request('post', $url.'/create_and_buy', $params);

        return Util::convertToEasyPostObject($response, $apiKey);
    }
829908
def purchased # Thank You!
      @order = if params[:id].present?
        Effective::Order.find(params[:id])
      elsif current_user.present?
        Effective::Order.sorted.purchased_by(current_user).last
      end

      if @order.blank?
        redirect_to(effective_orders.orders_path) and return
      end

      EffectiveOrders.authorize!(self, :show, @order)

      redirect_to(effective_orders.order_path(@order)) unless @order.purchased?
    end
111807
async function main () {

    const requirements = exchangeId && methodName
    if (!requirements) {

        printUsage ()

    } else {

        let args = params
            .map (s => s.match (/^[0-9]{4}[-]?[0-9]{2}[-]?[0-9]{2}[T\s]?[0-9]{2}[:]?[0-9]{2}[:]?[0-9]{2}/g) ? exchange.parse8601 (s) : s)
            .map (s => (() => { try { return eval ('(() => (' + s + ')) ()') } catch (e) { return s } }) ())

        const www = Array.isArray (exchange.urls.www) ? exchange.urls.www[0] : exchange.urls.www

        if (cloudscrape)
            exchange.headers = await scrapeCloudflareHttpHeaderCookie (www)

        if (cfscrape)
            exchange.headers = cfscrapeCookies (www)

        if (cors) {
            exchange.proxy =  'https://cors-anywhere.herokuapp.com/';
            exchange.origin = exchange.uuid ()
        }

        no_load_markets = no_send ? true : no_load_markets

        if (debug) {
            exchange.verbose = verbose
        }

        if (!no_load_markets) {
            await exchange.loadMarkets ()
        }

        exchange.verbose = verbose

        if (no_send) {

            exchange.verbose = no_send
            exchange.fetch = function fetch (url, method = 'GET', headers = undefined, body = undefined) {
                log.dim.noLocate ('-------------------------------------------')
                log.dim.noLocate (exchange.iso8601 (exchange.milliseconds ()))
                log.green.unlimited ({
                    url,
                    method,
                    headers,
                    body,
                })
                process.exit ()
            }
        }

        if (typeof exchange[methodName] === 'function') {

            log (exchange.id + '.' + methodName, '(' + args.join (', ') + ')')

            while (true) {

                try {

                    const result = await exchange[methodName] (... args)
                    printHumanReadable (exchange, result)

                } catch (e) {

                    if (e instanceof ExchangeError) {

                        log.red (e.constructor.name, e.message)

                    } else if (e instanceof NetworkError) {

                        log.yellow (e.constructor.name, e.message)

                    }

                    log.dim ('---------------------------------------------------')

                    // rethrow for call-stack // other errors
                    throw e

                }

                if (!poll)
                    break;
            }

        } else if (exchange[methodName] === undefined) {

            log.red (exchange.id + '.' + methodName + ': no such property')

        } else {

            printHumanReadable (exchange, exchange[methodName])
        }
    }
}
381599
def commit_buy(self, buy_id, **params):
        """"""
        return self.api_client.commit_buy(self.id, buy_id, **params)
1000945
public final void makeSeOrdLn(final Map<String, Object> pRqVs,
    final List<CuOrSe> pOrders, final SeSeller pSel,
      final AItemPlace<?, ?> pItPl, final CartLn pCartLn,
        final TradingSettings pTs) throws Exception {
    CuOrSe cuOr = null;
    boolean isNdOrInit = true;
    for (CuOrSe co : pOrders) {
      if (co.getCurr() != null && co.getSel() != null
  && co.getSel().getSeller().getItsId().equals(pSel.getSeller().getItsId())) {
        cuOr = co;
        isNdOrInit = false;
        break;
      }
    }
    if (cuOr == null) {
      for (CuOrSe co : pOrders) {
        if (co.getCurr() == null) {
          cuOr = co;
          break;
        }
      }
    }
    if (cuOr == null) {
      cuOr = new CuOrSe();
      cuOr.setIsNew(true);
      cuOr.setTaxes(new ArrayList<CuOrSeTxLn>());
      cuOr.setGoods(new ArrayList<CuOrSeGdLn>());
      cuOr.setServs(new ArrayList<CuOrSeSrLn>());
      pOrders.add(cuOr);
    }
    if (isNdOrInit) {
      cuOr.setDat(new Date());
      cuOr.setSeller(pSel);
      cuOr.setStat(EOrdStat.NEW);
      cuOr.setDeliv(pCartLn.getItsOwner().getDeliv());
      cuOr.setPayMeth(pCartLn.getItsOwner().getPayMeth());
      cuOr.setBuyer(pCartLn.getItsOwner().getBuyer());
      //TODO  method "pickup by buyer from several places"
      //cuOr.setPlace(pItPl.getPickUpPlace());
      cuOr.setPur(pCartLn.getItsOwner().getItsVersion());
      cuOr.setCurr(pCartLn.getItsOwner().getCurr());
      cuOr.setExcRt(pCartLn.getItsOwner().getExcRt());
      cuOr.setDescr(pCartLn.getItsOwner().getDescr());
    }
    pRqVs.put(CartItTxLn.class.getSimpleName() + "itsOwnerdeepLevel", 1);
    pRqVs.put(CartItTxLn.class.getSimpleName() + "taxdeepLevel", 1);
    List<CartItTxLn> citls = getSrvOrm().retrieveListWithConditions(pRqVs,
      CartItTxLn.class, "where DISAB=0 and ITSOWNER=" + pCartLn.getItsId());
    pRqVs.remove(CartItTxLn.class.getSimpleName() + "itsOwnerdeepLevel");
    pRqVs.remove(CartItTxLn.class.getSimpleName() + "taxdeepLevel");
    ACuOrSeLn ol;
    if (pCartLn.getItTyp().equals(EShopItemType.SEGOODS)) {
      CuOrSeGdLn ogl = null;
      if (!cuOr.getIsNew()) {
        for (CuOrSeGdLn gl : cuOr.getGoods()) {
          if (gl.getGood() == null) {
            ogl = gl;
            break;
          }
        }
      }
      if (ogl == null) {
        ogl = new CuOrSeGdLn();
        ogl.setIsNew(true);
        cuOr.getGoods().add(ogl);
      }
      SeGoods gd = new SeGoods();
      gd.setSeller(pSel);
      gd.setItsId(pCartLn.getItId());
      gd.setItsName(pCartLn.getItsName());
      ogl.setGood(gd);
      if (citls.size() > 0) {
        if (ogl.getIsNew()) {
          ogl.setItTxs(new ArrayList<CuOrSeGdTxLn>());
        }
        for (CartItTxLn citl : citls) {
          CuOrSeGdTxLn oitl = null;
          if (!cuOr.getIsNew()) {
            for (CuOrSeGdTxLn itl : ogl.getItTxs()) {
              if (itl.getTax() == null) {
                oitl = itl;
                break;
              }
            }
          }
          if (oitl == null) {
            oitl = new CuOrSeGdTxLn();
            oitl.setIsNew(true);
            ogl.getItTxs().add(oitl);
          }
          oitl.setItsOwner(ogl);
          Tax tx = new Tax();
          tx.setItsId(citl.getTax().getItsId());
          tx.setItsName(citl.getTax().getItsName());
          oitl.setTax(tx);
          oitl.setTot(citl.getTot());
        }
      }
      ol = ogl;
    } else {
      CuOrSeSrLn osl = null;
      if (!cuOr.getIsNew()) {
        for (CuOrSeSrLn sl : cuOr.getServs()) {
          if (sl.getService() == null) {
            osl = sl;
            break;
          }
        }
      }
      if (osl == null) {
        osl = new CuOrSeSrLn();
        osl.setIsNew(true);
        cuOr.getServs().add(osl);
      }
      SeService sr = new SeService();
      sr.setSeller(pSel);
      sr.setItsId(pCartLn.getItId());
      sr.setItsName(pCartLn.getItsName());
      osl.setService(sr);
      osl.setDt1(pCartLn.getDt1());
      osl.setDt2(pCartLn.getDt2());
      if (citls.size() > 0) {
        if (osl.getIsNew()) {
          osl.setItTxs(new ArrayList<CuOrSeSrTxLn>());
        }
        for (CartItTxLn citl : citls) {
          CuOrSeSrTxLn oitl = null;
          if (!cuOr.getIsNew()) {
            for (CuOrSeSrTxLn itl : osl.getItTxs()) {
              if (itl.getTax() == null) {
                oitl = itl;
                break;
              }
            }
          }
          if (oitl == null) {
            oitl = new CuOrSeSrTxLn();
            oitl.setIsNew(true);
            osl.getItTxs().add(oitl);
          }
          oitl.setItsOwner(osl);
          Tax tx = new Tax();
          tx.setItsId(citl.getTax().getItsId());
          tx.setItsName(citl.getTax().getItsName());
          oitl.setTax(tx);
          oitl.setTot(citl.getTot());
        }
      }
      ol = osl;
    }
    ol.setItsName(pCartLn.getItsName());
    ol.setDescr(pCartLn.getDescr());
    ol.setUom(pCartLn.getUom());
    ol.setPrice(pCartLn.getPrice());
    ol.setQuant(pCartLn.getQuant());
    ol.setSubt(pCartLn.getSubt());
    ol.setTot(pCartLn.getTot());
    ol.setTotTx(pCartLn.getTotTx());
    ol.setTxCat(pCartLn.getTxCat());
    ol.setTxDsc(pCartLn.getTxDsc());
  }
248195
def sell(self, account_id, **params):
        """"""
        if 'amount' not in params and 'total' not in params:
            raise ValueError("Missing required parameter: 'amount' or 'total'")
        for required in ['currency']:
            if required not in params:
                raise ValueError("Missing required parameter: %s" % required)
        response = self._post('v2', 'accounts', account_id, 'sells', data=params)
        return self._make_api_object(response, Sell)
1224555
async def Offer(self, offers):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='ApplicationOffers',
                   request='Offer',
                   version=2,
                   params=_params)
        _params['Offers'] = offers
        reply = await self.rpc(msg)
        return reply
180852
def buy(self, security, price=0, amount=0, volume=0, entrust_prop=0):
        
        return self._trade(security, price, amount, volume, "buy")
799913
function _stream_open($path, $mode, $options, &$opened_path)
    {
        $path = $this->_parse_path($path);

        if ($path === false) {
            return false;
        }
        $this->path = $path;

        $this->size = $this->sftp->size($path);
        $this->mode = preg_replace('#[bt]$#', '', $mode);
        $this->eof = false;

        if ($this->size === false) {
            if ($this->mode[0] == 'r') {
                return false;
            } else {
                $this->sftp->touch($path);
                $this->size = 0;
            }
        } else {
            switch ($this->mode[0]) {
                case 'x':
                    return false;
                case 'w':
                    $this->sftp->truncate($path, 0);
                    $this->size = 0;
            }
        }

        $this->pos = $this->mode[0] != 'a' ? 0 : $this->size;

        return true;
    }
1116678
def commit_sell(self, sell_id, **params):
        """"""
        return self.api_client.commit_sell(self.id, sell_id, **params)