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

Commit

Permalink
Cryptocurrency: Swap out external endpoint for proxy endpoint. (#3350)
Browse files Browse the repository at this point in the history
* Swap out external endpoint for proxy endpoint.

* Fix alto

* Update the api call.
  • Loading branch information
pjhampton authored and moollaza committed Jun 30, 2017
1 parent 722fb30 commit 48dccca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions lib/DDG/Spice/Cryptocurrency.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ spice wrap_jsonp_callback => 1;
spice is_cached => 0;
spice proxy_cache_valid => "200 1m";

spice alt_to => {
cryptonator => {
from => '([^/]+)/([^/]*)',
to => 'https://api.cryptonator.com/api/full/$1-$2',
wrap_jsonp_callback => 0,
}
};

# This function converts things like "us dollars" to the standard "usd".
sub getCode {
my $input = shift;
Expand Down
10 changes: 6 additions & 4 deletions share/spice/cryptocurrency/cryptocurrency.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@
Converter.fromCurrency = from;
}

var endpoint = "https://api.cryptonator.com/api/full/" + from + "-" + to;
$.get(endpoint, function(payload) {
Converter.rate = parseFloat(payload.ticker.price);
var endpoint = "/js/spice/cryptonator/" + from + "/" + to;

$.getJSON(endpoint, function(payload) {
var response = payload;
Converter.rate = parseFloat(response.ticker.price);
Converter.calculateRate();
Converter.updateMoreAtLink(to, from);
Converter.updateChangeRate(payload.ticker.change);
Converter.updateChangeRate(response.ticker.change);
});
},

Expand Down

0 comments on commit 48dccca

Please sign in to comment.