Coder Social home page Coder Social logo

ruby-mws's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ruby-mws's Issues

next fails after multiple list_order_items

I get an error when trying to do a mws.orders.next :
mwstestcase.rb:73:in <main>': undefined methodhas_key?' for nil:NilClass (NoMethodError)

and if I save the response.next_token and try mws.orders.list_orders_by_next_response, I get another error:
mwstestcase.rb:70:in <main>': undefined methodlist_orders_by_next_response' for #MWS::API::Order:8366400 (NoMethodError)

The problem is duplicated if I do multiple mws.orders.list_order_items between the mws.orders.list_orders and the mws.orders.next.

Here is the test case for response.next_token:

require 'rubygems'
require 'ruby-mws'
require 'active_record'
require 'active_support/all'

def get_response # takes a block as a parameter
  #amazon requests may be throttled, so we need to check before returning results
  throttled = true
  while throttled == true 
    the_response = yield                        
    if the_response.has_key?("error_response")                  # all error responses should have this key
      if the_response.error_response.error.has_key?("code")         
        if the_response.error_response.error.code == "RequestThrottled"
          sleep(10.seconds)                     # throttle times may vary, so retry after 10 sec
        end
      else
        puts "unknown error"
        return nil 
      end
    else
      throttled = false
      return the_response
    end
  end
end

mws = MWS.new ({:aws_access_key_id => "",
  :secret_access_key => "++",
  :seller_id => "",
  :marketplace_id => ""})


start_time = Time.utc(2003)                                         # default start date

response = get_response {mws.orders.list_orders :last_updated_after => start_time}                        

n = 0
while n < 3 do 

  if mws.orders.has_next? == true
    puts "has next"
    next_token = response.next_token
  else
    puts "does not have next"
  end

  response.orders.each do |r|
    order_items = get_response {mws.orders.list_order_items :amazon_order_id => r.amazon_order_id}
      if order_items
        order_items.order_items.each do |item|
        puts r.amazon_order_id, item.title
      end 
    end
  end


puts "trying next_token!"  
response = get_response {mws.orders.list_orders_by_next_response :next_token => next_token}                       

n += 1
end

uncaught exception in openssl

Hi,

Thanks for writing this. It's very useful. I am writing to report an error I came across. Not repeatable so far (below).

While I'm at it, I might as well report that mws.orders.next doesn't work for me, so I have to use: mws.orders.list_orders :last_updated_after => start_time

Here's the error message:

C:/Ruby193/lib/ruby/1.9.1/openssl/buffering.rb:174:in sysread_nonblock': end of file reached (EOFError) from C:/Ruby193/lib/ruby/1.9.1/openssl/buffering.rb:174:inread_nonbloc
k'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:141:in rbuf_fill' from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:inreaduntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in readline' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:inread_status_line'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in read_new' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:inblock in transport_r
equest'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in catch' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:intransport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in request' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1286:inblock in request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in start' from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:inrequest'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httparty-0.11.0/lib/httparty/re
quest.rb:92:in perform' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httparty-0.11.0/lib/httparty.rb :461:inperform_request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/httparty-0.11.0/lib/httparty.rb
:398:in get' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-mws-0.0.4/lib/ruby-mws/api /base.rb:49:insend_request'
from (eval):4:in list_order_items' from mws.rb:103:inblock (2 levels) in

'
from mws.rb:29:in get_response' from mws.rb:103:inblock in '
from mws.rb:91:in each' from mws.rb:91:in'

How do I get the tests to pass?

