bitopro 1.0.4 → 1.0.5
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/bitopro/api/order.rb +5 -1
- data/lib/bitopro/client.rb +24 -13
- data/lib/bitopro/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85de28eb600e6f367a643fbbd5ec8688c85126ab40b297e80eb02514e622c1e6
|
4
|
+
data.tar.gz: 3b73be1f37bde9b8452cdf853580bba033768178813821792e621b8d940056e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0011d2a8bfff243595b7a20f2aba67bfd21fe0d77e428aaa315b8e63dc01b62893f9f80410c4b20a01c1b91cb77f2d076232ce23ef32da923b55480f36575f1
|
7
|
+
data.tar.gz: f8fc33340d15dfcff2f6572d6d565d355070e6c9006ae8ebf85c05cb921f9fb84a1e69e408de577d97e1b998d756654db5b048136da51596366afee5fdaea97c
|
data/lib/bitopro/api/order.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
module Bitopro
|
2
2
|
module Order
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
3
5
|
# Example:
|
4
6
|
# client = Bitopro::Client.new
|
5
7
|
# client.create_order(pair: "bito_eth", action: "buy", amount: "600", price: "0.000001", type: "limit")
|
6
|
-
def create_order(pair: "", action: "", amount: 0, price: 0, type: "limit")
|
8
|
+
def create_order(pair: "", action: "", amount: "0", price: "0", type: "limit")
|
9
|
+
raise Error, "Amount or Price must be string" if !amount.is_a?(String) || !price.is_a?(String)
|
10
|
+
|
7
11
|
authenticated_post("/orders/#{pair}", { body: { action: action,
|
8
12
|
amount: amount,
|
9
13
|
price: price,
|
data/lib/bitopro/client.rb
CHANGED
@@ -23,7 +23,7 @@ module Bitopro
|
|
23
23
|
"#{BASE_URL}#{url}"
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
AUTH_HTTP_ACTION.each do |action|
|
27
27
|
define_method "authenticated_#{action}" do |url, params = {}|
|
28
28
|
raise SetupError, "Must be set configure before call authenticate action" unless Bitopro.configured?
|
29
29
|
|
@@ -31,24 +31,35 @@ module Bitopro
|
|
31
31
|
payload = build_payload(json_body)
|
32
32
|
headers = build_headers(payload)
|
33
33
|
|
34
|
-
|
34
|
+
begin
|
35
|
+
response = RestClient::Request.execute(method: action,
|
36
|
+
url: complete_url(url),
|
37
|
+
headers: headers,
|
38
|
+
payload: action == "post" ? json_body : params,
|
39
|
+
timeout: 10)
|
40
|
+
response_body = response.body
|
41
|
+
rescue => error
|
42
|
+
response_body = error.response
|
43
|
+
end
|
44
|
+
|
45
|
+
JSON.parse(response_body)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def get(url, params = {})
|
50
|
+
begin
|
51
|
+
response = RestClient::Request.execute(method: :get,
|
35
52
|
url: complete_url(url),
|
36
|
-
headers: headers,
|
37
53
|
payload: params,
|
54
|
+
headers: tracking_header,
|
38
55
|
timeout: 10)
|
39
56
|
|
40
|
-
|
57
|
+
response_body = response.body
|
58
|
+
rescue => error
|
59
|
+
response_body = error.response
|
41
60
|
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def get(url, params = {})
|
45
|
-
response = RestClient::Request.execute(method: :get,
|
46
|
-
url: complete_url(url),
|
47
|
-
payload: params,
|
48
|
-
headers: tracking_header,
|
49
|
-
timeout: 10)
|
50
61
|
|
51
|
-
JSON.parse(
|
62
|
+
JSON.parse(response_body)
|
52
63
|
end
|
53
64
|
|
54
65
|
def build_payload(json_body)
|
data/lib/bitopro/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitopro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- niclin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,7 +141,7 @@ rubyforge_project:
|
|
141
141
|
rubygems_version: 2.7.8
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
|
-
summary: bitopro-1.0.
|
144
|
+
summary: bitopro-1.0.5
|
145
145
|
test_files:
|
146
146
|
- spec/spec_helper.rb
|
147
147
|
- spec/bitopro/config_spec.rb
|