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 create retrieve and update api endpoints for organization resource #5361

Merged

Conversation

hrithikesh026
Copy link
Contributor

@hrithikesh026 hrithikesh026 commented Jul 18, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Added /organization route to do crud operation on organization table.

Authentication method for /organization will be admin-api-key

Also generated openapi spec for the new api models and endpoints.

New Routes:
create: POST-> {base_url}/organization/
retrieve: Get-> {base_url}/organization/:id
update: Put-> {base_url}/organization/:id

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Manual

  1. create an organization
curl --location 'http://localhost:8080/organization' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "organization_name": "my_org"
}'

Response:

{
    "organization_id": "org_q98uSGAYbjEwqs0mJwnz",
    "organization_name": "my_org"
}
  1. Retrieve the organization
curl --location --request GET 'http://localhost:8080/organization/org_q98uSGAYbjEwqs0mJwnz' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "organization_name": "my_org"
}'

Response:

{
    "organization_id": "org_q98uSGAYbjEwqs0mJwnz",
    "organization_name": "my_org"
}
  1. Update the organization
curl --location --request PUT 'http://localhost:8080/organization/org_q98uSGAYbjEwqs0mJwnz' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "organization_name": "your_org"
}'

Response:

{
    "organization_id": "org_q98uSGAYbjEwqs0mJwnz",
    "organization_name": "your_org"
}

DB screenshot.
image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@hrithikesh026 hrithikesh026 added C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed M-api-contract-changes Metadata: This PR involves API contract changes labels Jul 18, 2024
@hrithikesh026 hrithikesh026 added this to the July 2024 Release milestone Jul 18, 2024
@hrithikesh026 hrithikesh026 self-assigned this Jul 18, 2024
@hrithikesh026 hrithikesh026 requested review from a team as code owners July 18, 2024 11:25
crates/api_models/src/organization.rs Outdated Show resolved Hide resolved
crates/router/src/core/admin.rs Outdated Show resolved Hide resolved
@hrithikesh026 hrithikesh026 requested a review from a team as a code owner July 19, 2024 10:15
sahkal
sahkal previously approved these changes Jul 22, 2024
lsampras
lsampras previously approved these changes Jul 22, 2024
@hrithikesh026 hrithikesh026 dismissed stale reviews from lsampras and sahkal via b111bdf July 22, 2024 14:08
Self(organization_id)
}

/// Get the string representation of customer id
Copy link
Member

Choose a reason for hiding this comment

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

can you replace the instances of customer id with organization id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be done in this PR: #5380

Comment on lines +3 to +6
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "payment_v2")))]
use common_utils::types::keymanager::KeyManagerState;
#[cfg(all(feature = "v2", feature = "payment_v2"))]
use common_utils::types::keymanager::KeyManagerState;
Copy link
Member

Choose a reason for hiding this comment

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

is the feature gating required for this import? since we are using KeyManagerState in both the features

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cargo clippy --no-default-features will say unused imports.

Comment on lines +1 to +7
#[cfg(all(
any(feature = "v1", feature = "v2"),
not(feature = "merchant_account_v2")
))]
use common_utils::id_type;
#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]
use common_utils::id_type;
Copy link
Member

Choose a reason for hiding this comment

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

we can use the type alias where the type is used, this feature gating for imports can be avoided

@pixincreate pixincreate added this pull request to the merge queue Jul 24, 2024
Merged via the queue into main with commit 26b8783 Jul 24, 2024
21 checks passed
@pixincreate pixincreate deleted the introduce-organization-create-retrieve-update-endpoints branch July 24, 2024 07:04
pixincreate added a commit that referenced this pull request Jul 24, 2024
* 'main' of github.com:juspay/hyperswitch: (27 commits)
  refactor(connector): added amount conversion framework for billwerk (#4972)
  feat(connector): [Itaubank] Add refund and rsync flow  (#5420)
  feat: create additional columns in organization table (#5380)
  refactor(merchant_id): create domain type for `merchant_id` (#5408)
  fix(euclid): remove business_profile routing feature flag (#5430)
  feat: add create retrieve and update api endpoints for organization resource (#5361)
  chore(version): 2024.07.24.0
  refactor(connector): [Itaubank] add dynamic fields for pix (#5419)
  Feat(connector): [WELLSFARGO] Add template code (#5333)
  fix(connector): [Datatrans] Handling for 4-Digit YYYY input and Correct 3DS Routing to no_3ds (#5410)
  refactor(connector):  add amount conversion framework to volt (#4985)
  chore(users): email templates footer icon style enhance (#5375)
  feat(customer): customer v2 refactor for customer create end point (#5350)
  chore(version): 2024.07.23.0
  fix(router): store `network_transaction_id` in stripe `authorize` flow (#5399)
  ci: handle packages to run are being empty (#5403)
  chore: add customer, shipping and billing details to payment_response for payment list api (#5401)
  refactor(dashboard_metadata): alter query for merchant scoped metadata (#5397)
  refactor(connector): Add billing_country in klarna dynamic fields (#5373)
  feat(connector): [Itau Bank] Add payment and sync flow for Pix (#5342)
  ...
@SanchithHegde SanchithHegde removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants