Skip to content

Commit

Permalink
feat: remove query param from paths already with unique id
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie committed Oct 11, 2023
1 parent e860b72 commit 8b42dfc
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 168 deletions.
17 changes: 0 additions & 17 deletions openapi/resource-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ paths:
description: A client can fetch the latest state of an incoming payment to determine the amount received into the wallet address.
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/wallet-address'
'/incoming-payments/{id}/complete':
post:
summary: Complete an Incoming Payment
Expand Down Expand Up @@ -712,21 +711,6 @@ paths:
$ref: '#/components/responses/403'
'404':
description: Incoming Payment Not Found
requestBody:
content:
application/json:
schema:
type: object
additionalProperties: false
properties:
walletAddress:
$ref: ./schemas.yaml#/components/schemas/walletAddress
required:
- walletAddress
examples:
Complete incoming payment for https://openpayments.guide/alice:
value:
walletAddress: 'https://openpayments.guide/alice/'
description: |-
A client with the appropriate permissions MAY mark a non-expired **incoming payment** as `completed` indicating that the client is not going to make any further payments toward this **incoming payment**, even though the full `incomingAmount` may not have been received.
Expand Down Expand Up @@ -785,7 +769,6 @@ paths:
- $ref: '#/components/parameters/signature'
parameters:
- $ref: '#/components/parameters/id'
- $ref: '#/components/parameters/wallet-address'
'/quotes/{id}':
get:
summary: Get a Quote
Expand Down
6 changes: 3 additions & 3 deletions packages/open-payments/src/client/grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpMethod } from '@interledger/openapi'
import {
GrantOrTokenRequestArgs,
RouteDeps,
UnauthenticatedRequestArgs
UnauthenticatedResourceRequestArgs
} from '.'
import {
getASPath,
Expand All @@ -19,7 +19,7 @@ export interface GrantRouteDeps extends RouteDeps {

export interface GrantRoutes {
request(
postArgs: UnauthenticatedRequestArgs,
postArgs: UnauthenticatedResourceRequestArgs,
args: Omit<GrantRequest, 'client'>
): Promise<PendingGrant | Grant>
continue(
Expand Down Expand Up @@ -47,7 +47,7 @@ export const createGrantRoutes = (deps: GrantRouteDeps): GrantRoutes => {

return {
request: (
{ url }: UnauthenticatedRequestArgs,
{ url }: UnauthenticatedResourceRequestArgs,
args: Omit<GrantRequest, 'client'>
) =>
post(
Expand Down
55 changes: 21 additions & 34 deletions packages/open-payments/src/client/incoming-payment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,13 @@ describe('incoming-payment', (): void => {

nock(serverAddress)
.get('/incoming-payments/1')
.query({ 'wallet-address': walletAddress })
.reply(200, incomingPayment)

const result = await getIncomingPayment(
{ axiosInstance, logger },
{
url: `${serverAddress}/incoming-payments/1`,
accessToken,
walletAddress
accessToken
},
openApiValidators.successfulValidator
)
Expand All @@ -87,7 +85,6 @@ describe('incoming-payment', (): void => {

nock(serverAddress)
.get('/incoming-payments/1')
.query({ 'wallet-address': walletAddress })
.reply(200, incomingPayment)

await expect(
Expand All @@ -98,8 +95,7 @@ describe('incoming-payment', (): void => {
},
{
url: `${serverAddress}/incoming-payments/1`,
accessToken,
walletAddress
accessToken
},
openApiValidators.successfulValidator
)
Expand All @@ -122,8 +118,7 @@ describe('incoming-payment', (): void => {
},
{
url: `${serverAddress}/incoming-payments/1`,
accessToken,
walletAddress
accessToken
},
openApiValidators.failedValidator
)
Expand Down Expand Up @@ -191,9 +186,10 @@ describe('incoming-payment', (): void => {

const result = await createIncomingPayment(
{ axiosInstance, logger },
{ url: serverAddress, walletAddress, accessToken },
{ url: serverAddress, accessToken },
openApiValidators.successfulValidator,
{
walletAddress,
incomingAmount,
expiresAt,
metadata
Expand Down Expand Up @@ -225,9 +221,9 @@ describe('incoming-payment', (): void => {
await expect(
createIncomingPayment(
{ axiosInstance, logger },
{ url: serverAddress, walletAddress, accessToken },
{ url: serverAddress, accessToken },
openApiValidators.successfulValidator,
{}
{ walletAddress }
)
).rejects.toThrowError()
scope.done()
Expand All @@ -243,9 +239,9 @@ describe('incoming-payment', (): void => {
await expect(
createIncomingPayment(
{ axiosInstance, logger },
{ url: serverAddress, walletAddress, accessToken },
{ url: serverAddress, accessToken },
openApiValidators.failedValidator,
{}
{ walletAddress }
)
).rejects.toThrowError()
scope.done()
Expand All @@ -266,8 +262,7 @@ describe('incoming-payment', (): void => {
{ axiosInstance, logger },
{
url: `${serverAddress}/incoming-payments/${incomingPayment.id}`,
accessToken,
walletAddress
accessToken
},
openApiValidators.successfulValidator
)
Expand All @@ -291,8 +286,7 @@ describe('incoming-payment', (): void => {
{ axiosInstance, logger },
{
url: `${serverAddress}/incoming-payments/${incomingPayment.id}`,
accessToken,
walletAddress
accessToken
},
openApiValidators.successfulValidator
)
Expand All @@ -315,8 +309,7 @@ describe('incoming-payment', (): void => {
{ axiosInstance, logger },
{
url: `${serverAddress}/incoming-payments/${incomingPayment.id}`,
accessToken,
walletAddress
accessToken
},
openApiValidators.failedValidator
)
Expand Down Expand Up @@ -670,7 +663,7 @@ describe('incoming-payment', (): void => {
openApi,
axiosInstance,
logger
}).get({ url, accessToken, walletAddress })
}).get({ url, accessToken })

expect(getSpy).toHaveBeenCalledWith(
{
Expand All @@ -679,11 +672,7 @@ describe('incoming-payment', (): void => {
},
{
url,
accessToken,
walletAddress,
queryParams: {
'wallet-address': walletAddress
}
accessToken
},
true
)
Expand All @@ -695,7 +684,7 @@ describe('incoming-payment', (): void => {
const mockResponseValidator = ({ path, method }) =>
path === '/incoming-payments/{id}' && method === HttpMethod.GET

const url = `${walletAddress}/incoming-payments/1`
const url = `${serverAddress}/incoming-payments/1`

jest
.spyOn(openApi, 'createResponseValidator')
Expand All @@ -712,7 +701,7 @@ describe('incoming-payment', (): void => {
openApi,
axiosInstance,
logger
}).getPublic({ accessToken, url })
}).getPublic({ url })

expect(getSpy).toHaveBeenCalledWith(
{
Expand Down Expand Up @@ -775,6 +764,7 @@ describe('incoming-payment', (): void => {

const url = `${serverAddress}/incoming-payments`
const incomingPaymentCreateArgs = {
walletAddress,
description: 'Invoice',
incomingAmount: { assetCode: 'USD', assetScale: 2, value: '10' }
}
Expand All @@ -793,7 +783,7 @@ describe('incoming-payment', (): void => {
axiosInstance,
logger
}).create(
{ url: serverAddress, walletAddress, accessToken },
{ url: serverAddress, accessToken },
incomingPaymentCreateArgs
)

Expand Down Expand Up @@ -829,7 +819,7 @@ describe('incoming-payment', (): void => {
openApi,
axiosInstance,
logger
}).complete({ url: incomingPaymentUrl, accessToken, walletAddress })
}).complete({ url: incomingPaymentUrl, accessToken })

expect(postSpy).toHaveBeenCalledWith(
{
Expand All @@ -838,10 +828,7 @@ describe('incoming-payment', (): void => {
},
{
url: `${incomingPaymentUrl}/complete`,
accessToken,
body: {
walletAddress
}
accessToken
},
true
)
Expand All @@ -854,7 +841,7 @@ describe('incoming-payment', (): void => {
const mockResponseValidator = ({ path, method }) =>
path === '/incoming-payments/{id}' && method === HttpMethod.GET

const url = `${walletAddress}/incoming-payments/1`
const url = `${serverAddress}/incoming-payments/1`

jest
.spyOn(openApi, 'createResponseValidator')
Expand Down
Loading

0 comments on commit 8b42dfc

Please sign in to comment.