evershopcommerce / evershop

🛍️ NodeJS E-commerce Platform
https://evershop.io/
GNU General Public License v3.0
3.6k stars 946 forks source link

Use of APIs #500

Closed leandrosantoss closed 1 week ago

leandrosantoss commented 1 month ago

Hello everyone, I installed evershop, but I didn't understand how to do a GET /products.

I'll need some GET that don't exist in the catalog:

GET /products GET /products/:id GET /categories GET /categories/:id ... etc

Do I need to implement something? Can you help me?

Thanks!

treoden commented 1 month ago

Hi @leandrosantoss ,

EverShop uses Graphql for query data. So instead of looking for REST API, you can check the Graphql query

image

Thanks

leandrosantoss commented 4 weeks ago

Yes, I managed it via GraphQL. I'm going to integrate ecommerce with a chatbot and I'm having trouble understanding:

  1. Retrieve (Category, Product, etc) via GraphQL (Ok)
  2. Add item to cart needs to have a sessionID to call the http://localhost:3000/api/cart/mine/items service, but how do I get this sessionID?

In the chatbot, the customer will list categories, then list products in the category, add to cart, generate order and finalize.

My code is in nodejs and I will need to make calls to Evershop.

Can you help me?

leandrosantoss commented 4 weeks ago

Here, is basic flow

image

treoden commented 4 weeks ago

So you are looking for an API which help you create a new shopping cart and return the ID of the cart, from here you can add item and finish the checkout based on the cart ID right?

leandrosantoss commented 4 weeks ago

Yes, perfect!

Do you help me?

Thanks!

leandrosantoss commented 4 weeks ago

There could be a feature that just creates a cart:

POST /carts Request:

{
"full_name": {{customer_name}}
"email": {{customer_email}}
}

Response:

{
"cardId": {{cardId}}
}

If there is an active cart (by email) return the existing one, so you can continue your purchase.

What do you think?

treoden commented 4 weeks ago

Hi @leandrosantoss ,

Yes it is a good Idea. How about we ask for at lease 1 first item to create a cart?

Something like

POST /carts Request:

   {
      "full_name": {{customer_name}},
      "email": {{customer_email}},
      "items": [
        {
          "sku": "justasku",
          "qty": 1
        }
      ]
    }
leandrosantoss commented 4 weeks ago

Yes, perfect!

Do you implement? Or do I implement it?

treoden commented 4 weeks ago

Hi @leandrosantoss ,

I will implement it, it will be included in the next release. I will let you know the timeline soon. Ideally in this month

Thanks

leandrosantoss commented 4 weeks ago

Ok, thanks @treoden !

I await the schedule to continue my development

If you need help I can help you.

Thanks!

leandrosantoss commented 3 weeks ago

Hi, @treoden

Prioritized for this month?

Thanks

treoden commented 3 weeks ago

Yes I am working on it @leandrosantoss

leandrosantoss commented 3 weeks ago

Thank you very much

leandrosantoss commented 2 weeks ago

Hi @treoden,

PR 512 contains this implementation, correct?

What version of evershop should I put in package.json to pull this FEATURE?

Thanks

treoden commented 2 weeks ago

Hi @leandrosantoss ,

Yes the PR includes the create cart API. Please wait, I am doing some more test and release a package to the npm. I will keep you posted here. Thanks

leandrosantoss commented 1 week ago

Hi @treoden , I installed the new version 1.1.0.

I run the build: > evershop build ✔ Client ✔ Server Compiled successfully in 1.93m

I run start: `> ecommerce@1.0.0 start

evershop start production`

But no message "Started sucessful in localhost:3000"

If execute https://localhost:3000 in browser, display this error:

image

In terminal this error: ❌ error: Enum "FilterOperation" cannot represent non-enum value: "=". GraphQLError: Enum "FilterOperation" cannot represent non-enum value: "=". at GraphQLEnumType.parseLiteral (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\type\definition.js:1140:13) at isValidValueNode (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\validation\rules\ValuesOfCorrectTypeRule.js:154:30) at Object.StringValue (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\validation\rules\ValuesOfCorrectTypeRule.js:118:28) at Object.enter (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\language\visitor.js:301:32) at Object.enter (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\utilities\TypeInfo.js:391:27) at visit (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\language\visitor.js:197:21) at validate (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\graphql\validation\validate.js:91:24) at graphql (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\@evershop\evershop\src\modules\graphql\pages\global\[buildQuery]graphql[notification].js:32:34) at asyncMiddlewareWrapper (C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\@evershop\evershop\src\lib\middleware\async.js:24:18) at C:\Users\lpdsa\Documents\Projetos\SquidTech\Git\ecommerce\node_modules\@evershop\evershop\src\lib\middleware\buildMiddlewareFunction.js:56:11

Help me understand if something is wrong?

treoden commented 1 week ago

Hi @leandrosantoss

This new release comes with a changes to the FillterOperation input GraphQL query. If you are working on a customization using GraphQL collection filtering, you will have to pass the operation argument to the query variable.

Before

{key: 'type', value: 'select'}

After

{ key: 'type', operation: 'eq', value: 'select' }

The operation value should be one of the following: eq, neq, gt, gteq, lt, lteq, like, nlike, in, nin

Thank you

treoden commented 1 week ago

Hi @leandrosantoss ,

Let me know if you solved the issue. You can refer to my commit here for example: https://github.com/evershopcommerce/evetheme/commit/3de75b1a34aa24ae9b9c4165db7f2977360a5639

Thanks

leandrosantoss commented 1 week ago

Resolved! I validated the POST/carts API and it worked perfectly. Thank you for your help.