paxful_client 0.2.0 → 1.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 254db880129744b08cde6919bfc46602d477b2a3157cf4b3b5cfa5c915d073fe
4
- data.tar.gz: 8d779a7267a67da361b314491c60256a0f5ce13744d3cb20ba3e7cfcc2b5f29d
3
+ metadata.gz: e31445632e6df99df0ecdec87a56d68eeeb475287b881d53eb3a75a9d3292f35
4
+ data.tar.gz: 63ec0e3c38e12fe71ac6b41880e4008e4a51fd658464172de59cb628d4038ebe
5
5
  SHA512:
6
- metadata.gz: 7add11eb46dd431527e2b796e206ffa2308a17277736b4944a343b6c03d765e6134f23f483f7da3e018a3fb045ece8ee4e772f6af0b558fb265b0ce4d56e7421
7
- data.tar.gz: 6e2b95a8c2ef5b291764d8f9292e1d145c0e76df509b33a9edc4e54af3a07be6c5808281ef7f40c4f1b7dca935fd084dd09ae5366573c92bb2855215da9252f8
6
+ metadata.gz: 0a521e88fb719f7376433db827da71458d46309e3ac61e61f8af72dd910bcda757ff63c1d03c078f98140bf76f73c34803423fbc42091d01613010da37508061
7
+ data.tar.gz: 7326e16e3bdebb80b3c5fab4c2a806d9bc75a2dba5a57319d5eb8a5f783c1465c35a58bdebdc51303f26a0835e0c7e587208440b6198b33f46b1705c782ec213
@@ -0,0 +1,31 @@
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
+ - uses: actions/setup-ruby@v1
24
+ with:
25
+ ruby-version: '2.7'
26
+ - name: Install dependencies
27
+ run: bundle install
28
+ - name: Copy config.yml
29
+ run: cp spec/config.yml{.sample,}
30
+ - name: Run tests
31
+ run: bundle exec rake
@@ -4,7 +4,29 @@ 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
+ ## [1.3.0] - 2021-01-06
8
+ ### Changed
9
+ - `get_balance#success?` now checks if the response body has a `data` element. Sometimes Paxful returns 200, but has an empty body
10
+
11
+ ## [1.2.0] - 2020-12-15
12
+ ### Changed
13
+ - Only consider success for `get_completed_trades` if it meets certain criteria
14
+
15
+ ## [1.1.0] - 2020-11-25
16
+ ### Added
17
+ - Add support for passing in `page` for completed trades
18
+
19
+ ## [1.0.0] - 2020-11-19
20
+ ### Added
21
+ - Ensure that `key` and `secret` are present; raise exception otherwise
22
+
23
+ ## [0.3.0] - 2020-10-12
24
+ ### Added
25
+ - add `trade/completed` endpoint
26
+ - add `PaxfulClient::OrderBook` model
27
+ - add `PaxfulClient::Trade` model
28
+
29
+ ## [0.2.0] - 2020-09-12
8
30
  ### Changed
9
31
  - refactor `get_balance` request
10
32
 
@@ -1,20 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paxful_client (0.2.0)
4
+ paxful_client (1.3.0)
5
5
  activesupport
6
6
  api_client_base
7
+ dry-validation (~> 0.13)
7
8
  typhoeus
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (6.0.3.3)
13
+ activesupport (6.1.0)
13
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
- i18n (>= 0.7, < 2)
15
- minitest (~> 5.1)
16
- tzinfo (~> 1.1)
17
- zeitwerk (~> 2.2, >= 2.2.2)
15
+ i18n (>= 1.6, < 2)
16
+ minitest (>= 5.1)
17
+ tzinfo (~> 2.0)
18
+ zeitwerk (~> 2.3)
18
19
  addressable (2.7.0)
19
20
  public_suffix (>= 2.0.2, < 5.0)
20
21
  api_client_base (1.9.0)
@@ -34,17 +35,45 @@ GEM
34
35
  descendants_tracker (0.0.4)
35
36
  thread_safe (~> 0.3, >= 0.3.1)
36
37
  diff-lcs (1.4.4)
