wcx 0.1.1 → 0.1.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wcx.rb +17 -17
  3. data/lib/wcx/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12ea0bf8d49e30fc5da6872973455e2a36b44c9b
4
- data.tar.gz: 4c713cd2e3882fe67fc7f4580d9ee20d824ff4d0
3
+ metadata.gz: 0fa347c62665c295a26ef030a40d21194d17aa2e
4
+ data.tar.gz: 629bd1966546c7b9d8e45e2f11347e4ec34f65de
5
5
  SHA512:
6
- metadata.gz: a432246cbb318064c9f4c94a17b5d4251d425ed6475a36f7d38e442632b3d95bd6ea850e42affd1a5e9871a59ea861f041ba82393ce67006af10b8e8d9658d0b
7
- data.tar.gz: 29599c5a1e9a732ba43c730c1194475a10300c1332f891b1e92bfec68e490448ef8ecfb1e348023903a4a29b055810ed72d301eeccacd6031451ece30f4ce0cf
6
+ metadata.gz: fb01cdfb987dad3eea997fa527c06b7f3a9e40b082cffc1793a70f8b068d3dc48c842ce308048283492c8ad67b219538bb27e5414487fd7edd176f0bbd8f17da
7
+ data.tar.gz: 055aaf5490b7995f87f21bcc58b7876eaeff38895fa5a69134e922a0421daa0fad43508e31eab6303ebf1af5190c02221faf770ffc46595f63be51d8fd5e1bb7
data/lib/wcx.rb CHANGED
@@ -16,6 +16,7 @@ module Wcx
16
16
  # initialize BlockIo
17
17
  @api_key = args[:api_key]
18
18
  @secret = args[:secret]
19
+ @request = args[:request]
19
20
  @args = args
20
21
  # @encryptionKey = Helper.pinToAesKey(@pin) if !@pin.nil?
21
22
 
@@ -23,52 +24,51 @@ module Wcx
23
24
 
24
25
  @version = args[:version] || 1 # default version is 2
25
26
 
26
- self.api_call(['get_balances',""],args)
27
+ # self.api_call(['Tickerprice',""],args)
27
28
  end
28
29
 
29
30
  def self.method_missing(m, *args, &block)
30
31
 
31
32
  method_name = m.to_s
32
-
33
33
  params = get_params(args.first)
34
- self.api_call([method_name, params])
34
+ self.api_call([method_name, args])
35
35
 
36
36
  end
37
37
 
38
38
  private
39
39
 
40
- def self.api_call(endpoint,options={})
40
+ def self.api_call(endpoint)
41
41
 
42
42
  body = nil
43
43
 
44
44
  @conn_pool.with do |hc|
45
- # prevent initiation of HTTPClients every time we make this call, use a connection_pool
46
-
47
- puts options
48
-
45
+ # prevent initiation of HTTPClients every time we make this call, use a connection_pool
46
+ options = Hash[*endpoint[1]]
47
+ # payload = Hash["request" => endpoint[0], "nonce" => ((Time.now.to_f * 1_000_000_000).to_i).to_s]
49
48
  payload = {}
50
49
  payload['request'] = endpoint[0]
51
- payload['nonce'] = (Time.now.to_f * 1_000_000_000).to_i.to_s
52
- payload.merge!(options)
53
-
50
+ payload['nonce'] = ((Time.now.to_f * 1_000_000_000).to_i).to_s
51
+
52
+ if !options.empty?
53
+
54
+ payload.merge!(options)
55
+ end
56
+
54
57
  payload_enc = Base64.encode64(payload.to_json).gsub(/\s/, '')
55
-
56
58
  digest = OpenSSL::Digest.new('sha384')
57
59
  sig = OpenSSL::HMAC.hexdigest(digest, @secret, payload_enc)
58
60
 
59
-
60
- #puts payload
61
61
  header = { "X-WCX-APIKEY" => @api_key, "X-WCX-PAYLOAD" => payload_enc, 'X-WCX-SIGNATURE' => sig}
62
-
63
- puts header
62
+ # puts header
64
63
  hc.ssl_config.ssl_version = :TLSv1
65
64
  response = hc.get("#{@base_url.gsub('API_CALL',endpoint[0]).gsub('VERSION', 'v'+@version.to_s)}", endpoint[1],header)
65
+ # puts response.body
66
66
  body = JSON.parse(response.body)
67
67
  # puts 'rest'+body
68
68
  begin
69
69
  body = JSON.parse(response.body)
70
70
 
71
- raise Exception.new(body['result']) if !body['status'].eql?('1')
71
+ raise Exception.new(body['result']) if !body['status'].eql?('0')
72
72
  rescue
73
73
  raise Exception.new('Unknown error occurred. Please report this.')
74
74
  end
data/lib/wcx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wcx
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - veerasarma
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-21 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler