paxful_client 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 254db880129744b08cde6919bfc46602d477b2a3157cf4b3b5cfa5c915d073fe
4
- data.tar.gz: 8d779a7267a67da361b314491c60256a0f5ce13744d3cb20ba3e7cfcc2b5f29d
3
+ metadata.gz: f4f2db608ddceb40e4e29da6a0361216a461969a95c8179515f04bd8b975f256
4
+ data.tar.gz: 2ead2910725c7649bae0015e049e5ea12f40a8ff29cccac24b3fcb25a4a1c403
5
5
  SHA512:
6
- metadata.gz: 7add11eb46dd431527e2b796e206ffa2308a17277736b4944a343b6c03d765e6134f23f483f7da3e018a3fb045ece8ee4e772f6af0b558fb265b0ce4d56e7421
7
- data.tar.gz: 6e2b95a8c2ef5b291764d8f9292e1d145c0e76df509b33a9edc4e54af3a07be6c5808281ef7f40c4f1b7dca935fd084dd09ae5366573c92bb2855215da9252f8
6
+ metadata.gz: cf3ebdf5000d7fe7a3085cfa57166b0fa59174f6427b3d5cc2f3fffa03bf832a9f1f1fb12a420e93c8429032c2fe4d56392b01e3f580372f23ddd80176a99036
7
+ data.tar.gz: e8f72c926f62c588a1c7c71241d647e7d74823f089b51bcb97fc7a321f306fe28ebdfa2e540a87d5b337126a6ff7ec931d79992cc855765d2fd242f68ae67cb4
@@ -0,0 +1,33 @@
1
+ # This workflow uses actions that are not certified by GitHub.
2
+ # They are provided by a third-party and are governed by
3
+ # separate terms of service, privacy policy, and support
4
+ # documentation.
5
+ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
6
+ # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
7
+
8
+ name: Ruby
9
+
10
+ on:
11
+ push:
12
+ branches: [ master ]
13
+ pull_request:
14
+ branches: [ master ]
15
+
16
+ jobs:
17
+ test:
18
+
19
+ runs-on: ubuntu-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby
24
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
25
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
26
+ # uses: ruby/setup-ruby@v1
27
+ uses: ruby/setup-ruby@ec106b438a1ff6ff109590de34ddc62c540232e0
28
+ with:
29
+ ruby-version: 2.6
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake
@@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
- ## [Unreleased]
7
+ ## [0.3.0] - 2020-10-12
8
+ ### Added
9
+ - add `trade/completed` endpoint
10
+ - add `PaxfulClient::OrderBook` model
11
+ - add `PaxfulClient::Trade` model
12
+
13
+ ## [0.2.0] - 2020-09-12
8
14
  ### Changed
9
15
  - refactor `get_balance` request
10
16
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paxful_client (0.2.0)
4
+ paxful_client (0.3.0)
5
5
  activesupport
6
6
  api_client_base
7
7
  typhoeus
@@ -9,7 +9,7 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- activesupport (6.0.3.3)
12
+ activesupport (6.0.3.4)
13
13
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
14
  i18n (>= 0.7, < 2)
15
15
  minitest (~> 5.1)
@@ -6,9 +6,15 @@ require "active_support/core_ext/hash/indifferent_access"
6
6
  require "openssl"
7
7
 
8
8
  require "paxful_client/client"
9
+ require "paxful_client/models/order_book"
10
+ require "paxful_client/models/trade"
9
11
  require "paxful_client/models/wallet"
12
+ require "paxful_client/requests/base_request"
10
13
  require "paxful_client/requests/get_balance_request"
14
+ require "paxful_client/requests/get_completed_trades_request"
15
+ require "paxful_client/responses/base_response"
11
16
  require "paxful_client/responses/get_balance_response"
17
+ require "paxful_client/responses/get_completed_trades_response"
12
18
 
13
19
  module PaxfulClient
14
20
  include APIClientBase::Base.module
@@ -4,6 +4,7 @@ module PaxfulClient
4
4
  include APIClientBase::Client.module(default_opts: :default_opts)
5
5
 
6
6
  api_action :get_balance
7
+ api_action :get_completed_trades
7
8
 
8
9
  attribute :host, String
9
10
  attribute :key, String
