quoine_client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa810b342d7fd128ee45e3c33820aa38e3362321
4
+ data.tar.gz: 919561ae4ee2747cbbdb2bb6aabf321201cfa522
5
+ SHA512:
6
+ metadata.gz: dfee18b254acac4a1e5965c5a770e0fdc7bb1606e52e6765c974ec65a78e684647092abc36966bf71bd78dcee0d7a5b02be699d0a6d17763d73c954ad4e2c296
7
+ data.tar.gz: 152585ad0df4260c7754a9630a77b883072127303fdcb5ea7736eac9e1e1f0434266d86fe5d85c5bbec451ce2c651f0d19effceebb9632149b9fed51771a8b16
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/config.yml
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ ruby-2.3.1
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,16 @@
1
+ # Change Log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/).
6
+
7
+ ## [0.1.0] - 2017-04-10
8
+ ### Added
9
+ - Add `client.get_order_book` quoine client method
10
+ - Add `client.list_products` quoine client method
11
+ - Add `client.get_product` quoine client method
12
+
13
+ ### Changed
14
+ - Rename `quoine` gem to `quoine_client`
15
+
16
+
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in quoine.gemspec
4
+ gemspec
5
+
6
+ gem "pry"
7
+
@@ -0,0 +1,38 @@
1
+ # QuoineClient
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/quoine_client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'quoine_client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install quoine_client
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ To run tests run `bundle exec rspec spec`. Copy over `spec/config.yml.sample` into your own `spec/config.yml` and populate with the necessary Quoine credentials
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/quoine_client.
38
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "quoine_client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,32 @@
1
+ require "api_client_base"
2
+ require "typhoeus"
3
+ require "time"
4
+ require "securerandom"
5
+ require "base64"
6
+ require "json"
7
+
8
+ require "quoine_client/version"
9
+ require "quoine_client/client"
10
+ require "quoine_client/models/base_model"
11
+ require "quoine_client/models/product"
12
+ require "quoine_client/models/order"
13
+ require "quoine_client/models/order_book"
14
+ require "quoine_client/requests/base_request"
15
+ require "quoine_client/requests/list_products_request"
16
+ require "quoine_client/requests/get_order_book_request"
17
+ require "quoine_client/requests/get_product_request"
18
+ require "quoine_client/responses/base_response"
19
+ require "quoine_client/responses/list_products_response"
20
+ require "quoine_client/responses/get_order_book_response"
21
+ require "quoine_client/responses/get_product_response"
22
+
23
+ module QuoineClient
24
+ include APIClientBase::Base.module
25
+
26
+ with_configuration do
27
+ has :host, classes: String, default: "https://api.quoine.com"
28
+ has :user_id, classes: String
29
+ has :user_secret, classes: String
30
+ end
31
+ end
32
+
@@ -0,0 +1,20 @@
1
+ module QuoineClient
2
+ class Client
3
+
4
+ include APIClientBase::Client.module(default_opts: :default_opts)
5
+ attribute :host, String
6
+ attribute :user_id, String
7
+ attribute :user_secret, String
8
+
9
+ api_action :list_products
10
+ api_action :get_product, args: [:product_id]
11
+ api_action :get_order_book, args: [:product_id]
12
+
13
+ private
14
+
15
+ def default_opts
16
+ { host: host, user_id: user_id, user_secret: user_secret }
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ module QuoineClient
2
+ class BaseModel
3
+
4
+ include Virtus.model
5
+
6
+ end
7
+ end
8
+
@@ -0,0 +1,14 @@
1
+ module QuoineClient
2
+ class Order < BaseModel
3
+ attribute :rate, Float
4
+ attribute :volume, Float
5
+
6
+ def initialize(*args)
7
+ return super(*args) if args.first.is_a?(Hash)
8
+
9
+ arg = args.flatten
10
+ self.rate = arg.first
11
+ self.volume = arg.last
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ module QuoineClient
2
+ class OrderBook < BaseModel
3
+
4
+ attribute :buy_price_levels, Array[QuoineClient::Order]
5
+ attribute :sell_price_levels, Array[QuoineClient::Order]
6
+
7
+ end
8
+ end
9
+
@@ -0,0 +1,27 @@
1
+ module QuoineClient
2
+ class Product < BaseModel
3
+ attribute :id, Integer
4
+ attribute :product_type, String
5
+ attribute :code, String
6
+ attribute :name, String
7
+ attribute :market_ask, Float
8
+ attribute :market_bid, Float
9
+ attribute :indicator, Integer
10
+ attribute :currency, String
11
+ attribute :currency_pair_code, String
12
+ attribute :symbol, String
13
+ attribute :btc_minimum_withdraw, Float
14
+ attribute :fiat_minimum_withdraw, Float
15
+ attribute :pusher_channel, String
16
+ attribute :taker_fee, Float
17
+ attribute :maker_fee, Float
18
+ attribute :low_market_bid, Float
19
+ attribute :high_market_ask, Float
20
+ attribute :volume_24h, Float
21
+ attribute :last_price_24h, Float
22
+ attribute :last_traded_price, Float
23
+ attribute :last_traded_quantity, Float
24
+ attribute :quoted_currency, String
25
+ attribute :base_currency, String
26
+ end
27
+ end
@@ -0,0 +1,40 @@
1
+ module QuoineClient
2
+ class BaseRequest
3
+
4
+ include APIClientBase::Request.module
5
+ attribute :user_secret, String
6
+ attribute :user_id, String
7
+ attribute :nonce, String, default: :default_nonce
8
+ attribute :date_of_request, String, default: Time.now.httpdate
9
+ attribute :signature, String, lazy: true, default: :default_signature
10
+
11
+ private
12
+
13
+ def headers
14
+ {
15
+ "Content-Type" => "application/json",
16
+ "Date" => date_of_request,
17
+ "NONCE" => nonce,
18
+ "Authorization" => "APIAuth #{user_id}:#{signature}",
19
+ }
20
+ end
21
+
22
+ def default_nonce
23
+ SecureRandom.hex
24
+ end
25
+
26
+ def default_signature
27
+ canonical_string = "application/json,,#{path},#{date_of_request},#{nonce}"
28
+
29
+ Base64.strict_encode64(
30
+ OpenSSL::HMAC.digest(
31
+ OpenSSL::Digest.new("sha1"),
32
+ user_secret,
33
+ canonical_string,
34
+ )
35
+ )
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,13 @@
1
+ module QuoineClient
2
+ class GetOrderBookRequest < BaseRequest
3
+
4
+ attribute :product_id, String
5
+ private
6
+
7
+ def path
8
+ "/products/:product_id/price_levels"
9
+ end
10
+
11
+ end
12
+ end
13
+
@@ -0,0 +1,13 @@
1
+ module QuoineClient
2
+ class GetProductRequest < BaseRequest
3
+
4
+ attribute :product_id, String
5
+ private
6
+
7
+ def path
8
+ "/products/:product_id"
9
+ end
10
+
11
+ end
12
+ end
13
+
@@ -0,0 +1,12 @@
1
+ module QuoineClient
2
+ class ListProductsRequest < BaseRequest
3
+
4
+ private
5
+
6
+ def path
7
+ "/products"
8
+ end
9
+
10
+ end
11
+ end
12
+
@@ -0,0 +1,15 @@
1
+ module QuoineClient
2
+ class BaseResponse
3
+
4
+ include APIClientBase::Response.module
5
+ attribute :body, String, lazy: true, default: :default_body
6
+
7
+ private
8
+
9
+ def default_body
10
+ raw_response.body
11
+ end
12
+
13
+ end
14
+ end
15
+
@@ -0,0 +1,17 @@
1
+ module QuoineClient
2
+ class GetOrderBookResponse < BaseResponse
3
+
4
+ attribute(:order_book, OrderBook, {
5
+ lazy: true,
6
+ default: :default_order_book,
7
+ })
8
+
9
+ private
10
+
11
+ def default_order_book
12
+ OrderBook.new(JSON.parse(body))
13
+ end
14
+
15
+ end
16
+ end
17
+
@@ -0,0 +1,19 @@
1
+ module QuoineClient
2
+ class GetProductResponse < BaseResponse
3
+
4
+ attribute(
5
+ :product,
6
+ QuoineClient::Product,
7
+ lazy: true,
8
+ default: :default_product,
9
+ )
10
+
11
+ private
12
+
13
+ def default_product
14
+ QuoineClient::Product.new(JSON.parse(body))
15
+ end
16
+
17
+ end
18
+ end
19
+
@@ -0,0 +1,16 @@
1
+ module QuoineClient
2
+ class ListProductsResponse < BaseResponse
3
+
4
+ attribute :products, Array, lazy: true, default: :default_products
5
+
6
+ private
7
+
8
+ def default_products
9
+ JSON.parse(body).map do |product|
10
+ QuoineClient::Product.new(product)
11
+ end
12
+ end
13
+
14
+ end
15
+ end
16
+
@@ -0,0 +1,3 @@
1
+ module QuoineClient
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'quoine_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "quoine_client"
8
+ spec.version = QuoineClient::VERSION
9
+ spec.authors = ["israelkeys", "ramontayag", "ace-subido"]
10
+ spec.email = ["israelkeys@gmail.com", "ramon.tayag@gmail.com", "ace.subido@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby wrapper for BloomNet Center's API}
13
+ spec.description = %q{Ruby wrapper for BloomNet Center's API}
14
+ spec.homepage = "https://github.com/imacchiato/quoine_client-ruby"
15
+ spec.license = "MIT"
16
+
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
25
+ f.match(%r{^(test|spec|features)/})
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "api_client_base", "~> 1.0"
32
+ spec.add_dependency "typhoeus", "~> 1.0"
33
+ spec.add_dependency "virtus", "~> 1.0"
34
+ spec.add_development_dependency "bundler", "~> 1.14"
35
+ spec.add_development_dependency "rake", "~> 12.0"
36
+ spec.add_development_dependency "rspec", "~> 3.5"
37
+ spec.add_development_dependency "timecop", "0.8.1"
38
+ spec.add_development_dependency "vcr", "~> 3.0"
39
+ spec.add_development_dependency "virtus-matchers", ">= 0.4.0"
40
+ spec.add_development_dependency "webmock", "~> 2.3"
41
+
42
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quoine_client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - israelkeys
8
+ - ramontayag
9
+ - ace-subido
10
+ autorequire:
11
+ bindir: exe
12
+ cert_chain: []
13
+ date: 2017-04-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: api_client_base
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: typhoeus
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: virtus
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: bundler
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.14'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.14'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '12.0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '12.0'
85
+ - !ruby/object:Gem::Dependency
86
+ name: rspec
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '3.5'
92
+ type: :development
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '3.5'
99
+ - !ruby/object:Gem::Dependency
100
+ name: timecop
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '='
104
+ - !ruby/object:Gem::Version
105
+ version: 0.8.1
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '='
111
+ - !ruby/object:Gem::Version
112
+ version: 0.8.1
113
+ - !ruby/object:Gem::Dependency
114
+ name: vcr
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '3.0'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
125
+ - !ruby/object:Gem::Version
126
+ version: '3.0'
127
+ - !ruby/object:Gem::Dependency
128
+ name: virtus-matchers
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 0.4.0
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 0.4.0
141
+ - !ruby/object:Gem::Dependency
142
+ name: webmock
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '2.3'
148
+ type: :development
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - "~>"
153
+ - !ruby/object:Gem::Version
154
+ version: '2.3'
155
+ description: Ruby wrapper for BloomNet Center's API
156
+ email:
157
+ - israelkeys@gmail.com
158
+ - ramon.tayag@gmail.com
159
+ - ace.subido@gmail.com
160
+ executables: []
161
+ extensions: []
162
+ extra_rdoc_files: []
163
+ files:
164
+ - ".gitignore"
165
+ - ".rspec"
166
+ - ".ruby-version"
167
+ - ".travis.yml"
168
+ - CHANGELOG.md
169
+ - Gemfile
170
+ - README.md
171
+ - Rakefile
172
+ - bin/console
173
+ - bin/setup
174
+ - lib/quoine_client.rb
175
+ - lib/quoine_client/client.rb
176
+ - lib/quoine_client/models/base_model.rb
177
+ - lib/quoine_client/models/order.rb
178
+ - lib/quoine_client/models/order_book.rb
179
+ - lib/quoine_client/models/product.rb
180
+ - lib/quoine_client/requests/base_request.rb
181
+ - lib/quoine_client/requests/get_order_book_request.rb
182
+ - lib/quoine_client/requests/get_product_request.rb
183
+ - lib/quoine_client/requests/list_products_request.rb
184
+ - lib/quoine_client/responses/base_response.rb
185
+ - lib/quoine_client/responses/get_order_book_response.rb
186
+ - lib/quoine_client/responses/get_product_response.rb
187
+ - lib/quoine_client/responses/list_products_response.rb
188
+ - lib/quoine_client/version.rb
189
+ - quoine_client.gemspec
190
+ homepage: https://github.com/imacchiato/quoine_client-ruby
191
+ licenses:
192
+ - MIT
193
+ metadata:
194
+ allowed_push_host: https://rubygems.org
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.5.1
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Ruby wrapper for BloomNet Center's API
215
+ test_files: []