straight 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +5 -1
- data/README.md +20 -10
- data/VERSION +1 -1
- data/lib/straight.rb +10 -1
- data/lib/straight/blockchain_adapter.rb +2 -13
- data/lib/straight/blockchain_adapters/biteasy_adapter.rb +74 -0
- data/lib/straight/blockchain_adapters/blockchain_info_adapter.rb +37 -17
- data/lib/straight/blockchain_adapters/mycelium_adapter.rb +144 -0
- data/lib/straight/exchange_rate_adapter.rb +20 -1
- data/lib/straight/exchange_rate_adapters/average_rate_adapter.rb +54 -0
- data/lib/straight/exchange_rate_adapters/bitpay_adapter.rb +5 -2
- data/lib/straight/exchange_rate_adapters/bitstamp_adapter.rb +2 -1
- data/lib/straight/exchange_rate_adapters/btce_adapter.rb +18 -0
- data/lib/straight/exchange_rate_adapters/coinbase_adapter.rb +2 -4
- data/lib/straight/exchange_rate_adapters/kraken_adapter.rb +18 -0
- data/lib/straight/exchange_rate_adapters/localbitcoins_adapter.rb +17 -0
- data/lib/straight/exchange_rate_adapters/okcoin_adapter.rb +18 -0
- data/lib/straight/gateway.rb +20 -9
- data/lib/straight/order.rb +46 -13
- data/spec/lib/blockchain_adapters/{helloblock_io_spec.rb → biteasy_adapter_spec.rb} +23 -18
- data/spec/lib/blockchain_adapters/{blockchain_info_spec.rb → blockchain_info_adapter_spec.rb} +8 -3
- data/spec/lib/blockchain_adapters/mycelium_adapter_spec.rb +54 -0
- data/spec/lib/exchange_rate_adapter_spec.rb +6 -1
- data/spec/lib/exchange_rate_adapters/average_rate_adapter_spec.rb +43 -0
- data/spec/lib/exchange_rate_adapters/bitpay_adapter_spec.rb +14 -1
- data/spec/lib/exchange_rate_adapters/bitstamp_adapter_spec.rb +14 -1
- data/spec/lib/exchange_rate_adapters/btce_adapter_spec.rb +27 -0
- data/spec/lib/exchange_rate_adapters/coinbase_adapter_spec.rb +14 -1
- data/spec/lib/exchange_rate_adapters/kraken_adapter_spec.rb +27 -0
- data/spec/lib/exchange_rate_adapters/localbitcoins_adapter_spec.rb +27 -0
- data/spec/lib/exchange_rate_adapters/okcoin_adapter_spec.rb +27 -0
- data/spec/lib/gateway_spec.rb +23 -5
- data/spec/lib/order_spec.rb +18 -2
- data/straight.gemspec +95 -0
- metadata +33 -6
- data/lib/straight/blockchain_adapters/helloblock_io_adapter.rb +0 -53
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: straight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Snitko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money-tree
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,23 +114,36 @@ files:
|
|
100
114
|
- VERSION
|
101
115
|
- lib/straight.rb
|
102
116
|
- lib/straight/blockchain_adapter.rb
|
117
|
+
- lib/straight/blockchain_adapters/biteasy_adapter.rb
|
103
118
|
- lib/straight/blockchain_adapters/blockchain_info_adapter.rb
|
104
|
-
- lib/straight/blockchain_adapters/
|
119
|
+
- lib/straight/blockchain_adapters/mycelium_adapter.rb
|
105
120
|
- lib/straight/exchange_rate_adapter.rb
|
121
|
+
- lib/straight/exchange_rate_adapters/average_rate_adapter.rb
|
106
122
|
- lib/straight/exchange_rate_adapters/bitpay_adapter.rb
|
107
123
|
- lib/straight/exchange_rate_adapters/bitstamp_adapter.rb
|
124
|
+
- lib/straight/exchange_rate_adapters/btce_adapter.rb
|
108
125
|
- lib/straight/exchange_rate_adapters/coinbase_adapter.rb
|
126
|
+
- lib/straight/exchange_rate_adapters/kraken_adapter.rb
|
127
|
+
- lib/straight/exchange_rate_adapters/localbitcoins_adapter.rb
|
128
|
+
- lib/straight/exchange_rate_adapters/okcoin_adapter.rb
|
109
129
|
- lib/straight/gateway.rb
|
110
130
|
- lib/straight/order.rb
|
111
|
-
- spec/lib/blockchain_adapters/
|
112
|
-
- spec/lib/blockchain_adapters/
|
131
|
+
- spec/lib/blockchain_adapters/biteasy_adapter_spec.rb
|
132
|
+
- spec/lib/blockchain_adapters/blockchain_info_adapter_spec.rb
|
133
|
+
- spec/lib/blockchain_adapters/mycelium_adapter_spec.rb
|
113
134
|
- spec/lib/exchange_rate_adapter_spec.rb
|
135
|
+
- spec/lib/exchange_rate_adapters/average_rate_adapter_spec.rb
|
114
136
|
- spec/lib/exchange_rate_adapters/bitpay_adapter_spec.rb
|
115
137
|
- spec/lib/exchange_rate_adapters/bitstamp_adapter_spec.rb
|
138
|
+
- spec/lib/exchange_rate_adapters/btce_adapter_spec.rb
|
116
139
|
- spec/lib/exchange_rate_adapters/coinbase_adapter_spec.rb
|
140
|
+
- spec/lib/exchange_rate_adapters/kraken_adapter_spec.rb
|
141
|
+
- spec/lib/exchange_rate_adapters/localbitcoins_adapter_spec.rb
|
142
|
+
- spec/lib/exchange_rate_adapters/okcoin_adapter_spec.rb
|
117
143
|
- spec/lib/gateway_spec.rb
|
118
144
|
- spec/lib/order_spec.rb
|
119
145
|
- spec/spec_helper.rb
|
146
|
+
- straight.gemspec
|
120
147
|
homepage: http://github.com/snitko/straight
|
121
148
|
licenses:
|
122
149
|
- MIT
|
@@ -137,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
164
|
version: '0'
|
138
165
|
requirements: []
|
139
166
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.4.5
|
141
168
|
signing_key:
|
142
169
|
specification_version: 4
|
143
170
|
summary: An engine for the Straight payment gateway software
|
@@ -1,53 +0,0 @@
|
|
1
|
-
module Straight
|
2
|
-
module Blockchain
|
3
|
-
|
4
|
-
class HelloblockIoAdapter < Adapter
|
5
|
-
|
6
|
-
def self.mainnet_adapter
|
7
|
-
self.new("https://mainnet.helloblock.io/v1")
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.testnet_adapter
|
11
|
-
raise "Not Supported Yet"
|
12
|
-
end
|
13
|
-
|
14
|
-
def initialize(base_url)
|
15
|
-
@base_url = base_url
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns transaction info for the tid
|
19
|
-
def fetch_transaction(tid, address: nil)
|
20
|
-
straighten_transaction JSON.parse(http_request("#{@base_url}/transactions/#{tid}"))['data']['transaction'], address: address
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns all transactions for the address
|
24
|
-
def fetch_transactions_for(address)
|
25
|
-
transactions = JSON.parse(http_request("#{@base_url}/addresses/#{address}/transactions"))['data']['transactions']
|
26
|
-
transactions.map { |t| straighten_transaction(t, address: address) }
|
27
|
-
end
|
28
|
-
|
29
|
-
# Returns the current balance of the address
|
30
|
-
def fetch_balance_for(address)
|
31
|
-
JSON.parse(http_request("#{@base_url}/addresses/#{address}"))['data']['address']['balance']
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
# Converts transaction info received from the source into the
|
37
|
-
# unified format expected by users of BlockchainAdapter instances.
|
38
|
-
def straighten_transaction(transaction, address: nil)
|
39
|
-
outs = transaction['outputs'].map do |out|
|
40
|
-
{ amount: out['value'], receiving_address: out['address'] } if address.nil? || address == out['address']
|
41
|
-
end.compact
|
42
|
-
{
|
43
|
-
tid: transaction['txHash'],
|
44
|
-
total_amount: outs.inject(0) { |sum, o| sum + o[:amount] },
|
45
|
-
confirmations: transaction['confirmations'],
|
46
|
-
outs: outs
|
47
|
-
}
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|