nl-btcmarkets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/nl-btcmarkets.rb +37 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cc654487a8d3c2eb0f31de429375cc896087bf83
4
+ data.tar.gz: d00d58ed1e22b46a2575520c548f09e54d8d4d60
5
+ SHA512:
6
+ metadata.gz: 74eb4939c4a4f0de8599ed5f03ea66b2cda16b4130e08d7c23e58bbc68c7a0845c5f469eae848496e62ca46957b1feab57495188d1e4a8e96ea5d2aa55352d0c
7
+ data.tar.gz: 2806df78ea91b2569b7a5a352c9e96893bde3b3af8ce6424d319d87a949c58e9c62b6d412ea7747839d5c2c6a187577af3e5c79774f3a80438657a1b1c3058f0
@@ -0,0 +1,37 @@
1
+ require 'base64'
2
+ require 'cgi'
3
+ require 'openssl'
4
+ require 'json'
5
+ require 'digest/md5'
6
+ require 'httparty'
7
+
8
+ class BTCMarkets
9
+ include HTTParty
10
+ base_uri 'https://api.btcmarkets.net'
11
+
12
+ def initialize(options={})
13
+ @apisecret = Base64.decode64(ENV['btcm_access_secret'])
14
+ @apikey = ENV['btcm_access_key']
15
+ #@currency = ENV['btcm_currency']
16
+ @nonce = (Time.now.to_f * 1000).to_i.to_s
17
+ @parameters = ''
18
+ end
19
+
20
+ def method_missing(method_sym, *arguments, &block)
21
+ convert_undercores_to_slashes = method_sym.to_s.gsub('_','/')
22
+ if arguments.length == 1 then
23
+ if arguments[0].kind_of? Hash
24
+ @parameters = arguments[0].to_json # Its a json thing!
25
+ end
26
+ end
27
+ @nonce = (Time.now.to_f * 1000).to_i.to_s # generate a new one each time
28
+ if @parameters != ''
29
+ to_sign = '/' + convert_undercores_to_slashes + "\n" + @nonce + "\n" + @parameters+ "\n"
30
+ else
31
+ to_sign = '/' + convert_undercores_to_slashes + "\n" + @nonce + "\n"
32
+ end
33
+ ssl_sign = OpenSSL::HMAC.digest('sha512', @apisecret, to_sign)
34
+ ssl_sign_encoded = Base64.encode64(ssl_sign).to_s.gsub("\n",'')
35
+ self.class.get('/' + convert_undercores_to_slashes, :headers => {'Content-Type' => 'application/json', 'apikey' => @apikey , 'signature' => ssl_sign_encoded, 'timestamp' => @nonce}).to_json
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nl-btcmarkets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Barry Teoh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A ruby class to talk to the BTC Markets API (Work in progress!)
14
+ email: hello@barryteoh.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/nl-btcmarkets.rb
20
+ homepage: https://github.com/nolim1t/btcmarkets-gem
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.5.0
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: nolim1t's BTC Markets Ruby Gem
44
+ test_files: []