Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API Support #9

Open
prionkor opened this issue Jan 1, 2021 · 11 comments
Open

REST API Support #9

prionkor opened this issue Jan 1, 2021 · 11 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@prionkor
Copy link

prionkor commented Jan 1, 2021

Continue of the discussion from WP Support Forum

I am going to for this project and start the development. If you have any preferred guidelines on how you structure your code let me know. I am using a pattern like this.

Namespace

/yith/wishlist/v1

Proposed Endpoint for (CRUD)

GET {url}/wishlists
Users with credentials will be returned with an array of wishlists object.

POST {url}/wishlists

Add product/s to wishlist endpoint. Users with credentials will be returned with a wishlists object created from the POST data. if no wishlist id was provided a new wishlist is created otherwise the object with the given id returned.

Params:

wishlistId: id of the wishlist
productIds: an array of product ids. for a single product add send one element array.
userId (optional): In the case of client credentials or API key, admin user auth send userId. For a user auth userId isn't required because userId will be gathered from authentication. Defaults to the current user. (needs discussion)

DELETE {url}/wishlists/{id}

Clears the wishlist data.

DELETE {url}/wishlists/{id}/product/{product_id}

Removes the given product id from wishlist id

@alarocca130
Copy link
Member

Hi there

I am going to for this project and start the development. If you have any preferred guidelines on how you structure your code let me know. I am using a pattern like this.

We of course suggest to create a PR to this repo, in order to improve and extend the plugin
Anyway, as I already told you on wp.org, this is an ongoing project and I'll make use of your post to open discussion about this feature, that will be hopefully added within next major release

Talking about standards, we have no specific suggestions regarding plugin scaffolding, but of course we recommend to follow WP's coding standards and best practice in general; we'll hopefully write a contributing guide for this project soon enough

Regarding namespace, I'd follow WC's example, and place the root of API at wp-json/yith/wishlist/v1

The structure of the API, instead, should describe the two main entities of the project: wishlist and wishlist_item (you can find reference of these objects in dedicated classes, YITH_WooCommerce_Wishlist and YITH_WooCommerce_Wishlist_Item respectively)

I'll spend some time drafting a possible API structure, to share here for anyone who may want to contribute, or even to get feedback before proceeding with development

@alarocca130 alarocca130 added enhancement New feature or request help wanted Extra attention is needed labels Jan 4, 2021
@alarocca130 alarocca130 added this to the 3.1 milestone Jan 4, 2021
@prionkor
Copy link
Author

prionkor commented Jan 6, 2021

Tasks

  • Get list of wishlist
  • Get single wishlist
  • Create Wishlist
  • Update Wishlist
  • Add product to wishlist
  • Remove product from wishlist
  • Delete wishlist
  • Clean wishlist (delete all products form wishlists

@prionkor
Copy link
Author

prionkor commented Jan 9, 2021

As the deadline of one of my client projects approaches. I have created a separate plugin with the work and can be found here https://github.com/prionkor/yith-woocommerce-wishlist-rest-api The checklist above is a list of things that were done.

The plugin needs pull request #11 to be merged to work properly.

@melomontoya
Copy link

As the deadline of one of my client projects approaches. I have created a separate plugin with the work and can be found here https://github.com/prionkor/yith-woocommerce-wishlist-rest-api The checklist above is a list of things that were done.

The plugin needs pull request #11 to be merged to work properly.

Great work @prionkor have you accomplished the "Create Wishlist" task yet?? I'm developing some custom endpoints for a project and I'm kinda stuck in there. Somehow I can create a "wishlist object" but the "->save()" wont work even though it returns an id.

I'm attaching photos of the endpoint, what I get as a response from my endpoint and what I see on the wishlists list. I don't seem to find the one that got created.

Captura de Pantalla 2021-08-24 a la(s) 18 44 09

Captura de Pantalla 2021-08-24 a la(s) 18 41 32

Captura de Pantalla 2021-08-24 a la(s) 18 41 58

@prionkor
Copy link
Author

Sorry, for the delay. I think I did, I will check this in the weekend and get back to you.

@melomontoya
Copy link

Would really appreciate it. Thank you :D

@prionkor
Copy link
Author

prionkor commented Aug 29, 2021

@melomontoya Could you move over to https://github.com/prionkor/yith-woocommerce-wishlist-rest-api and create a ticket there?

BTW, There is always a default wishlist created for a user. Unless you need multiple wishlist you do not need a create wishlist endpoint. You can just add to the wishlist and it should stick.

@melomontoya
Copy link

melomontoya commented Aug 30, 2021

So why would "YITH_WCWL_Wishlist_Factory::get_default_wishlist( $user_id );" return false?
And why I'm not able to see the new wishlists on the backend?
Thanks for your answer :D

@melomontoya
Copy link

hi?

@Chris2011
Copy link

Was this ever added somehow into the plugin?

@Uny1me
Copy link

Uny1me commented Aug 27, 2023

How does still have no updates? can someone provide reference here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants