GithubHelp home page GithubHelp logo

Comments (4)

Ninigi avatar Ninigi commented on May 27, 2024

Hmm, how should we do this... You think just returning a list would be appropriate?

Shopify.CollectionListing.get_product_ids(session, collection_id)
# => %{product_ids: [123123, 987786, ...]}

@lewisf It's pretty easy to implement, question is should we add a generic section for things that do not really justify a resource struct.

EDIT: What I mean is, are there any other endpoints that return something like this outside of count? If so, we should probably look into it.

from shopify.

lewisf avatar lewisf commented on May 27, 2024

returning a list is good but maybe also in the standard %Shopify.Response struct with code/data?

I just clicked through the api docs there's only one other instance of this:
https://help.shopify.com/en/api/reference/sales-channels/productlisting#product_ids

and I also need it :P lucky me I guess?

from shopify.

lewisf avatar lewisf commented on May 27, 2024

@Ninigi if you agree then we can move forward with this. so far it doesn't look like there are any other endpoints that return a list of ids, so maybe it makes sense to build a general escape hatch?

here's my quick analysis of the changes that need to be made:

since it seems like this is only local to these resources, we can manually add functions to make the right calls here:
https://github.com/nsweeting/shopify/blob/master/lib/shopify/resources/collection_listing.ex
https://github.com/nsweeting/shopify/blob/master/lib/shopify/resources/product_listing.ex

we'd also need to overload Shopify.Request.new to handle the case where resource isn't specified. Would it be sufficient to pass in nil as the resource here? https://github.com/nsweeting/shopify/blob/master/lib/shopify/request.ex#L30-L40

and change Shopify.Response to handle responses where something other than Shopify.resources are returned as data.

The one thing I think needs to be configured is the "singular" / "plural" of the returned data to handle parsing {product_ids: [...]} into the proper %Shopify.Response{code: 200, data: [...]} struct.

from shopify.

Ninigi avatar Ninigi commented on May 27, 2024

@lewisf If you have the time to look into it, it would be very much appreciated 👍

I think it might actually be not that different from a call to the count resources or spam in this resource

So it might actually not need many modifications, but if you want to come up with a fancy solution I'll be happy to do a review 👍

from shopify.

Related Issues (20)

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.