woocommerce / wc-api-ruby

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

List all customers filter parameters are not working #38

Closed marcosteixeira closed 5 years ago

marcosteixeira commented 7 years ago

Hello, I'm using version 1.4.0 and trying to filter customers using exclude, include, email and role parameters.

Ex:

store = OpenStruct.new(woocommerce_url: "http://emojiskaitiniai.lt/wootest", token: "ck_8640cd6ad69dd8a2a0fc16b3b4eef73cd82d8e1b", consumer_secret: "cs_0f7cb647a1caeb9d8dd6ef786fcec16ca563c453")

@client = WooCommerce::API.new(
  store.woocommerce_url,
  store.token,
  store.consumer_secret
)

@client.get('customers', exclude: [4])
# or
@client.get('customers', include: [4])
# or
@client.get('customers', email: marcos@smartrmail.com)

I always get all the records. Same for the orders endpoints.

Thanks

claudiosanches commented 7 years ago

Looks like you just exposed your API keys to everyone. Better purge it.

marcosteixeira commented 7 years ago

Already did :D

claudiosanches commented 7 years ago

Cool, I'll make some tests with the parameters by the weekend, and I let you know.

hobertro commented 6 years ago

Hi @claudiosanches, any update on the issue above for include and exclude filters? I tried making a request to the list orders endpoint with the "include" filter populated with order ids (something like { include: [1234, 4567] }) and it returns an 401 invalid signature error. However, if I provide just the order id, something like { include: 1234 }, it will return that single order successfully. Seems the API gets unhappy when providing an array of parameters in the query string params.

Example: http://sb-woo.com:80/woo/wp-json/wc/v2/orders?include[]=5262

(all credentials and signatures removed for security reasons)

claudiosanches commented 5 years ago

@hobertro it's because in the REST API expects a string, like http://sb-woo.com:80/woo/wp-json/wc/v2/orders?include=5262,1234,4567. Sorry for the delay on replying it. But this why array doesn't works.