paxful_client 0.1.0 → 1.2.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: bd4bceb9faf23e3312e6fcacc3e05a4c1ec64ec063c3e47eb35fca7258046203
4
- data.tar.gz: 6b4b36e4aa6118db45526d1224d4fa88fcb26eee350109a5ab5421cfa353be02
3
+ metadata.gz: 445e56c7910f8f51f1029e5f0af8513452c6824ecfc974972abb780f124587ab
4
+ data.tar.gz: e49d1a66ebe40915efe9e832876b63d646597a53d7272dbddc64b70fe13c4772
5
5
  SHA512:
6
- metadata.gz: 86718a060d6075badbbefe1d0e6f261be85ff21939019fccde70433e5f0a6ffe69a33bff1c2f3dce2e97698662ddd20687401131f95b588877a0a9d807f7f243
7
- data.tar.gz: 715d18fbcd1adb7855c492673f72582c652e92657e474c4af4c2df483289ec71bb321f13d2f328615af01d6fc365bd3cf6b89cee23c04d4840254d4301bb5f2b
6
+ metadata.gz: 9a75f633fcd0778ac1ba08d9915412e085c5499862f8430c100548673b942ae1659e08bf3c229846ee6c594e878c9f521b0dc8a256da4f88935b391af9d8f5aa
7
+ data.tar.gz: 6967c3a4737520d0e04328144c8422fe4e072bf12617b9bc8ae01fe3b60009c6c6cc166ce96c798ae394ba26f4f1af3878497f9ad57df348e662935a33c61865
@@ -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,5 +4,28 @@ 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.2.0] - 2020-12-15
8
+ ### Changed
9
+ - Only consider success for `get_completed_trades` if it meets certain criteria
10
+
11
+ ## [1.1.0] - 2020-11-25
12
+ ### Added
13
+ - Add support for passing in `page` for completed trades
14
+
15
+ ## [1.0.0] - 2020-11-19
16
+ ### Added
17
+ - Ensure that `key` and `secret` are present; raise exception otherwise
18
+
19
+ ## [0.3.0] - 2020-10-12
20
+ ### Added
21
+ - add `trade/completed` endpoint
22
+ - add `PaxfulClient::OrderBook` model
23
+ - add `PaxfulClient::Trade` model
24
+
25
+ ## [0.2.0] - 2020-09-12
26
+ ### Changed
27
+ - refactor `get_balance` request
28
+
29
+ ## [0.1.0] - 2020-09-12
30
+ ### Added
8
31
  - add `get_balance` endpoint
@@ -1,20 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paxful_client (0.1.0)
4
+ paxful_client (1.2.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,6 +35,35 @@ 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.11.6)
39
+ concurrent-ruby (~> 1.0)
40
+ dry-core (~> 0.4, >= 0.4.7)
41
+ dry-equalizer (~> 0.2)
42
+ dry-container (0.7.2)
43
+ concurrent-ruby (~> 1.0)
44
+ dry-configurable (~> 0.1, >= 0.1.3)
45
+ dry-core (0.5.0)
46
+ concurrent-ruby (~> 1.0)
47
+ dry-equalizer (0.3.0)
48
+ dry-inflector (0.2.0)
49
+ dry-logic (0.6.1)
50
+ concurrent-ruby (~> 1.0)
51
+ dry-core (~> 0.2)
52
+ dry-equalizer (~> 0.2)
53
+ dry-types (0.14.1)
54
+ concurrent-ruby (~> 1.0)
55
+ dry-container (~> 0.3)
56
+ dry-core (~> 0.4, >= 0.4.4)
57
+ dry-equalizer (~> 0.2)
58
+ dry-inflector (~> 0.1, >= 0.1.2)
59
+ dry-logic (~> 0.5, >= 0.5)
60
+ dry-validation (0.13.3)
61
+ concurrent-ruby (~> 1.0)
62
+ dry-configurable (~> 0.1, >= 0.1.3)
63
+ dry-core (~> 0.2, >= 0.2.1)
64
+ dry-equalizer (~> 0.2)
65
+ dry-logic (~> 0.5, >= 0.5.0)
66
+ dry-types (~> 0.14.0)
37
67
  equalizer (0.0.11)
38
68
  ethon (0.12.0)
39
69
  ffi (>= 1.3.0)
@@ -67,8 +97,8 @@ GEM
67
97
  thread_safe (0.3.6)
68
98
  typhoeus (1.4.0)
69
99
  ethon (>= 0.9.0)
70
- tzinfo (1.2.7)
71
- thread_safe (~> 0.1)
100
+ tzinfo (2.0.3)
101
+ concurrent-ruby (~> 1.0)
72
102
  vcr (3.0.3)
73
103
  virtus (1.0.5)
74
104
  axiom-types (~> 0.1)
@@ -79,7 +109,7 @@ GEM
79
109
  addressable (>= 2.3.6)
80
110
  crack (>= 0.3.2)
81
111
  hashdiff
82
- zeitwerk (2.4.0)
112
+ zeitwerk (2.4.2)
83
113
 
84
114
  PLATFORMS
85
115
  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,12 +14,8 @@ module PaxfulClient
19
14
  }
20
15
  end
21
16
 
22
- def body
23
- nonce = Time.now.to_i
24
- payload = "apikey=#{key}&nonce=#{nonce}"
25
- apiseal = OpenSSL::HMAC.hexdigest("SHA256", secret, payload)
26
-
27
- "apikey=#{key}&nonce=#{nonce}&apiseal=#{apiseal}"
17
+ def default_action
18
+ :post
28
19
  end
29
20
 
30
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,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.1.0"
2
+ VERSION = "1.2.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.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2020-12-16 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
@@ -127,7 +150,7 @@ metadata:
127
150
  homepage_uri: https://github.com/MarkFChavez/paxful_client-ruby
128
151
  source_code_uri: https://github.com/MarkFChavez/paxful_client-ruby
129
152
  changelog_uri: https://github.com/MarkFChavez/paxful_client-ruby
130
- post_install_message:
153
+ post_install_message:
131
154
  rdoc_options: []
132
155
  require_paths:
133
156
  - lib
@@ -142,9 +165,8 @@ 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
147
- signing_key:
168
+ rubygems_version: 3.0.3
169
+ signing_key:
148
170
  specification_version: 4
149
171
  summary: API wrapper for Paxful
150
172
  test_files: []
@@ -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