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: add rules API #65

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open

feat: add rules API #65

wants to merge 3 commits into from

Conversation

kschiew
Copy link

@kschiew kschiew commented Aug 31, 2023

This PR exposes the Rules API for TypeScript SDK users to calculate dynamic derived data.

Features:

  • New function rules() which sends a POST request to sgID Rules Engine server to retrieved the dynamic derived data.

Improvements:

  • Add commas behind every JSDoc comments for consistency.

Before & After Screenshots

BEFORE:
image
AFTER:
image

Tests

Tested locally on an sgid-test-app draft PR via npm pack.

Deploy Notes

New dependencies:

New dev dependencies:

Copy link
Contributor

@PrawiraGenestonlia PrawiraGenestonlia left a comment

Choose a reason for hiding this comment

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

left comments!

package.json Outdated Show resolved Hide resolved
src/SgidClient.ts Show resolved Hide resolved
src/constants.ts Outdated Show resolved Hide resolved
src/types.ts Show resolved Hide resolved
Copy link
Contributor

@PrawiraGenestonlia PrawiraGenestonlia left a comment

Choose a reason for hiding this comment

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

Can you also add test cases?

}
return await response.json()
} catch (err) {
return Promise.reject((err as Error).message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return Promise.reject((err as Error).message)
throw new Error(err)

const response = await fetch(this.rulesEngineEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you using application/x-www-form-urlencoded instead of json?

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

Successfully merging this pull request may close these issues.

2 participants