bitbns 0.0.1.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bfd9c0df9654dcb1d8e8ad8c7e4feda73c6b32dfd4c3772ca3fcba9a3728b2cc
4
+ data.tar.gz: 3566656be7781a6d8e1d657dca4cf1c54569dd640f46004addb2d882f87d5d34
5
+ SHA512:
6
+ metadata.gz: 4a5a06dcde010daa618a25bdeca0ee2be7562bbd87007fe56205cfdf0f5c24c789bcb872b3a55de013c2f875fac7b1842c917149b9095de01881dc1b7656d8fd
7
+ data.tar.gz: fdedbdf90d0f2c4fd367bcfbc291d5c59ac1cec75406113814f00986fefe3429d3d4065c37e8792f3ba9bb359a994c3198b5b9412e30cda07c07f1dd156f47a0
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./requests/base.rb"
4
+ require_relative "./responses/base.rb"
5
+
6
+ module BitBns
7
+ class Client
8
+ attr_reader :api_key, :api_secret_key, :version
9
+ REQ_NAMESPACE = "BitBns::Requests"
10
+
11
+ def initialize(config)
12
+ @api_key = config.fetch(:api_key)
13
+ @api_secret_key = config.fetch(:api_secret_key)
14
+ @version = config.fetch(:version, 2)
15
+ end
16
+
17
+ def send_request(name, options = {})
18
+ request_spec = Kernel.const_get(parse_request_name(name)).new(options)
19
+ request_txn_modifiers = [
20
+ request_spec.verb,
21
+ request_spec.url,
22
+ request_spec.params,
23
+ request_spec.headers
24
+ ]
25
+
26
+ response = Faraday.new.send(*request_txn_modifiers) do |req|
27
+ req.body = request_spec.body
28
+ end
29
+
30
+ request_spec.response_parser.new(response)
31
+ end
32
+
33
+ def parse_request_name(name)
34
+ "#{REQ_NAMESPACE}::#{name.split("_").map(&:capitalize).join}"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ module BitBns
2
+ module Requests
3
+ require_relative "./request.rb"
4
+ require_relative "./fetch_markets.rb"
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ module BitBns
3
+ module Requests
4
+ class FetchMarkets < BitBns::Requests::Request
5
+ def initialize(opts)
6
+ @url = "#{PUB_BASE_URL}/order/fetchMarkets/"
7
+ @params = {}
8
+ @headers = {}
9
+ @verb = :get
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module BitBns
2
+ module Requests
3
+ class Request
4
+ attr_accessor :headers, :verb, :params, :body, :url
5
+ API_BASE_URL = "https://api.bitbns.com/api/trade/v%version"
6
+ PUB_BASE_URL = "https://bitbns.com"
7
+
8
+ def response_parser
9
+ Kernel.const_get("BitBns::Responses::#{self.class.to_s.split("::").last}")
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,6 @@
1
+ module BitBns
2
+ module Responses
3
+ require_relative "./response.rb"
4
+ require_relative "./fetch_markets.rb"
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ module BitBns
2
+ module Responses
3
+ class FetchMarkets < BitBns::Responses::Response
4
+ attr_reader :body, :headers, :raw
5
+
6
+ def initialize(response)
7
+ @raw = response
8
+ @body = JSON.parse(response.body)
9
+ @headers = response.headers
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ module BitBns
2
+ module Responses
3
+ class Response
4
+ end
5
+ end
6
+ end
data/lib/bitbns.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "faraday"
4
+
5
+ module BitBns
6
+ require_relative "./bitbns/client.rb"
7
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bitbns
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Sreedev Kodichath
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Ruby Wrapper around BitBns Crypto Trading APIs
14
+ email: sreedevpadmakumar@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/bitbns.rb
20
+ - lib/bitbns/client.rb
21
+ - lib/bitbns/requests/base.rb
22
+ - lib/bitbns/requests/fetch_markets.rb
23
+ - lib/bitbns/requests/request.rb
24
+ - lib/bitbns/responses/base.rb
25
+ - lib/bitbns/responses/fetch_markets.rb
26
+ - lib/bitbns/responses/response.rb
27
+ homepage: https:/bitbns.com
28
+ licenses:
29
+ - MIT
30
+ metadata:
31
+ source_code_uri: https://github.com/sreedevk/bitbns-rb
32
+ post_install_message:
33
+ rdoc_options: []
34
+ require_paths:
35
+ - lib
36
+ required_ruby_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.6.6
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">"
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.1
46
+ requirements: []
47
+ rubygems_version: 3.2.22
48
+ signing_key:
49
+ specification_version: 4
50
+ summary: BitBns API Client
51
+ test_files: []