38
+ dry-configurable (0.12.0)
39
+ concurrent-ruby (~> 1.0)
40
+ dry-core (~> 0.5, >= 0.5.0)
41
+ dry-container (0.7.2)
42
+ concurrent-ruby (~> 1.0)
43
+ dry-configurable (~> 0.1, >= 0.1.3)
44
+ dry-core (0.5.0)
45
+ concurrent-ruby (~> 1.0)
46
+ dry-equalizer (0.3.0)
47
+ dry-inflector (0.2.0)
48
+ dry-logic (0.6.1)
49
+ concurrent-ruby (~> 1.0)
50
+ dry-core (~> 0.2)
51
+ dry-equalizer (~> 0.2)
52
+ dry-types (0.14.1)
53
+ concurrent-ruby (~> 1.0)
54
+ dry-container (~> 0.3)
55
+ dry-core (~> 0.4, >= 0.4.4)
56
+ dry-equalizer (~> 0.2)
57
+ dry-inflector (~> 0.1, >= 0.1.2)
58
+ dry-logic (~> 0.5, >= 0.5)
59
+ dry-validation (0.13.3)
60
+ concurrent-ruby (~> 1.0)
61
+ dry-configurable (~> 0.1, >= 0.1.3)
62
+ dry-core (~> 0.2, >= 0.2.1)
63
+ dry-equalizer (~> 0.2)
64
+ dry-logic (~> 0.5, >= 0.5.0)
65
+ dry-types (~> 0.14.0)
37
66
  equalizer (0.0.11)
38
67
  ethon (0.12.0)
39
68
  ffi (>= 1.3.0)
40
- ffi (1.13.1)
69
+ ffi (1.14.2)
41
70
  gem_config (0.3.2)
42
71
  hashdiff (1.0.1)
43
- i18n (1.8.5)
72
+ i18n (1.8.7)
44
73
  concurrent-ruby (~> 1.0)
45
74
  ice_nine (0.11.2)
46
75
  method_source (1.0.0)
47
- minitest (5.14.2)
76
+ minitest (5.14.3)
48
77
  pry (0.13.1)
49
78
  coderay (~> 1.1)
50
79
  method_source (~> 1.0)
@@ -67,8 +96,8 @@ GEM
67
96
  thread_safe (0.3.6)
68
97
  typhoeus (1.4.0)
69
98
  ethon (>= 0.9.0)
70
- tzinfo (1.2.7)
71
- thread_safe (~> 0.1)
99
+ tzinfo (2.0.4)
100
+ concurrent-ruby (~> 1.0)
72
101
  vcr (3.0.3)
73
102
  virtus (1.0.5)
74
103
  axiom-types (~> 0.1)
@@ -79,7 +108,7 @@ GEM
79
108
  addressable (>= 2.3.6)
80
109
  crack (>= 0.3.2)
81
110
  hashdiff
82
- zeitwerk (2.4.0)
111
+ zeitwerk (2.4.2)
83
112
 
84
113
  PLATFORMS
85
114
  ruby
data/README.md CHANGED
@@ -22,18 +22,29 @@ Or install it yourself as:
22
22
 
23
23
  ```ruby
24
24
  client = PaxfulClient.new(host: "host", key: "key", secret: "secret")
25
+
26
+ # Get balance
25
27
  response = client.get_balance
26
28
  wallet = response.wallet
27
-
28
- # get the balance
29
29
  wallet.balance
30
+
31
+ # Get completed trades (page = 1 by default)
32
+ response = client.get_completed_trades
33
+
34
+ # Get completed trades by page
35
+ response = client.get_completed_trades(page: page)
36
+
37
+ # Get response
38
+ order_book = response.order_book
39
+ order_book.trades
30
40
  ```
31
41
 
32
42
  ## Development
33
43
 
34
- 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.
35
-
36
- 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).
44
+ ```
45
+ cp spec/config.yml{.sample,}
46
+ rspec
47
+ ```
37
48
 
38
49
  ## Contributing
39
50
 
@@ -1,14 +1,24 @@
1
1
  require "paxful_client/version"
2
2
  require "api_client_base"
3
+ require "dry-validation"
3
4
 
4
5
  require "json"
5
6
  require "active_support/core_ext/hash/indifferent_access"
6
7
  require "openssl"
7
8
 
8
9
  require "paxful_client/client"
10
+ require "paxful_client/models/order_book"
11
+ require "paxful_client/models/trade"
9
12
  require "paxful_client/models/wallet"
13
+ require "paxful_client/requests/base_request"
10
14
  require "paxful_client/requests/get_balance_request"
15
+ require "paxful_client/requests/get_completed_trades_request"
16
+ require "paxful_client/responses/base_response"
11
17
  require "paxful_client/responses/get_balance_response"
18
+ require "paxful_client/responses/get_completed_trades_response"
19
+ require "paxful_client/schemas/base_request_schema"
20
+ require "paxful_client/schemas/get_balance_request_schema"
21
+ require "paxful_client/schemas/get_completed_trades_request_schema"
12
22
 
13
23
  module PaxfulClient
14
24
  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,29 @@
