Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
Add Currency extension functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed May 3, 2022
1 parent dd322bc commit 8c1398d
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.cyb3rko.m3okotlin.services

import com.cyb3rko.m3okotlin.M3O
import com.cyb3rko.m3okotlin.data.*
import com.cyb3rko.m3okotlin.data.CurrencyCodesResponse.CurrencyCode
import io.ktor.client.request.*

private const val SERVICE = "currency"
Expand Down Expand Up @@ -58,4 +59,10 @@ object CurrencyService {
body = CurrencyRatesRequest(code)
}
}

suspend fun CurrencyCode.convert(amount: Float, to: String) = convert(amount, this.name, to)

suspend fun CurrencyCode.history(date: String) = history(this.name, date)

suspend fun CurrencyCode.rates() = rates(this.name)
}

0 comments on commit 8c1398d

Please sign in to comment.