@@ -0,0 +1,13 @@
1
+ module PaxfulClient
2
+ class OrderBook
3
+
4
+ include Virtus.model
5
+
6
+ attribute :status, String
7
+ attribute :timestamp, Integer
8
+ attribute :count, Integer
9
+ attribute :page, Integer
10
+ attribute :trades, Array
11
+
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ module PaxfulClient
2
+ class Trade
3
+
4
+ include Virtus.model
5
+
6
+ attribute :status, String
7
+ attribute :trade_hash, String
8
+ attribute :offer_hash, String
9
+ attribute :offer_type, String
10
+ attribute :fiat_currency_code, String
11
+ attribute :crypto_currency_code, String
12
+ attribute :fiat_amount_requested, BigDecimal
13
+ attribute :crypto_amount_requested, BigDecimal
14
+ attribute :payment_method_name, String
15
+ attribute :started_at, String
16
+ attribute :ended_at, String
17
+ attribute :completed_at, String
18
+ attribute :seller, String
19
+ attribute :buyer, String
20
+
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ module PaxfulClient
2
+ class BaseRequest
3
+
4
+ include APIClientBase::Request
5
+
6
+ attribute :key, String
7
+ attribute :secret, String
8
+
9
+ private
10
+
11
+ def body
12
+ nonce = Time.now.to_i
13
+ apiseal = OpenSSL::HMAC.hexdigest(
14
+ "SHA256",
15
+ secret,
16
+ "apikey=#{key}&nonce=#{nonce}",
17
+ )
18
+
19
+ [
20
+ "apikey=#{key}",
21
+ "nonce=#{nonce}",
22
+ "apiseal=#{apiseal}",
23
+ ].join("&")
24
+ end
25
+
26
+ end
27
+ end
@@ -1,10 +1,5 @@
1
1
  module PaxfulClient
2
- class GetBalanceRequest
3
-
4
- include APIClientBase::Request.module(action: :post)
5
-
6
- attribute :key, String
7
- attribute :secret, String
2
+ class GetBalanceRequest < BaseRequest
8
3
 
9
4
  private
10
5
 
@@ -19,19 +14,8 @@ module PaxfulClient
19
14
  }
20
15
  end
21
16
 
22
- def body
23
- nonce = Time.now.to_i
24
- apiseal = OpenSSL::HMAC.hexdigest(
25
- "SHA256",
26
- secret,
27
- "apikey=#{key}&nonce=#{nonce}",
28
- )
29
-
30
- [
31
- "apikey=#{key}",
32
- "nonce=#{nonce}",
33
- "apiseal=#{apiseal}",
34
- ].join("&")
17
+ def default_action
18
+ :post
35
19
  end
36
20
 
37
21
  end
@@ -0,0 +1,22 @@
1
+ module PaxfulClient
2
+ class GetCompletedTradesRequest < BaseRequest
3
+
4
+ private
5
+
6
+ def path
7
+ "/trade/completed"
8
+ end
9
+
10
+ def headers
11
+ {
12
+ "Accept" => "application/json",
13
+ "Content-Type" => "text/plain",
14
+ }
15
+ end
16
+
17
+ def default_action
18
+ :post
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module PaxfulClient
2
+ class BaseResponse
3
+
4
+ include APIClientBase::Response.module
5
+
6
+ attribute :body, Object, lazy: true, default: :default_body
7
+ attribute :parsed_body, String, lazy: true, default: :default_parsed_body
8
+
9
+ private
10
+
11
+ def default_body
12
+ raw_response.body
13
+ end
14
+
15
+ def default_parsed_body
16
+ JSON.parse(body).with_indifferent_access
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ module PaxfulClient
2
+ class GetCompletedTradesResponse < BaseResponse
3
+
4
+ attribute :order_book, PaxfulClient::OrderBook, lazy: true, default: :default_order_book
5
+
6
+ private
7
+
8
+ def default_order_book
9
+ status = parsed_body["status"]
10
+ timestamp = parsed_body["timestamp"]
11
+ args = parsed_body["data"]
12
+
13
+ order_book = OrderBook.new
14
+ order_book.status = status
15
+ order_book.timestamp = timestamp
16
+ order_book.count = args["count"]
17
+ order_book.page = args["page"]
18
+ order_book.trades = args["trades"].map do |trade_hash|
19
+ Trade.new(trade_hash)
20
+ end
21
+
22
+ order_book
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module PaxfulClient
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paxful_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2020-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -101,9 +101,9 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".github/workflows/ruby.yml"
104
105
  - ".gitignore"
105
106
  - ".rspec"
106
- - ".travis.yml"
107
107
  - CHANGELOG.md
108
108
  - CODE_OF_CONDUCT.md
109
109
  - Gemfile
@@ -115,9 +115,15 @@ files:
115
115
  - bin/setup
116
116
  - lib/paxful_client.rb
117
117
  - lib/paxful_client/client.rb
118
+ - lib/paxful_client/models/order_book.rb
119
+ - lib/paxful_client/models/trade.rb
118
120
  - lib/paxful_client/models/wallet.rb
121
+ - lib/paxful_client/requests/base_request.rb
119
122
  - lib/paxful_client/requests/get_balance_request.rb
123
+ - lib/paxful_client/requests/get_completed_trades_request.rb
124
+ - lib/paxful_client/responses/base_response.rb
120
125
  - lib/paxful_client/responses/get_balance_response.rb
126
+ - lib/paxful_client/responses/get_completed_trades_response.rb
121
127
  - lib/paxful_client/version.rb
122
128
  - paxful_client.gemspec
123
129
  homepage: https://github.com/MarkFChavez/paxful_client-ruby
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.5.3
6
- before_install: gem install bundler -v 2.1.4