coins_ph_ruby 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/coins_ph_ruby/version.rb +1 -1
- data/lib/coins_ph_ruby.rb +21 -38
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49be320ecca66bdd9181211adf884e804d81e0b9
|
4
|
+
data.tar.gz: 80fa7e3a7e6aa88b6ce10f2ea615cb77ce0df449
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e23eee938321d04e5e235c473e321a924e48a2248c6e6a43ed110d666f1e72634e22e67ffdf833e0d60c9b2372022c738a83a931730e0ca466a4d0ee1348ecf
|
7
|
+
data.tar.gz: 5a41d6f0f58decf0b646ef6f1ed7c9e3e878dabc8a9773769f2ff591f4ea18fc134d8aa5f47ae09e012de7f45e1a9fe12516669a0f403a37817896d3b0b46137
|
data/lib/coins_ph_ruby.rb
CHANGED
@@ -10,38 +10,26 @@ module CoinsPhRuby
|
|
10
10
|
@base_url = 'https://coins.ph/api/v3'
|
11
11
|
end
|
12
12
|
|
13
|
-
def get_crypto_accounts(
|
13
|
+
def get_crypto_accounts(_currency = nil)
|
14
14
|
nonce = Hmac.get_nonce
|
15
15
|
url = @base_url + '/crypto-accounts/'
|
16
|
-
signature = Hmac.sign_request(@api_secret, url,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
ACCESS_KEY: @api_key,
|
23
|
-
ACCESS_NONCE: nonce)
|
24
|
-
rescue StandardError => e
|
25
|
-
puts e.response
|
26
|
-
end
|
27
|
-
response
|
16
|
+
signature = Hmac.sign_request(@api_secret, url, nonce)
|
17
|
+
RestClient.get(url, content_type: :json,
|
18
|
+
accept: :json,
|
19
|
+
ACCESS_SIGNATURE: signature,
|
20
|
+
ACCESS_KEY: @api_key,
|
21
|
+
ACCESS_NONCE: nonce)
|
28
22
|
end
|
29
23
|
|
30
24
|
def get_transfers(_id = nil)
|
31
25
|
nonce = Hmac.get_nonce
|
32
26
|
url = @base_url + '/transfers/'
|
33
|
-
signature = Hmac.sign_request(@api_secret, url,
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
ACCESS_KEY: @api_key,
|
40
|
-
ACCESS_NONCE: nonce)
|
41
|
-
rescue StandardError => e
|
42
|
-
puts e.response
|
43
|
-
end
|
44
|
-
response
|
27
|
+
signature = Hmac.sign_request(@api_secret, url, nonce)
|
28
|
+
RestClient.get(url, content_type: :json,
|
29
|
+
accept: :json,
|
30
|
+
ACCESS_SIGNATURE: signature,
|
31
|
+
ACCESS_KEY: @api_key,
|
32
|
+
ACCESS_NONCE: nonce)
|
45
33
|
end
|
46
34
|
|
47
35
|
def transfer(amount, account, target_address, message = nil)
|
@@ -50,25 +38,20 @@ module CoinsPhRuby
|
|
50
38
|
url = @base_url + '/transfers/'
|
51
39
|
signature = Hmac.sign_request(@api_secret, url,
|
52
40
|
nonce, body)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
ACCESS_NONCE: nonce)
|
59
|
-
rescue StandardError => e
|
60
|
-
puts e.response
|
61
|
-
end
|
62
|
-
response
|
41
|
+
RestClient.post(url, body, content_type: :json,
|
42
|
+
accept: :json,
|
43
|
+
ACCESS_SIGNATURE: signature,
|
44
|
+
ACCESS_KEY: @api_key,
|
45
|
+
ACCESS_NONCE: nonce)
|
63
46
|
end
|
64
47
|
|
65
48
|
private
|
66
49
|
|
67
50
|
def build_transfer_body(account, amount, message, target_address)
|
68
51
|
body = {
|
69
|
-
|
70
|
-
|
71
|
-
|
52
|
+
target_address: target_address,
|
53
|
+
account: account,
|
54
|
+
amount: amount
|
72
55
|
}
|
73
56
|
body[:message] = message unless message.nil?
|
74
57
|
body.to_json.gsub(/\s+/, '')
|