Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Open Exchange Rates Grails Plugin
Shell Groovy
branch: master

README.md

Open Exchange Rates Grails Plugin

Introduction

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

Installation

Declare the plugin dependency in the BuildConfig.groovvy file, as shown here:

grails.project.dependency.resolution = {
        inherits("global") { }
        log "info"
        repositories {
                //your repositories
        }
        dependencies {
                //your regular dependencies
        }
        plugins {
                //here go your plugin dependencies
                runtime ':open-exchange-rates:0.1'
        }
}

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/Config.groovy:

grails.plugin.openexchangerates.appId = {APP_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.

Something went wrong with that request. Please try again.