Class: GarnetClient::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/garnet_client/service.rb

Class Method Summary collapse

Class Method Details

.tx_get_info(coin_type, tx_id) ⇒ Object

查询转账明细



41
42
43
44
45
46
47
# File 'lib/garnet_client/service.rb', line 41

def self.tx_get_info(coin_type, tx_id)
  service_path = "/tx/#{coin_type}/#{tx_id}"

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_get(service_path)
  msg
end

.tx_transfer(coin_type, source_id, from, to, value) ⇒ Object

发送一笔转账



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/garnet_client/service.rb', line 25

def self.tx_transfer(coin_type, source_id, from, to, value)
  service_path = "/tx/#{coin_type}/transfer"
  from_address = from.nil? ? '' : from
  post_params = {
      "source_id" => source_id,
      "from" => from_address,
      "to" => to,
      "value" => value
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end

.wallet_get_balance(coin_type, address) ⇒ Object

查询余额



16
17
18
19
20
21
22
# File 'lib/garnet_client/service.rb', line 16

def self.wallet_get_balance(coin_type, address)
  service_path = "/wallet/#{coin_type}/balance/#{address}"

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_get(service_path)
  msg
end

.wallet_get_or_create_address(coin_type, user_id) ⇒ Object

获得一个地址



4
5
6
7
8
9
10
11
12
13
# File 'lib/garnet_client/service.rb', line 4

def self.wallet_get_or_create_address(coin_type, user_id)
  service_path = "/wallet/#{coin_type}/get_or_create_address"
  post_params = {
      "user_id" => user_id
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end

.wallet_import_key(file_name, address, key_data, key_pwd, user_id) ⇒ Object

import钱包



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/garnet_client/service.rb', line 67

def self.wallet_import_key(file_name, address, key_data, key_pwd, user_id)
  service_path = "/wallet/eth/import_key"
  post_params = {
      "file_name" => file_name,
      "address" => address,
      "key_data" => key_data,
      "key_pwd" => key_pwd,
      "user_id" => user_id
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end

.withdraw_create_order(user_id, to, coin_type, value, transfer_fee, description) ⇒ Object

提交提现单



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/garnet_client/service.rb', line 50

def self.withdraw_create_order(user_id, to, coin_type, value, transfer_fee, description)
  service_path = "/withdraw/submit_order"
  post_params = {
      "user_id" => user_id,
      "to" => to,
      "coin_type" => coin_type,
      "value" => value,
      "transfer_fee" => transfer_fee,
      "description" => description
  }

  # 调用查询接口
  msg = GarnetClient::Utils::HttpRequest.send_post(service_path, post_params)
  msg
end