blocktrail 0.2.1 → 0.2.3
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/blocktrail.gemspec +1 -1
- data/examples/simple_data_api_usage.rb +11 -3
- data/lib/blocktrail/client.rb +13 -18
- data/lib/blocktrail/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 144bfdfc329dd4b5a1a9ce10002f4f2334145a87
|
4
|
+
data.tar.gz: adc54a48cb4182a007920f01c72742a2e2525f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f849f9ab3efd49308e361419724e782d8aa41dcebb0ae6e326b71e497ed9a292bd9ec3ff67f7debba3199d5cae981c8d9199b3a6fce736f0a266f0b73cfce7af
|
7
|
+
data.tar.gz: ebe2d815d0703fc2b42d4effdf3cfb8d93f3b2dd318a68de0bca471dc7355df4f777c89ce7eae6f72830cbaa32fedbc346d92369424d6b70598b283900c62821
|
data/blocktrail.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "rest-client"
|
24
|
+
spec.add_dependency "rest-client"
|
25
25
|
spec.add_dependency "api-auth", "~> 2.1"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.14"
|
@@ -1,11 +1,19 @@
|
|
1
1
|
require 'blocktrail'
|
2
2
|
|
3
|
-
client = Blocktrail::Client.new('YOUR_API_KEY_HERE', 'YOUR_API_SECRET_HERE')
|
3
|
+
client = Blocktrail::Client.new(api_key: 'YOUR_API_KEY_HERE', api_secret: 'YOUR_API_SECRET_HERE')
|
4
|
+
|
5
|
+
# If the enviroment variables YOUR_API_KEY_HERE and YOUR_API_SECRET_HERE'
|
6
|
+
# are defined you can just do:
|
7
|
+
client = Blocktrail::Client.new
|
4
8
|
|
5
9
|
address = client.address('1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp')
|
6
10
|
client.price
|
7
11
|
client.address_transactions('1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp')['data']
|
8
12
|
client.verify_address('16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z', 'HPMOHRgPSMKdXrU6AqQs/i9S7alOakkHsJiqLGmInt05Cxj6b/WhS7kJxbIQxKmDW08YKzoFnbVZIoTI2qofEzk=')
|
9
13
|
|
10
|
-
# with testnet
|
11
|
-
client = Blocktrail::Client.new('YOUR_API_KEY_HERE', 'YOUR_API_SECRET_HERE', 'v1', true, true)
|
14
|
+
# with testnet, debug info for the Bitcoin network:
|
15
|
+
client = Blocktrail::Client.new(api_key: 'YOUR_API_KEY_HERE', api_secret: 'YOUR_API_SECRET_HERE', coin: 'btc', api_version: 'v1', testnet: true, debug: true)
|
16
|
+
|
17
|
+
# If the enviroment variables BLOCKTRAIL_API_KEY and BLOCKTRAIL_API_SECRET
|
18
|
+
# are defined you can just do:
|
19
|
+
client = Blocktrail::Client.new(coin: 'bcc', testnet: true, debug: true)
|
data/lib/blocktrail/client.rb
CHANGED
@@ -6,35 +6,30 @@ require 'api-auth'
|
|
6
6
|
|
7
7
|
module Blocktrail
|
8
8
|
class Client
|
9
|
-
attr_accessor :api_key, :api_secret, :api_version, :testnet, :debug
|
9
|
+
attr_accessor :api_key, :api_secret, :api_version, :coin, :testnet, :debug
|
10
10
|
|
11
|
-
def initialize(
|
12
|
-
@api_key = api_key
|
13
|
-
@api_secret = api_secret
|
14
|
-
@
|
15
|
-
@testnet = testnet
|
16
|
-
@debug = debug
|
17
|
-
end
|
18
|
-
|
19
|
-
def api_key
|
20
|
-
@api_key || ENV['API_KEY']
|
21
|
-
end
|
11
|
+
def initialize(options = {})
|
12
|
+
@api_key = options[:api_key].presence || ENV['BLOCKTRAIL_API_KEY']
|
13
|
+
@api_secret = options[:api_secret].presence || ENV['BLOCKTRAIL_API_SECRET']
|
14
|
+
raise 'No API Keys defined' if @api_key.blank? || @api_secret.blank?
|
22
15
|
|
23
|
-
|
24
|
-
@
|
16
|
+
@api_version = options[:api_version] || 'v1'
|
17
|
+
@coin = options[:coin] || 'btc'
|
18
|
+
@testnet = options[:testnet] || false
|
19
|
+
@debug = options[:debug] || false
|
25
20
|
end
|
26
21
|
|
27
22
|
def default_headers
|
28
23
|
{
|
29
24
|
'Content-Type' => 'application/json',
|
30
|
-
'User-Agent'
|
31
|
-
'Date'
|
25
|
+
'User-Agent' => "#{Blocktrail::SDK_USER_AGENT}/#{Blocktrail::VERSION}",
|
26
|
+
'Date' => Time.now.utc.iso8601
|
32
27
|
}
|
33
28
|
end
|
34
29
|
|
35
30
|
def default_params
|
36
31
|
{
|
37
|
-
'api_key'
|
32
|
+
'api_key' => api_key
|
38
33
|
}
|
39
34
|
end
|
40
35
|
|
@@ -189,7 +184,7 @@ module Blocktrail
|
|
189
184
|
private
|
190
185
|
|
191
186
|
def request(method, url, payload = {}, headers = {})
|
192
|
-
url = "https://api.blocktrail.com/#{api_version}/#{testnet ? 't' : ''}
|
187
|
+
url = "https://api.blocktrail.com/#{api_version}/#{testnet ? 't' : ''}#{coin}#{url}"
|
193
188
|
|
194
189
|
headers['Content-MD5'] = if payload.empty?
|
195
190
|
Digest::MD5.hexdigest('') # needs url here
|
data/lib/blocktrail/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blocktrail
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuri Skurikhin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: api-auth
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
124
|
+
rubygems_version: 2.6.14
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: Ruby bindings for the Blocktrail API.
|