-
Notifications
You must be signed in to change notification settings - Fork 3
[PB-4388]: feat/update object storage functions #293
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "name": "@internxt/sdk", | ||
| "author": "Internxt <[email protected]>", | ||
| "version": "1.9.20", | ||
| "version": "1.9.21", | ||
| "description": "An sdk for interacting with Internxt's services", | ||
| "repository": { | ||
| "type": "git", | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,30 +24,40 @@ describe('Object Storage service', () => { | |
|
|
||
| const body = await client.getObjectStoragePlanById('plan_123', 'eur'); | ||
|
|
||
| expect(callStub.firstCall.args).toEqual(['/object-storage-plan-by-id?planId=plan_123¤cy=eur', headers]); | ||
| expect(callStub.firstCall.args).toEqual(['/object-storage/price?planId=plan_123¤cy=eur', headers]); | ||
| expect(body).toEqual({ id: 'plan_123' }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Create customer for object storage', () => { | ||
| it('When create customer is requested, then it should call with right params & return data', async () => { | ||
| const callStub = sinon.stub(httpClient, 'post').resolves({ | ||
| const callStub = sinon.stub(httpClient, 'get').resolves({ | ||
| customerId: 'cus_123', | ||
| }); | ||
| const { client, headers } = basicHeadersAndClient(); | ||
|
|
||
| const body = await client.createCustomerForObjectStorage({ | ||
| name: 'test', | ||
| const body = await client.getObjectStorageCustomerId({ | ||
| customerName: 'test', | ||
| postalCode: '123456', | ||
| email: '[email protected]', | ||
| country: 'US', | ||
| companyVatId: '1234567890', | ||
| }); | ||
|
|
||
| expect(callStub.firstCall.args).toEqual([ | ||
| '/create-customer-for-object-storage', | ||
| { name: 'test', email: '[email protected]', country: 'US', companyVatId: '1234567890' }, | ||
| headers, | ||
| ]); | ||
| const customerName = 'test'; | ||
| const postalCode = '123456'; | ||
| const email = '[email protected]'; | ||
| const country = 'US'; | ||
| const companyVatId = '1234567890'; | ||
|
|
||
| const query = new URLSearchParams(); | ||
| query.set('customerName', customerName); | ||
| query.set('email', email); | ||
| query.set('postalCode', postalCode); | ||
| query.set('country', country); | ||
| query.set('companyVatId', companyVatId); | ||
|
|
||
| expect(callStub.firstCall.args).toEqual([`/object-storage/customer?${query.toString()}`, headers]); | ||
| expect(body).toEqual({ customerId: 'cus_123' }); | ||
| }); | ||
| }); | ||
|
|
@@ -62,22 +72,19 @@ describe('Object Storage service', () => { | |
|
|
||
| await client.createObjectStorageSubscription({ | ||
| customerId: 'cus_123', | ||
| plan: { id: 'plan_123', bytes: 1000, interval: 'month', amount: 1000, currency: 'eur', decimalAmount: 10.0 }, | ||
| priceId: 'price_id', | ||
| currency: 'eur', | ||
| token: 'token', | ||
| companyName: 'test', | ||
| vatId: '1234567890', | ||
| promoCodeId: 'promo_123', | ||
| }); | ||
|
|
||
| expect(callStub.firstCall.args).toEqual([ | ||
| '/create-subscription-for-object-storage', | ||
| '/object-storage/subscription', | ||
| { | ||
| customerId: 'cus_123', | ||
| priceId: 'plan_123', | ||
| priceId: 'price_id', | ||
| token: 'token', | ||
| currency: 'eur', | ||
| companyName: 'test', | ||
| companyVatId: '1234567890', | ||
| promoCodeId: 'promo_123', | ||
| }, | ||
| headers, | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are using a GET method to create a customer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of this endpoint is to get the customer ID, regardless of whether the user already has one or it needs to be created. It’s a retrieval operation from the client’s perspective, which is why we’re using GET.