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

feat: increments commerce client #2647

Merged

Conversation

Guilera
Copy link
Collaborator

@Guilera Guilera commented Jan 29, 2025

What's the purpose of this pull request?

To add the Reviews & Ratings API integration through commerce client

How it works?

Adds 3 new calls to the client:

  • client.commerce.rating (retrieves rating information for a specific product)
  • client.commerce.reviews.list (retrieves all reviews for a specific product)
  • client.commerce.reviews.create (creates a new review for a specific product)

How to test it?

Creates a .ts file on the root folder of the project and adds the following code:

import { getContextFactory, Options } from "./packages/api/src/platforms/vtex";

const apiOptions = {
  platform: 'vtex',
  account: 'storeframework',
  locale: 'en-US',
  environment: 'vtexcommercestable',
  channel: '{"salesChannel":"1"}',
  showSponsored: false,
} as Options

const apiCtx = getContextFactory(apiOptions)

const commerceApiClient = apiCtx({}).clients.commerce

After that you can use the commerceApiClient to call the new methods.

To run the file locally use the following command:

npx tsx 

References

JIRA Task: SFS-2092
Reviews & Ratings API Doc

Checklist

PR Description

  • Added Rating types
  • Added Reviews types
  • Incremented ProductSearchReviewResult
  • Created adapatObject function on utils
  • Created camelToSnakeCase function on utils

@Guilera Guilera requested a review from a team as a code owner January 29, 2025 14:40
@Guilera Guilera requested review from eduardoformiga and lariciamota and removed request for a team January 29, 2025 14:40
Copy link

vercel bot commented Jan 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
faststore-site ✅ Ready (Inspect) Visit Preview Jan 30, 2025 2:43pm

Copy link

codesandbox-ci bot commented Jan 29, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Contributor

@lucasfp13 lucasfp13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raise some discussions 💭

Copy link
Contributor

@lucasfp13 lucasfp13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commerce functions are working as expected, LGTM!

@lucasfp13 lucasfp13 merged commit 93262b4 into feat/reviews-and-ratings Feb 6, 2025
4 checks passed
@lucasfp13 lucasfp13 deleted the feat/reviews-and-ratings-api-client branch February 6, 2025 15:03
@Guilera Guilera mentioned this pull request Feb 6, 2025
2 tasks
artursantiago pushed a commit that referenced this pull request Feb 7, 2025
## What's the purpose of this pull request?

To add the Reviews & Ratings API integration through commerce client

## How it works?

Adds 3 new calls to the client:
- client.commerce.rating (retrieves rating information for a specific
product)
- client.commerce.reviews.list (retrieves all reviews for a specific
product)
- client.commerce.reviews.create (creates a new review for a specific
product)

## How to test it?

Creates a `.ts` file on the root folder of the project and adds the
following code:
```typescript
import { getContextFactory, Options } from "./packages/api/src/platforms/vtex";

const apiOptions = {
  platform: 'vtex',
  account: 'storeframework',
  locale: 'en-US',
  environment: 'vtexcommercestable',
  channel: '{"salesChannel":"1"}',
  showSponsored: false,
} as Options

const apiCtx = getContextFactory(apiOptions)

const commerceApiClient = apiCtx({}).clients.commerce
```

After that you can use the `commerceApiClient` to call the new methods.

To run the file locally use the following command:
```bash
npx tsx 
```

## References

[JIRA Task: SFS-2092](https://vtex-dev.atlassian.net/browse/SFS-2092)
[Reviews & Ratings API
Doc](https://developers.vtex.com/docs/api-reference/reviews-and-ratings-api#overview)

## Checklist

**PR Description**

- [ ] Added Rating types
- [ ] Added Reviews types
- [ ] Incremented ProductSearchReviewResult
- [ ] Created adapatObject function on `utils`
- [ ] Created camelToSnakeCase function on `utils`
artursantiago pushed a commit that referenced this pull request Feb 7, 2025
## What's the purpose of this pull request?

To add the Reviews & Ratings API integration through commerce client

## How it works?

Adds 3 new calls to the client:
- client.commerce.rating (retrieves rating information for a specific
product)
- client.commerce.reviews.list (retrieves all reviews for a specific
product)
- client.commerce.reviews.create (creates a new review for a specific
product)

## How to test it?

Creates a `.ts` file on the root folder of the project and adds the
following code:
```typescript
import { getContextFactory, Options } from "./packages/api/src/platforms/vtex";

const apiOptions = {
  platform: 'vtex',
  account: 'storeframework',
  locale: 'en-US',
  environment: 'vtexcommercestable',
  channel: '{"salesChannel":"1"}',
  showSponsored: false,
} as Options

const apiCtx = getContextFactory(apiOptions)

const commerceApiClient = apiCtx({}).clients.commerce
```

After that you can use the `commerceApiClient` to call the new methods.

To run the file locally use the following command:
```bash
npx tsx 
```

## References

[JIRA Task: SFS-2092](https://vtex-dev.atlassian.net/browse/SFS-2092)
[Reviews & Ratings API
Doc](https://developers.vtex.com/docs/api-reference/reviews-and-ratings-api#overview)

## Checklist

**PR Description**

- [ ] Added Rating types
- [ ] Added Reviews types
- [ ] Incremented ProductSearchReviewResult
- [ ] Created adapatObject function on `utils`
- [ ] Created camelToSnakeCase function on `utils`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants