Open Exchange Rates Grails Plugin
Groovy Shell
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gradle/3.0/taskArtifacts
gradle/wrapper
grails-app
src/main/groovy/grails/plugin/openexchangerates
.gitignore
.travis.yml
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle
travis-publish.sh

README.md

Open Exchange Rates Grails Plugin

Build Status Download

Introduction

The Open Exchange Rates Plugin allows you to integrate Open Exchange Rates in your Grails application.

Installation

Declare the plugin dependency in the build.gradle file, as shown here:

repositories {
    ...
    maven { url "http://dl.bintray.com/agorapulse/grails-open-exchange-rates" }
}
dependencies {
    ...
    compile "org.grails.plugins:grails-open-exchange-rates:1.0"
}

Config

Create an account on Open Exchange Rates, in order to get your own app ID.

Add your app parameters to your grails-app/conf/application.yml:

grails:
    plugin:
        openexchangerates:
            appId: {APP_ID} # Write ID

Usage

You can inject openExchangeRatesService in any of your Grails artefacts (controllers, services...) in order to call Open Exchange Rates APIs.

// Get latest rates
def result = openExchangeRatesService.latest()
println new Date(result.timestamp)
println result.rates['EUR']

// By default (free account), it will use USD as base currency but you can use other currency
result = openExchangeRatesService.latest(base: 'EUR')

// Get full currency names
def currencies = openExchangeRatesService.currencies()

Latest rates are returned with the following format

{
    "disclaimer": "Exchange rates provided by [...]",
    "license": "Data collected and blended [...]",
    "timestamp": 1319730758,
    "base": "USD",
    "rates": {
        "AED": 3.672626,
        "AFN": 48.3775,
        "ALL": 110.223333,
        "AMD": 409.604993,
        /* 160 fx rates available - see currencies.json */
        "YER": 215.035559,
        "ZAR": 8.416205,
        "ZMK": 4954.411262,
        "ZWL": 322.355011
    }
}

Check Open Exchange Rates documentation for more info.

Latest releases

  • 2014-04-16 V0.1 : Initial release

Bugs

To report any bug, please use the project Issues section on GitHub.