bitex 0.1.9 → 0.1.10
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.
- data/lib/bitex/usd_deposit.rb +9 -2
- data/lib/bitex/version.rb +1 -1
- data/spec/fixtures/cancelled_usd_deposit.json +1 -0
- data/spec/usd_deposit_spec.rb +11 -0
- metadata +4 -2
data/lib/bitex/usd_deposit.rb
CHANGED
@@ -40,6 +40,7 @@ module Bitex
|
|
40
40
|
# * :sender_unknown we could not accept these funds because you're not the
|
41
41
|
# sender.
|
42
42
|
# * :other we'll contact you regarding this deposit.
|
43
|
+
# * :user_cancelled We cancelled this deposit per your request.
|
43
44
|
attr_accessor :reason
|
44
45
|
|
45
46
|
# @!attribute country
|
@@ -68,7 +69,7 @@ module Bitex
|
|
68
69
|
attr_accessor :third_party_reference
|
69
70
|
|
70
71
|
# @visibility private
|
71
|
-
def self.from_json(json)
|
72
|
+
def self.from_json(json, deposit = nil)
|
72
73
|
deposit_method_lookup = {
|
73
74
|
1 => :astropay,
|
74
75
|
2 => :other,
|
@@ -83,8 +84,9 @@ module Bitex
|
|
83
84
|
1 => :did_not_credit,
|
84
85
|
2 => :sender_unknown,
|
85
86
|
3 => :other,
|
87
|
+
4 => :user_cancelled,
|
86
88
|
}
|
87
|
-
Api.from_json(new, json) do |thing|
|
89
|
+
Api.from_json(deposit || new, json) do |thing|
|
88
90
|
thing.requested_amount = BigDecimal.new(json[3].to_s)
|
89
91
|
thing.amount = BigDecimal.new(json[4].to_s)
|
90
92
|
thing.deposit_method = deposit_method_lookup[json[5]]
|
@@ -114,6 +116,11 @@ module Bitex
|
|
114
116
|
from_json(Api.private(:get, "/private/usd/deposits/#{id}"))
|
115
117
|
end
|
116
118
|
|
119
|
+
def cancel!
|
120
|
+
path = "/private/usd/deposits/#{self.id}/cancel"
|
121
|
+
self.class.from_json(Api.private(:post, path), self)
|
122
|
+
end
|
123
|
+
|
117
124
|
def self.all
|
118
125
|
Api.private(:get, "/private/usd/deposits").collect{|x| from_json(x) }
|
119
126
|
end
|
data/lib/bitex/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
[7,12345678,946685400,110.00000000,100.00000000,1,3,4,"UY","UYU",1,"bank of new york mellon",{"status":"OK","link":"https://astr.com"},"ABABABABA"]
|
data/spec/usd_deposit_spec.rb
CHANGED
@@ -74,6 +74,7 @@ describe Bitex::UsdDeposit do
|
|
74
74
|
1 => :did_not_credit,
|
75
75
|
2 => :sender_unknown,
|
76
76
|
3 => :other,
|
77
|
+
4 => :user_cancelled,
|
77
78
|
}.each do |code, symbol|
|
78
79
|
it "sets reason #{code} to #{symbol}" do
|
79
80
|
as_json[7] = code
|
@@ -103,6 +104,16 @@ describe Bitex::UsdDeposit do
|
|
103
104
|
deposit.status.should == :pending
|
104
105
|
end
|
105
106
|
|
107
|
+
it 'cancels a deposit' do
|
108
|
+
stub_private(:get, '/private/usd/deposits/12345678', 'usd_deposit')
|
109
|
+
stub_private(:post, '/private/usd/deposits/12345678/cancel', 'cancelled_usd_deposit')
|
110
|
+
deposit = Bitex::UsdDeposit.find(12345678)
|
111
|
+
deposit.cancel!
|
112
|
+
deposit.should be_a Bitex::UsdDeposit
|
113
|
+
deposit.status.should == :cancelled
|
114
|
+
deposit.reason.should == :user_cancelled
|
115
|
+
end
|
116
|
+
|
106
117
|
it 'lists all usd deposits' do
|
107
118
|
stub_private(:get, '/private/usd/deposits', 'usd_deposits')
|
108
119
|
deposits = Bitex::UsdDeposit.all
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bitex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -201,6 +201,7 @@ files:
|
|
201
201
|
- spec/fixtures/bids_cancel.json
|
202
202
|
- spec/fixtures/bids_create.json
|
203
203
|
- spec/fixtures/bids_show.json
|
204
|
+
- spec/fixtures/cancelled_usd_deposit.json
|
204
205
|
- spec/fixtures/file.jpg
|
205
206
|
- spec/fixtures/kyc_file.json
|
206
207
|
- spec/fixtures/kyc_files.json
|
@@ -275,6 +276,7 @@ test_files:
|
|
275
276
|
- spec/fixtures/bids_cancel.json
|
276
277
|
- spec/fixtures/bids_create.json
|
277
278
|
- spec/fixtures/bids_show.json
|
279
|
+
- spec/fixtures/cancelled_usd_deposit.json
|
278
280
|
- spec/fixtures/file.jpg
|
279
281
|
- spec/fixtures/kyc_file.json
|
280
282
|
- spec/fixtures/kyc_files.json
|