1
+ module PaxfulClient
2
+ class BaseRequest
3
+
4
+ include APIClientBase::Request
5
+
6
+ attribute :key, String
7
+ attribute :secret, String
8
+ attribute :page, Integer, default: 1
9
+
10
+ private
11
+
12
+ def body
13
+ nonce = Time.now.to_i
14
+ apiseal = OpenSSL::HMAC.hexdigest(
15
+ "SHA256",
16
+ secret,
17
+ "apikey=#{key}&nonce=#{nonce}&page=#{page}",
18
+ )
19
+
20
+ [
21
+ "apikey=#{key}",
22
+ "nonce=#{nonce}",
23
+ "page=#{page}",
24
+ "apiseal=#{apiseal}",
25
+ ].join("&")
26
+ end
27
+
28
+ end
29
+ 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,21 @@
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
+ attribute :error_message, String, lazy: true
9
+
10
+ private
11
+
12
+ def default_body
13
+ raw_response.body
14
+ end
15
+
16
+ def default_parsed_body
17
+ JSON.parse(body).with_indifferent_access
18
+ end
19
+
20
+ end
21
+ end
@@ -1,7 +1,5 @@
1
1
  module PaxfulClient
2
- class GetBalanceResponse
3
-
4
- include APIClientBase::Response.module
2
+ class GetBalanceResponse < BaseResponse
5
3
 
6
4
  attribute :wallet, PaxfulClient::Wallet, lazy: true, default: :default_wallet
7
5
  attribute :body, Object, lazy: true, default: :default_body
@@ -9,6 +7,14 @@ module PaxfulClient
9
7
 
10
8
  private
11
9
 
10
+ def default_success
11
+ unless parsed_body['data'].present?
12
+ self.error_message = 'GetBalanceResponse: data not present'
13
+ return false
14
+ end
15
+ raw_response.success?
16
+ end
17
+
12
18
  def default_wallet
13
19
  args = parsed_body["data"].each_with_object({}) do |(attr, val), hash|
14
20
  hash[attr.underscore] = val
@@ -0,0 +1,36 @@
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
+ def default_success
26
+ code == 200 && present_parsed_body?
27
+ end
28
+
29
+ def present_parsed_body?
30
+ !parsed_body.nil? &&
31
+ !parsed_body["data"].nil? &&
32
+ !parsed_body["data"]["trades"].nil?
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,8 @@
1
+ module PaxfulClient
2
+ BaseRequestSchema = Dry::Validation.Schema do
3
+
4
+ required(:key).filled(:str?)
5
+ required(:secret).filled(:str?)
6
+
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module PaxfulClient
2
+ GetBalanceRequestSchema = BaseRequestSchema
3
+ end
@@ -0,0 +1,3 @@
1
+ module PaxfulClient
2
+ GetCompletedTradesRequestSchema = BaseRequestSchema
3
+ end
@@ -1,3 +1,3 @@
1
1
  module PaxfulClient
2
- VERSION = "0.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "api_client_base"
29
29
  spec.add_dependency "typhoeus"
30
30
  spec.add_dependency "activesupport"
31
+ spec.add_dependency "dry-validation", "~> 0.13"
31
32
 
32
33
  spec.add_development_dependency "pry"
33
34
  spec.add_development_dependency "vcr", "~> 3.0"
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: 1.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: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dry-validation
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.13'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.13'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -101,9 +115,9 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".github/workflows/ruby.yml"
104
119
  - ".gitignore"
105
120
  - ".rspec"
106
- - ".travis.yml"
107
121
  - CHANGELOG.md
108
122
  - CODE_OF_CONDUCT.md
109
123
  - Gemfile
@@ -115,9 +129,18 @@ files:
115
129
  - bin/setup
116
130
  - lib/paxful_client.rb
117
131
  - lib/paxful_client/client.rb
132
+ - lib/paxful_client/models/order_book.rb
133
+ - lib/paxful_client/models/trade.rb
118
134
  - lib/paxful_client/models/wallet.rb
135
+ - lib/paxful_client/requests/base_request.rb
119
136
  - lib/paxful_client/requests/get_balance_request.rb
137
+ - lib/paxful_client/requests/get_completed_trades_request.rb
138
+ - lib/paxful_client/responses/base_response.rb
120
139
  - lib/paxful_client/responses/get_balance_response.rb
140
+ - lib/paxful_client/responses/get_completed_trades_response.rb
141
+ - lib/paxful_client/schemas/base_request_schema.rb
142
+ - lib/paxful_client/schemas/get_balance_request_schema.rb
143
+ - lib/paxful_client/schemas/get_completed_trades_request_schema.rb
121
144
  - lib/paxful_client/version.rb
122
145
  - paxful_client.gemspec
123
146
  homepage: https://github.com/MarkFChavez/paxful_client-ruby
@@ -142,8 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
165
  - !ruby/object:Gem::Version
143
166
  version: '0'
144
167
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.7.6
168
+ rubygems_version: 3.0.3
147
169
  signing_key:
148
170
  specification_version: 4
149
171
  summary: API wrapper for Paxful
@@ -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