benbuckman / nodejs-ebay-api

[No longer maintained] eBay API Client for Node.js
MIT License
155 stars 104 forks source link

All queries are using the wrong values #36

Closed moeiscool closed 7 years ago

moeiscool commented 8 years ago

I have made a simple script to interface with ebay through this plugin but all queries are using these values.

serviceName='Trading'
opType='GetSellingManagerSoldListings';

Even if i leave them blank it queries this same API. Even when i try GetSellingManagerSaleRecord is shows the same response.

What am i doing wrong?

my server.js below.. I have replaced my actual values with XXXXXXXXXXXXXX. The authToken is fed in from the client side at this time.

var ebay_cred={
    //get orders
  // app/environment
  devId: 'XXXXXXXXXXXXXX',
  certId: 'XXXXXXXXXXXXXX',
  appName: 'XXXXXXXXXXXXXX',
  sandbox: false,
};
s={};
s.userOps=function(x,y){
    y=ebay_cred;
    for (var n in x) {
       y[n]=x[n];
    }
    return y;
}
var http = require('http'),io = require('socket.io'),fs = require('fs'),request = require('request');
var server = http.createServer();
server.listen(3000);
io = io.listen(server);

io.on('connection', function (cn) {
    function tx(x){cn.emit('f',x);}
    cn.on('f', function (d) {
        switch(d.f){
            case'diag':
                tx(ebay_cred);
            break;
            case'getOrders':
                d.op.serviceName='Trading',d.op.opType='GetSellingManagerSoldListings';
                ebay.xmlRequest(s.userOps(d.op),function(er,d) {
                    tx({f:'getOrders',d:ebay.flatten(d)});
                });
            break;
            case'x':
                ebay.xmlRequest(s.userOps(d.op),function(er,d) {
                    tx(d);
                });
            break;
        }
    });
});

my client code looks like this

    <table id="processingOrders">
        <tbody>

        </tbody>
    </table>
<script>
  $user={token:'XXXXXXXXXXXX'}
  var socket = io('ws://localhost:3000');
    function cx(x){
        if(!x.op){x.op={}};x.op.authToken=$user.token;
        socket.emit('f',x);
    }
    socket.on('f',function (d) {
        console.log(d);
        switch(d.f){
            case'getOrders':
                d.e=$('#processingOrders');
                d.tmp='';
                if(d.d&&d.d.SaleRecord){
                $.each(d.d.SaleRecord,function(n,v){
                    v._SM=v.SellingManagerSoldTransaction,v._SA=v.ShippingAddress;
                    d.tmp+='<tr>';
                        d.tmp+='<td>'+v._SM.ItemTitle+'</td><td>'+v._SA.Name+'</td><td>'+v._SA.PostalCode+'</td>';
                    d.tmp+='</tr>';
                });
                }
                d.e.find('tbody').append(d.tmp);
            break;
        }
        delete(d.tmp);
    });
    </script>

Some example client calls:

cx({f:'getOrders'})
cx({f:'x',ops:{serviceName:'Finding',opType:'GetSellingManagerSaleRecord',params:{ItemID:"172279039480",TransactionID:"1581513952007"}}})
moeiscool commented 8 years ago

found the issue LOL biggest noob mistake ever. please close this.

cx({f:'x',ops:{serviceName:'Finding',opType:'GetSellingManagerSaleRecord',params:{ItemID:"172279039480",TransactionID:"1581513952007"}}})

should be

cx({f:'x',op:{serviceName:'Finding',opType:'GetSellingManagerSaleRecord',params:{ItemID:"172279039480",TransactionID:"1581513952007"}}})

op not ops :P LOL my own code

moeiscool commented 8 years ago

my edited and working code

s={};
s.userOps=function(x,y){
    y=function(){return ebay_cred};
    for (var n in x) {
       y[n]=x[n];
    }
    return y;
}
var http = require('http'),io = require('socket.io'),fs = require('fs'),request = require('request');
var server = http.createServer();
server.listen(3000);
io = io.listen(server);

io.on('connection', function (cn) {
    function tx(x){cn.emit('f',x);}
    cn.on('f', function (d) {
        switch(d.f){
            case'diag':
                tx(ebay_cred);
            break;
            case'getOrders':
                d.op.serviceName='Trading',d.op.opType='GetSellingManagerSoldListings';
                ebay.xmlRequest(s.userOps(d.op),function(er,e) {
                    tx({f:'getOrders',d:e});
                });
            break;
            case'x':
//                d.op.serviceName='Trading',d.op.opType='GetSellingManagerSaleRecord';
                ebay.xmlRequest(s.userOps(d.op),function(er,d) {
                    tx(d);
                });
            break;
        }
    });
});
noderat commented 7 years ago

@moeiscool You can close the ticket with the button at the bottom of the issue page when you're logged in.