paxful_client 0.3.0 → 1.4.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: f4f2db608ddceb40e4e29da6a0361216a461969a95c8179515f04bd8b975f256
4
- data.tar.gz: 2ead2910725c7649bae0015e049e5ea12f40a8ff29cccac24b3fcb25a4a1c403
3
+ metadata.gz: 36845963975c5db9f0a3184a366c0958283e4eeb18dd583db1987c4c4aac98a8
4
+ data.tar.gz: 968fb3acba949cb42c2e9425af38655da1ed612ca6a1a9b4793c620bb3b9296e
5
5
  SHA512:
6
- metadata.gz: cf3ebdf5000d7fe7a3085cfa57166b0fa59174f6427b3d5cc2f3fffa03bf832a9f1f1fb12a420e93c8429032c2fe4d56392b01e3f580372f23ddd80176a99036
7
- data.tar.gz: e8f72c926f62c588a1c7c71241d647e7d74823f089b51bcb97fc7a321f306fe28ebdfa2e540a87d5b337126a6ff7ec931d79992cc855765d2fd242f68ae67cb4
6
+ metadata.gz: 01e726e25a432383ab74b3ccde07c3cff7d1bf1c480afb8f9a4feaf0b52a0ca646f362fa427c2830e13a9996c21fe27112ec9af2d4f0394b99a58936fe8b3c85
7
+ data.tar.gz: d2b14a64416ba640ba0231c9bd2ea9f75d3d37eb7a41ccb71d40e3e110bb45a8160b7a0adf383da2099d24b3e9957e63c3a3be3e1b318c1441c587347079447b
@@ -20,14 +20,12 @@ jobs:
20
20
 
21
21
  steps:
22
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
23
+ - uses: actions/setup-ruby@v1
28
24
  with:
29
- ruby-version: 2.6
25
+ ruby-version: '2.7'
30
26
  - name: Install dependencies
31
27
  run: bundle install
28
+ - name: Copy config.yml
29
+ run: cp spec/config.yml{.sample,}
32
30
  - name: Run tests
33
31
  run: bundle exec rake
data/CHANGELOG.md CHANGED
@@ -4,6 +4,26 @@ 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
+ ## [1.4.0] - 2021-06-15
8
+ ### Added
9
+ - Update `dry-validation` to 1.x
10
+
11
+ ## [1.3.0] - 2021-01-06
12
+ ### Changed
13
+ - `get_balance#success?` now checks if the response body has a `data` element. Sometimes Paxful returns 200, but has an empty body
14
+
15
+ ## [1.2.0] - 2020-12-15
16
+ ### Changed
17
+ - Only consider success for `get_completed_trades` if it meets certain criteria
18
+
19
+ ## [1.1.0] - 2020-11-25
20
+ ### Added
21
+ - Add support for passing in `page` for completed trades
22
+
23
+ ## [1.0.0] - 2020-11-19
24
+ ### Added
25
+ - Ensure that `key` and `secret` are present; raise exception otherwise
26
+
7
27
  ## [0.3.0] - 2020-10-12
8
28
  ### Added
9
29
  - add `trade/completed` endpoint
data/Gemfile.lock CHANGED
@@ -1,23 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paxful_client (0.3.0)
4
+ paxful_client (1.4.0)
5
5
  activesupport
6
6
  api_client_base
7
+ dry-validation (~> 1.0, < 2)
7
8
  typhoeus
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (6.0.3.4)
13
+ activesupport (6.1.3.2)
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
- api_client_base (1.9.0)
21
+ api_client_base (1.10.0)
21
22
  activesupport (>= 3.0)
22
23
  gem_config (>= 0.3.1)
23
24
  virtus (>= 1.0)
@@ -28,23 +29,56 @@ GEM
28
29
  coderay (1.1.3)
29
30
  coercible (1.0.0)
30
31
  descendants_tracker (~> 0.0.1)
31
- concurrent-ruby (1.1.7)
32
+ concurrent-ruby (1.1.9)
32
33
  crack (0.4.3)
33
34
  safe_yaml (~> 1.0.0)
34
35
  descendants_tracker (0.0.4)
35
36
  thread_safe (~> 0.3, >= 0.3.1)
36
37
  diff-lcs (1.4.4)
37
- equalizer (0.0.11)
38
- ethon (0.12.0)
39
- ffi (>= 1.3.0)
40
- ffi (1.13.1)
38
+ dry-configurable (0.12.1)
39
+ concurrent-ruby (~> 1.0)
40
+ dry-core (~> 0.5, >= 0.5.0)
41
+ dry-container (0.8.0)
42
+ concurrent-ruby (~> 1.0)
43
+ dry-configurable (~> 0.1, >= 0.1.3)
44
+ dry-core (0.6.0)
45
+ concurrent-ruby (~> 1.0)
46
+ dry-equalizer (0.3.0)
47
+ dry-inflector (0.2.0)
48
+ dry-initializer (3.0.4)
49
+ dry-logic (1.2.0)
50
+ concurrent-ruby (~> 1.0)
51
+ dry-core (~> 0.5, >= 0.5)
52
+ dry-schema (1.6.2)
53
+ concurrent-ruby (~> 1.0)
54
+ dry-configurable (~> 0.8, >= 0.8.3)
55
+ dry-core (~> 0.5, >= 0.5)
56
+ dry-initializer (~> 3.0)
57
+ dry-logic (~> 1.0)
58
+ dry-types (~> 1.5)
59
+ dry-types (1.5.1)
60
+ concurrent-ruby (~> 1.0)
61
+ dry-container (~> 0.3)
62
+ dry-core (~> 0.5, >= 0.5)
63
+ dry-inflector (~> 0.1, >= 0.1.2)
64
+ dry-logic (~> 1.0, >= 1.0.2)
65
+ dry-validation (1.6.0)
66
+ concurrent-ruby (~> 1.0)
67
+ dry-container (~> 0.7, >= 0.7.1)
68
+ dry-core (~> 0.4)
69
+ dry-equalizer (~> 0.2)
70
+ dry-initializer (~> 3.0)
71
+ dry-schema (~> 1.5, >= 1.5.2)
72
+ ethon (0.14.0)
73
+ ffi (>= 1.15.0)
74
+ ffi (1.15.1)
41
75
  gem_config (0.3.2)
