Skip to content

Commit

Permalink
Fixed payment subresources fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
p-fedyukovich committed Nov 13, 2020
1 parent 482f897 commit a4cbc85
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions lib/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,43 +76,43 @@ export default class SwedbankPayAPI {
}

getPayment(paymentId: string): Promise<RawPaymentResponse> {
return this.get<RawPaymentResponse>(paymentId)
return this.get<RawPaymentResponse>(`${this._baseURL}${paymentId}`)
}

getRawPrices(pricesId: string): Promise<RawPricesResponse> {
return this.get<RawPricesResponse>(pricesId)
getPrices(pricesId: string): Promise<RawPricesResponse> {
return this.get<RawPricesResponse>(`${this._baseURL}${pricesId}`)
}

getRawUrls(urlsId: string): Promise<RawUrlsResponse> {
return this.get<RawUrlsResponse>(urlsId)
getUrls(urlsId: string): Promise<RawUrlsResponse> {
return this.get<RawUrlsResponse>(`${this._baseURL}${urlsId}`)
}

getRawPayeeInfo(payeeInfoId: string): Promise<RawPayeeInfoResponse> {
return this.get<RawPayeeInfoResponse>(payeeInfoId)
getPayeeInfo(payeeInfoId: string): Promise<RawPayeeInfoResponse> {
return this.get<RawPayeeInfoResponse>(`${this._baseURL}${payeeInfoId}`)
}

getMetadata(metadataId: string): Promise<RawMetadataResponse> {
return this.get<RawMetadataResponse>(metadataId)
return this.get<RawMetadataResponse>(`${this._baseURL}${metadataId}`)
}

getTransactions(transactionsId: string): Promise<RawTransactionsResponse> {
return this.get<RawTransactionsResponse>(transactionsId)
return this.get<RawTransactionsResponse>(`${this._baseURL}${transactionsId}`)
}

getAuthorizations(authorizationsId: string): Promise<RawAuthorizationsResponse> {
return this.get<RawAuthorizationsResponse>(authorizationsId)
return this.get<RawAuthorizationsResponse>(`${this._baseURL}${authorizationsId}`)
}

getCaptures(capturesId: string): Promise<RawCapturesResponse> {
return this.get<RawCapturesResponse>(capturesId)
return this.get<RawCapturesResponse>(`${this._baseURL}${capturesId}`)
}

getReversals(reversalsId: string): Promise<RawReversalsResponse> {
return this.get<RawReversalsResponse>(reversalsId)
return this.get<RawReversalsResponse>(`${this._baseURL}${reversalsId}`)
}

getVerifications(verificationsId: string): Promise<RawVerificationsResponse> {
return this.get<RawVerificationsResponse>(verificationsId)
return this.get<RawVerificationsResponse>(`${this._baseURL}${verificationsId}`)
}

getPaidPayment(url: string, method: Method): Promise<RawPaidPaymentResponse> {
Expand Down
8 changes: 4 additions & 4 deletions lib/models/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,23 @@ export default class Payment {
if (!this.pricesURN) {
return null
}
const rawPrices = await this.api.getRawPrices(this.pricesURN)
const rawPrices = await this.api.getPrices(this.pricesURN)
return Prices.generate(rawPrices)
}

async getUrls(): Promise<Urls | null> {
if (!this.urlsURN) {
return null
}
const rawUrls = await this.api.getRawUrls(this.urlsURN)
const rawUrls = await this.api.getUrls(this.urlsURN)
return Urls.generate(rawUrls)
}

async getPayeeInfo(): Promise<PayeeInfo | null> {
if (!this.payeeInfoURN) {
return null
}
const rawPayeeInfo = await this.api.getRawPayeeInfo(this.payeeInfoURN)
const rawPayeeInfo = await this.api.getPayeeInfo(this.payeeInfoURN)
return PayeeInfo.generate(rawPayeeInfo)
}

Expand Down Expand Up @@ -351,6 +351,6 @@ export default class Payment {
}

getOperation(name: string): Operation | null {
return this._operations.find((op: Operation) => op.rel) || null
return this._operations.find((op: Operation) => op.rel === name) || null
}
}

0 comments on commit a4cbc85

Please sign in to comment.