-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCoinMarketCap.m
117 lines (104 loc) · 3.57 KB
/
CoinMarketCap.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//
// CoinMarketCap.m
// Coins
//
// Created by Alexander Ivanov on 18.12.2017.
// Copyright © 2017 Alexander Ivanov. All rights reserved.
//
#import "CoinMarketCap.h"
@implementation CoinMarketCap
__static(NSDictionary *, symbols, (@{ @"BTC" : @"Bitcoin",
@"ETH" : @"Ethereum",
@"LTC" : @"Litecoin",
@"XMR" : @"Monero",
@"USDT" : @"Tether",
@"DASH" : @"Dash",
@"GAS" : @"Gas",
@"XEM" : @"NEM",
@"XRP" : @"Ripple",
@"ZEC" : @"Zcash",
@"REP" : @"Augur",
@"GNO" : @"Gnosis-GNO",
@"OMG" : @"OmiseGO",
@"SC" : @"Siacoin",
@"STRAT" : @"Stratis",
@"ZRX" : @"0x",
@"ARDR" : @"Ardor",
@"STR" : @"Stellar",
@"LSK" : @"Lisk",
@"NAV" : @"NAV-Coin",
@"BCH" : @"Bitcoin-Cash",
@"BTCD" : @"BitcoinDark",
@"BTS" : @"BitShares",
@"DOGE" : @"Dogecoin",
@"GAME" : @"GameCredits",
@"BELA" : @"BelaCoin",
@"XBC" : @"Bitcoin-Plus",
@"BCY" : @"BitCrystals",
@"BTM" : @"Bitmark",
@"BLK" : @"BlackCoin",
@"BURST" : @"Burst",
@"BCN" : @"Bytecoin-BCN",
@"CVC" : @"Civic",
@"CLAM" : @"CLAMS",
@"XCP" : @"Counterparty",
@"DCR" : @"Decred",
@"DGB" : @"DigiByte",
@"EMC2" : @"Einsteinium",
@"ETC" : @"Ethereum-Classic",
@"EXP" : @"Expanse",
@"FCT" : @"Factom",
@"FLO" : @"Florincoin",
@"FLDC" : @"FoldingCoin",
@"GNT" : @"Golem",
@"GRC" : @"Gridcoin",
@"HUC" : @"Huntercoin",
@"LBC" : @"Library-Credit",
@"MAID" : @"MaidSafeCoin",
@"NMC" : @"Namecoin",
@"NEOS" : @"Neoscoin",
@"NXC" : @"Nexium",
@"NXT" : @"NXT",
@"OMNI" : @"Omni",
@"PASC" : @"Pascal-Coin",
@"PPC" : @"Peercoin",
@"PINK" : @"Pinkcoin",
@"POT" : @"PotCoin",
@"XPM" : @"Primecoin",
@"RADS" : @"Radium",
@"RIC" : @"Riecoin",
@"STEEM" : @"STEEM",
@"SBD" : @"Steem-Dollars",
@"STORJ" : @"Storj",
@"AMP" : @"Synereo",
@"SYS" : @"Syscoin",
@"XVC" : @"Vcash",
@"VRC" : @"VeriCoin",
@"VTC" : @"Vertcoin",
@"VIA" : @"Viacoin",
@"USDC" : @"USD-Coin" }))
+ (NSURLSessionDataTask *)ticker:(NSString *)symbol handler:(void(^)(NSArray<NSDictionary *> *))handler {
NSString *url = @"https://api.coinmarketcap.com/v1/ticker/";
if (symbol)
url = [url stringByAppendingString:[self symbols][symbol]];
return [[NSURL URLWithString:url] sendRequestWithMethod:@"GET" header:Nil json:Nil completion:^(id json, NSURLResponse *response) {
if (handler)
handler(json);
}];
}
+ (NSURLSessionDataTask *)tickerWithStart:(NSUInteger)start limit:(NSUInteger)limit handler:(void(^)(NSArray<NSDictionary *> *))handler {
NSURL *url = [NSURL URLWithString:@"https://api.coinmarketcap.com/v1/ticker/"];
url = [url URLByAppendingQueryDictionary:dic__(@"start", start == NSNotFound ? Nil : @(start), @"limit", limit == NSNotFound ? Nil : @(limit))];
return [url sendRequestWithMethod:@"GET" header:Nil json:Nil completion:^(id json, NSURLResponse *response) {
if (handler)
handler(json);
}];
}
+ (NSURLSessionDataTask *)global:(void(^)(NSDictionary *))handler {
NSString *url = @"https://api.coinmarketcap.com/v1/global/";
return [[NSURL URLWithString:url] sendRequestWithMethod:@"GET" header:Nil json:Nil completion:^(id json, NSURLResponse *response) {
if (handler)
handler(json);
}];
}
@end