Skip to content

Commit

Permalink
feat: transak api get crypto and fiat currencies (#2709)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeeanribeiro authored Jul 5, 2024
1 parent f587654 commit 3fa8484
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/shared/src/lib/auxiliary/transak/apis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './transak.api'
20 changes: 20 additions & 0 deletions packages/shared/src/lib/auxiliary/transak/apis/transak.api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { BaseApi } from '@core/utils'
import { TRANSAK_API_BASE_URL } from '../constants'
import { ITransakApiCryptoCurrenciesResponse, ITransakApiFiatCurrenciesResponse } from '../interfaces'
import { TransakApiEndpoint } from '../enums'

export class TransakApi extends BaseApi {
constructor() {
super(TRANSAK_API_BASE_URL)
}

async getFiatCurrencies(): Promise<ITransakApiFiatCurrenciesResponse | undefined> {
const response = await this.get<ITransakApiFiatCurrenciesResponse>(TransakApiEndpoint.FiatCurrencies)
return response
}

async getCryptoCurrencies(): Promise<ITransakApiCryptoCurrenciesResponse | undefined> {
const response = await this.get<ITransakApiCryptoCurrenciesResponse>(TransakApiEndpoint.CryptoCurrencies)
return response
}
}
3 changes: 3 additions & 0 deletions packages/shared/src/lib/auxiliary/transak/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export * from './transak-api-base-url.constant'
export * from './transak-api-production-base-url.constant'
export * from './transak-api-staging-base-url.constant'
export * from './transak-production-widget-url.constant'
export * from './transak-staging-widget-url.constant'
export * from './transak-widget-url.constant'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { AppStage } from '@core/app/enums/app-stage.enum'
import { TRANSAK_API_PRODUCTION_BASE_URL } from './transak-api-production-base-url.constant'
import { TRANSAK_API_STAGING_BASE_URL } from './transak-api-staging-base-url.constant'

export const TRANSAK_API_BASE_URL =
process.env.STAGE === AppStage.PROD ? TRANSAK_API_PRODUCTION_BASE_URL : TRANSAK_API_STAGING_BASE_URL
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TRANSAK_API_PRODUCTION_BASE_URL = 'https://api.transak.com/api/v2'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const TRANSAK_API_STAGING_BASE_URL = 'https://api-stg.transak.com/api/v2'
1 change: 1 addition & 0 deletions packages/shared/src/lib/auxiliary/transak/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './transak-api-endpoint.enum'
export * from './transak-connection-status.enum'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum TransakApiEndpoint {
CryptoCurrencies = 'currencies/crypto-currencies',
FiatCurrencies = 'currencies/fiat-currencies',
}
2 changes: 2 additions & 0 deletions packages/shared/src/lib/auxiliary/transak/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './transak-api-crypto-currencies-response.interface'
export * from './transak-api-fiat-currencies-response.interface'
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export interface ITransakApiCryptoCurrenciesResponse {
response: ITransakApiCryptoCurrenciesResponseItem[]
}

export interface ITransakApiCryptoCurrenciesResponseItem {
_id: string
coinId: string
address?: string
addressAdditionalData?: boolean | { name: string; displayName: string }
createdAt: string
decimals: number
image: ITransakCryptoCurrencyImage
isAllowed: boolean
isPopular: boolean
isStable: boolean
name: string
roundOff: number
symbol: string
isIgnorePriceVerification: boolean
image_bk?: ITransakCryptoCurrencyImage
kycCountriesNotSupported: string[]
network: { name: string; fiatCurrenciesNotSupported: string[]; chainId?: string }
uniqueId: string
tokenType: string
isPayInAllowed: boolean
isSuspended: boolean
tokenIdentifier?: string
}

interface ITransakCryptoCurrencyImage {
large: string
small: string
thumb: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { FiatCurrency } from '@core/market'

export interface ITransakApiFiatCurrenciesResponse {
response: ITransakApiFiatCurrenciesResponseItem[]
}

export interface ITransakApiFiatCurrenciesResponseItem {
symbol: keyof typeof FiatCurrency
supportingCountries: string[]
logoSymbol: string
name: string
paymentOptions: ITransakApiPaymentOption[]
isPopular: boolean
isAllowed: boolean
roundOff: number
isPayOutAllowed: boolean
defaultCountryForNFT?: string
icon: string
displayMessage?: string
}

export interface ITransakApiPaymentOption {
name: string
id: string
isNftAllowed?: boolean
isNonCustodial?: boolean
processingTime: string
displayText: boolean
icon: string
limitCurrency: string
isActive: boolean
provider?: string
maxAmount: number
minAmount: number
defaultAmount: number
isConverted: boolean
visaPayoutCountries?: string[]
mastercardPayoutCountries?: string[]
isPayOutAllowed?: boolean
minAmountForPayOut?: number
maxAmountForPayOut?: number
defaultAmountForPayOut?: number
isBillingAddressRequired?: boolean
supportedCountryCode?: string[]
displayMessage?: string
}

0 comments on commit 3fa8484

Please sign in to comment.