btce 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/btce/api/public_api.rb +36 -19
- metadata +3 -2
data/lib/btce/api/public_api.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
# Copyright © 2013-2014, Christopher Mark Gore,
|
2
4
|
# Soli Deo Gloria,
|
3
5
|
# All rights reserved.
|
4
6
|
#
|
@@ -9,16 +11,16 @@
|
|
9
11
|
# Redistribution and use in source and binary forms, with or without
|
10
12
|
# modification, are permitted provided that the following conditions are met:
|
11
13
|
#
|
12
|
-
#
|
13
|
-
#
|
14
|
+
# * Redistributions of source code must retain the above copyright
|
15
|
+
# notice, this list of conditions and the following disclaimer.
|
14
16
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright
|
18
|
+
# notice, this list of conditions and the following disclaimer in the
|
19
|
+
# documentation and/or other materials provided with the distribution.
|
18
20
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
21
|
+
# * Neither the name of Christopher Mark Gore nor the names of other
|
22
|
+
# contributors may be used to endorse or promote products derived from
|
23
|
+
# this software without specific prior written permission.
|
22
24
|
#
|
23
25
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
24
26
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
@@ -37,28 +39,43 @@ module Btce
|
|
37
39
|
OPERATIONS = %w(fee ticker trades depth)
|
38
40
|
|
39
41
|
class << self
|
40
|
-
def get_pair_operation_json(pair, operation)
|
41
|
-
|
42
|
-
|
42
|
+
def get_pair_operation_json(pair, operation, options={})
|
43
|
+
list = pair.split('-')
|
44
|
+
i = 0
|
43
45
|
begin
|
44
46
|
raise ArgumentError if not API::CURRENCY_PAIRS.include? list[i]
|
45
|
-
|
46
|
-
|
47
|
+
i = i + 1
|
48
|
+
end while i < list.length
|
47
49
|
raise ArgumentError if not OPERATIONS.include? operation
|
48
|
-
|
50
|
+
|
51
|
+
params = ""
|
52
|
+
if options[:limit]
|
53
|
+
if options[:limit].is_a? Integer
|
54
|
+
if options[:limit] < 1
|
55
|
+
raise ArgumentError, "Limit #{options[:limit]} < 1."
|
56
|
+
else
|
57
|
+
params = "?limit=#{options[:limit]}"
|
58
|
+
end
|
59
|
+
else
|
60
|
+
raise ArgumentError,
|
61
|
+
"Non-Integer limit #{options[:limit].inspect}."
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
get_json url: "https://#{API::BTCE_DOMAIN}/api/3/#{operation}/#{pair}#{params}"
|
49
66
|
end
|
50
67
|
|
51
68
|
OPERATIONS.each do |operation|
|
52
69
|
class_eval %{
|
53
|
-
def get_pair_#{operation}_json(pair)
|
54
|
-
get_pair_operation_json pair, "#{operation}"
|
70
|
+
def get_pair_#{operation}_json(pair, options={})
|
71
|
+
get_pair_operation_json pair, "#{operation}", options
|
55
72
|
end
|
56
73
|
}
|
57
74
|
|
58
75
|
API::CURRENCY_PAIRS.each do |pair|
|
59
76
|
class_eval %{
|
60
|
-
def get_#{pair}_#{operation}_json
|
61
|
-
get_pair_#{operation}_json "#{pair}"
|
77
|
+
def get_#{pair}_#{operation}_json(options={})
|
78
|
+
get_pair_#{operation}_json "#{pair}", options
|
62
79
|
end
|
63
80
|
}
|
64
81
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: btce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,11 +13,12 @@ authors:
|
|
13
13
|
- Sami Laine
|
14
14
|
- Selvam Palanimalai
|
15
15
|
- Jaime Quint
|
16
|
+
- Panupan Sriautharawong
|
16
17
|
- Michaël Witrant
|
17
18
|
autorequire:
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
|
-
date: 2014-
|
21
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: monkey-patch
|