This project is read-only.

Gem Exchange

Introduction

The gem exchange service is not like the other services in the /v2 namespace. It does not retrieve large sets of data from a storage back-end. Instead, it converts a given number of coins-to-gems or gem-to-coins.

Terminology
  • Broker: a broker arranges transactions between a buyer and a seller for a commission when the deal is executed.
  • Quotation: a quotation is a statement of the current market price of a security or commodity.
The exchange service represents a broker. The broker can provide quotations that describe the real-time conversion rate between gems and gold.

The broker has the following service contracts:
  • Get a quotation for the given quantity of a commodity
  • (not implemented) Discover the identifiers of commodities
These service contracts are reflected in the code by the following interface:
  • IExchangeBroker
    • extends IBroker<GemQuotation>
  • IBroker<TQuotation>
    • GetQuotation(quantity)

Quickstart

Gold to Gems

TQuotation : GemQuotation

Step 1
Create an instance of the IBroker.

IBroker<GemQuotation> service;
service = GW2.V2.Commerce.Exchange.ForCurrency("coins");

Step 2
Get a quotation for 100 gold.
Underlying service: https://api.guildwars2.com/v2/commerce/exchange/coins?quantity=1000000

GemQuotation quotation = service.GetQuotation(1000000);

Step 4
Print the quotation.

string message = "Coins per gem: " + quotation.CoinsPerGem + "\n";
message += "To send (coins): " + quotation.Send;
message += "To receive (gems): " + quotation.Receive;
message += "Timestamp: " + quotation.Timestamp;

> Coins per gem: 1366
> To send (coins): 1000000
> To receive (gems): 731
> Timestamp: 9/27/2014 6:11:41 PM +00:00

Completed example
var service = GW2.V2.Commerce.Exchange.ForCurrency("coins");
GemQuotation quotation = service.GetQuotation(1000000);
string message = "Coins per gem: " + quotation.CoinsPerGem + "\n";
message += "To send (coins): " + quotation.Send;
message += "To receive (gems): " + quotation.Receive;
message += "Timestamp: " + quotation.Timestamp;

Gems to Gold

TQuotation : GemQuotation

Step 1
Create an instance of the IBroker.

IBroker<GemQuotation> service;
service = GW2.V2.Commerce.Exchange.ForCurrency("gems");

Step 2
Get a quotation for 100 gems.
Underlying service: https://api.guildwars2.com/v2/commerce/exchange/gems?quantity=100

GemQuotation quotation = service.GetQuotation(100);

Step 4
Print the quotation.

string message = "Coins per gem: " + quotation.CoinsPerGem + "\n";
message += "To send (gems): " + quotation.Send + "\n";
message += "To receive (coins): " + quotation.Receive + "\n";
message += "Timestamp: " + quotation.Timestamp;

> Coins per gem: 985
> To send (gems): 100
> To receive (coins): 98502
> Timestamp: 9/27/2014 6:11:41 PM +00:00

Completed example
var service = GW2.V2.Commerce.Exchange.ForCurrency("gems");
GemQuotation quotation = service.GetQuotation(100);
string message = "Coins per gem: " + quotation.CoinsPerGem + "\n";
message += "To send (gems): " + quotation.Send + "\n";
message += "To receive (coins): " + quotation.Receive + "\n";
message += "Timestamp: " + quotation.Timestamp;
Console.WriteLine(message);

Last edited Feb 7, 2015 at 10:45 AM by StevenLiekens, version 8