42
76
  hashdiff (1.0.1)
43
- i18n (1.8.5)
77
+ i18n (1.8.10)
44
78
  concurrent-ruby (~> 1.0)
45
79
  ice_nine (0.11.2)
46
80
  method_source (1.0.0)
47
- minitest (5.14.2)
81
+ minitest (5.14.4)
48
82
  pry (0.13.1)
49
83
  coderay (~> 1.1)
50
84
  method_source (~> 1.0)
@@ -67,19 +101,18 @@ GEM
67
101
  thread_safe (0.3.6)
68
102
  typhoeus (1.4.0)
69
103
  ethon (>= 0.9.0)
70
- tzinfo (1.2.7)
71
- thread_safe (~> 0.1)
104
+ tzinfo (2.0.4)
105
+ concurrent-ruby (~> 1.0)
72
106
  vcr (3.0.3)
73
- virtus (1.0.5)
107
+ virtus (2.0.0)
74
108
  axiom-types (~> 0.1)
75
109
  coercible (~> 1.0)
76
110
  descendants_tracker (~> 0.0, >= 0.0.3)
77
- equalizer (~> 0.0, >= 0.0.9)
78
111
  webmock (2.3.2)
79
112
  addressable (>= 2.3.6)
80
113
  crack (>= 0.3.2)
81
114
  hashdiff
82
- zeitwerk (2.4.0)
115
+ zeitwerk (2.4.2)
83
116
 
84
117
  PLATFORMS
85
118
  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
 
data/lib/paxful_client.rb CHANGED
@@ -1,5 +1,6 @@
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"
@@ -15,6 +16,9 @@ require "paxful_client/requests/get_completed_trades_request"
15
16
  require "paxful_client/responses/base_response"
16
17
  require "paxful_client/responses/get_balance_response"
17
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"
18
22
 
19
23
  module PaxfulClient
20
24
  include APIClientBase::Base.module
@@ -5,20 +5,22 @@ module PaxfulClient
5
5
 
6
6
  attribute :key, String
7
7
  attribute :secret, String
8
+ attribute :page, Integer, default: 1
8
9
 
9
10
  private
10
11
 
11
12
  def body
12
13
  nonce = Time.now.to_i
13
14
  apiseal = OpenSSL::HMAC.hexdigest(
14
- "SHA256",
15
- secret,
16
- "apikey=#{key}&nonce=#{nonce}",
15
+ "SHA256",
16
+ secret,
17
+ "apikey=#{key}&nonce=#{nonce}&page=#{page}",
17
18
  )
18
19
 
19
20
  [
20
21
  "apikey=#{key}",
21
22
  "nonce=#{nonce}",
23
+ "page=#{page}",
22
24
  "apiseal=#{apiseal}",
23
25
  ].join("&")
24
26
  end
@@ -5,6 +5,7 @@ module PaxfulClient
5
5
 
6
6
  attribute :body, Object, lazy: true, default: :default_body
7
7
  attribute :parsed_body, String, lazy: true, default: :default_parsed_body
8
+ attribute :error_message, String, lazy: true
8
9
 
9
10
  private
10
11
 
@@ -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
@@ -22,5 +22,15 @@ module PaxfulClient
22
22
  order_book
23
23
  end
24
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
+
25
35
  end
26
36
  end
@@ -0,0 +1,10 @@
1
+ module PaxfulClient
2
+ class BaseRequestSchema < Dry::Validation::Contract
3
+
4
+ params do
5
+ required(:key).filled(:string)
6
+ required(:secret).filled(:string)
7
+ end
8
+
9
+ end
10
+ 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.3.0"
2
+ VERSION = "1.4.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", "~> 1.0", "< 2"
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.3.0
4
+ version: 1.4.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-10-12 00:00:00.000000000 Z
11
+ date: 2021-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: api_client_base
@@ -52,6 +52,26 @@ 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: '1.0'
62
+ - - "<"
63
+ - !ruby/object:Gem::Version
64
+ version: '2'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '1.0'
72
+ - - "<"
73
+ - !ruby/object:Gem::Version
74
+ version: '2'
55
75
  - !ruby/object:Gem::Dependency
56
76
  name: pry
57
77
  requirement: !ruby/object:Gem::Requirement
@@ -124,6 +144,9 @@ files:
124
144
  - lib/paxful_client/responses/base_response.rb
125
145
  - lib/paxful_client/responses/get_balance_response.rb
126
146
  - lib/paxful_client/responses/get_completed_trades_response.rb
147
+ - lib/paxful_client/schemas/base_request_schema.rb
148
+ - lib/paxful_client/schemas/get_balance_request_schema.rb
149
+ - lib/paxful_client/schemas/get_completed_trades_request_schema.rb
127
150
  - lib/paxful_client/version.rb
128
151
  - paxful_client.gemspec
129
152
  homepage: https://github.com/MarkFChavez/paxful_client-ruby
@@ -148,8 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
171
  - !ruby/object:Gem::Version
149
172
  version: '0'
150
173
  requirements: []
151
- rubyforge_project:
152
- rubygems_version: 2.7.6
174
+ rubygems_version: 3.1.6
153
175
  signing_key:
154
176
  specification_version: 4
155
177
  summary: API wrapper for Paxful