Hi, I just forked the project and I would like to contribute to the feeds api. But first, can you help me understand what I need to do to get the tests to pass? I just ran rspec spec and I get failures like this (I tried looking through the source and tests, I took a look at the ephemeral_response gem and tried adding a credential.yml file afterwards, but I wasn't able to progress much):

....FFFFFFF.......

Failures:

  1. MWS::API::Inventory requests list_inventory_supply should return items based on seller SKUs
    Failure/Error: items = @mws.inventory.list_inventory_supply :timestamp => @timestamp,
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:11-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`list_inventory_supply'

    ./spec/ruby-mws/api/inventory_spec.rb:15:in `block (4 levels) in <top (required)>'

  2. MWS::API::Inventory requests list_inventory_supply should return items with inventory changes since a certain time
    Failure/Error: items = @mws.inventory.list_inventory_supply :timestamp => @timestamp,
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:11-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`list_inventory_supply'

    ./spec/ruby-mws/api/inventory_spec.rb:22:in `block (4 levels) in <top (required)>'

  3. MWS::API::Order requests list_orders should receive a list of orders
    Failure/Error: orders = @mws.orders.list_orders :last_updated_after => "2012-01-15T13:07:26-05:00" ,
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:55-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`list_orders'

    ./spec/ruby-mws/api/order_spec.rb:14:in `block (4 levels) in <top (required)>'

  4. MWS::API::Order requests list_orders_by_next_token should receive a list_orders_by_next_token_result
    Failure/Error: orders = @mws.orders.list_orders_by_next_token :timestamp => @timestamp,
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:55-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`list_orders_by_next_token'

    ./spec/ruby-mws/api/order_spec.rb:23:in `block (4 levels) in <top (required)>'

  5. MWS::API::Order requests get_order should return one order for one order id
    Failure/Error: order = @mws.orders.get_order :amazon_order_id => "102-4850183-7065809",
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:55-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`get_order'

    ./spec/ruby-mws/api/order_spec.rb:32:in `block (4 levels) in <top (required)>'

  6. MWS::API::Order requests get_order should return multiple orders for multiple order ids
    Failure/Error: orders = @mws.orders.get_order :amazon_order_id => ["102-4850183-7065809", "002-3400187-5292203"],
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:55-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`get_order'

    ./spec/ruby-mws/api/order_spec.rb:40:in `block (4 levels) in <top (required)>'

  7. MWS::API::Order requests list_order_items should return a list of items for an order
    Failure/Error: order = @mws.orders.list_order_items :amazon_order_id => "102-4850183-7065809",
    MWS::ErrorResponse:
    RequestExpired: Request has expired. Timestamp date: 2012-04-25T21:42:55-04:00

    ./lib/ruby-mws/api/response.rb:22:in `handle_error_response'

    ./lib/ruby-mws/api/response.rb:8:in`parse'

    ./lib/ruby-mws/api/base.rb:49:in `send_request'

    (eval):4:in`list_order_items'

    ./spec/ruby-mws/api/order_spec.rb:50:in `block (4 levels) in <top (required)>'

Just updated and am seeing errors

Hello, I was using a previous version of this gem and it was working fine, but I just updated and now I am having problems:

  • Previously, when Amazon throttled requests, my app caught that with the following code:
def get_response # takes a block as a parameter
    #amazon requests may be throttled, so we need to check before returning results
    throttled = true
  s = 5
    while throttled == true 
        the_response = yield                                                
        if the_response.has_key?("error_response")                                  # all error responses should have this key
            if the_response.error_response.error.has_key?("code")                   
                if the_response.error_response.error.code == "RequestThrottled"
                    sleep(s.seconds)                                            # throttle times may vary, so retry after 10 sec
          s = s*1.5
                end
            else
                puts "unknown error"
                return nil 
            end
        else
            throttled = false
            return the_response
        end
    end
end

Now, I don't even see the throttled response and instead I get a program crash as follows:

-> "<?xml version=\"1.0\"?>\n<ErrorResponse xmlns=\"https://mws.amazonservices.c
om/Orders/2011-01-01\">\n  <Error>\n    <Type></Type>\n    <Code>RequestThrottle
d</Code>\n    <Message>Request is throttled</Message>\n  </Error>\n  <RequestID>
740e1669-dab8-4776-b8dd-ebf1938c958a</RequestID>\n</ErrorResponse>\n"
read 291 bytes
Conn close
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-mws-0.1/lib/ruby-mws/api/response.rb:24
:in `handle_error_response': RequestThrottled: Request is throttled (MWS::ErrorR
esponse)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-mws-0.1/lib/ruby-mws/api/r
esponse.rb:10:in `parse'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ruby-mws-0.1/lib/ruby-mws/api/b
ase.rb:45:in `send_request'
        from (eval):4:in `list_order_items'
        from mws.rb:98:in `block (2 levels) in <main>'
        from mws.rb:29:in `get_response'
        from mws.rb:98:in `block in <main>'
        from mws.rb:87:in `each'
        from mws.rb:87:in `<main>'

Also:

  • Debug information for every message sent and received is being echoed to the terminal. How do I disable this?

Thanks very much.

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

  spec.license = 'MIT'
  # or
  spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.