woocommerce / wc-api-ruby

A Ruby wrapper for the WooCommerce API.
MIT License
69 stars 73 forks source link

API Documentation and Behavior Mismatch #40

Closed natesholland closed 7 years ago

natesholland commented 7 years ago

I'm looking at the documentation for V2 for listing all orders and I'm noticing a number of discrepancies in the documentation and how it performs http://woocommerce.github.io/woocommerce-rest-api-docs/?ruby#list-all-orders

For example the orderby and order flags seem to have no effect on what gets returned. Additionally the per_page options doesn't actually change the page size that comes back and after does not seem to have any effect on what comes back.

Here is an example script that should replicate the problems:

# Setup:
require "woocommerce_api"

woocommerce = WooCommerce::API.new(
    "http://example.com", # Your store URL
    "consumer_key", # Your consumer key
    "consumer_secret", # Your consumer secret
    {
        wp_json: true, # Enable the WP REST API integration
        version: "v2" # WooCommerce WP REST API version
    }
)

result1 = woocommerce.get("orders?order=asc&orderby=slug").parsed_response
result2 = woocommerce.get("orders?order=desc&orderby=date").parsed_response

if result1 == result2
  puts "FAIL: ordering should change the results that come back"
else
  puts "PASS: it looks like the ordering changed things which is good"
end

result1 = woocommerce.get("orders?per_page=10").parsed_response # This is the default value
result2 = woocommerce.get("orders?per_page=15").parsed_response

if result1 == result2
  puts "FAIL: page size should be different"
else
  puts "PASS: it looks like the page size is different which is good"
end
natesholland commented 7 years ago

I believe this was mainly based on my confusion between the gem's documentation and the websites documentation. I opened a PR on the website documentation to resolve my issues: https://github.com/woocommerce/woocommerce-rest-api-docs/pull/112