|
| 1 | +package com.alphawallet.app.repository; |
| 2 | + |
| 3 | +import android.net.Uri; |
| 4 | +import android.text.TextUtils; |
| 5 | + |
| 6 | +import com.alphawallet.app.entity.coinbasepay.DestinationWallet; |
| 7 | +import com.alphawallet.app.util.CoinbasePayUtils; |
| 8 | + |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +public class CoinbasePayRepository implements CoinbasePayRepositoryType |
| 12 | +{ |
| 13 | + private static final String SCHEME = "https"; |
| 14 | + private static final String AUTHORITY = "pay.coinbase.com"; |
| 15 | + private static final String BUY_PATH = "buy"; |
| 16 | + private static final String SELECT_ASSET_PATH = "select-asset"; |
| 17 | + private final KeyProvider keyProvider = KeyProviderFactory.get(); |
| 18 | + |
| 19 | + @Override |
| 20 | + public String getUri(DestinationWallet.Type type, String address, List<String> list) |
| 21 | + { |
| 22 | + String appId = keyProvider.getCoinbasePayAppId(); |
| 23 | + if (TextUtils.isEmpty(appId)) |
| 24 | + { |
| 25 | + return ""; |
| 26 | + } |
| 27 | + else |
| 28 | + { |
| 29 | + Uri.Builder builder = new Uri.Builder(); |
| 30 | + builder.scheme(SCHEME) |
| 31 | + .authority(AUTHORITY) |
| 32 | + .appendPath(BUY_PATH) |
| 33 | + .appendPath(SELECT_ASSET_PATH) |
| 34 | + .appendQueryParameter(RequestParams.APP_ID, keyProvider.getCoinbasePayAppId()) |
| 35 | + .appendQueryParameter(RequestParams.DESTINATION_WALLETS, CoinbasePayUtils.getDestWalletJson(type, address, list)); |
| 36 | + |
| 37 | + return builder.build().toString(); |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + public static class Blockchains |
| 42 | + { |
| 43 | + public static final String ETHEREUM = "ethereum"; |
| 44 | + public static final String SOLANA = "solana"; |
| 45 | + public static final String AVALANCHE_C_CHAIN = "avalanche-c-chain"; |
| 46 | + } |
| 47 | + |
| 48 | + private static class RequestParams |
| 49 | + { |
| 50 | + public static final String APP_ID = "appId"; |
| 51 | + public static final String ADDRESS = "address"; |
| 52 | + public static final String DESTINATION_WALLETS = "destinationWallets"; |
| 53 | + public static final String ASSETS = "assets"; |
| 54 | + public static final String BLOCKCHAINS = "blockchains"; |
| 55 | + } |
| 56 | +} |
0 commit comments