paxful_engine-rails 1.0.0 → 1.1.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: ff9e8f4e220dc9d5141eb07a899fd2fbb88116f105ef030808b4436d7f600a38
4
- data.tar.gz: ad6e6e4092f4665871cd2a401105203a0bdb183b02368329d1c7254802d38821
3
+ metadata.gz: d3159a0488268a8e71de8b1f6692b7bded1cc237f8ba3a1e60da23b2ce9523e1
4
+ data.tar.gz: 528ea4f3abed5646fc83b30482f416bb6a8a3b8afa02025e59e52c2b9841e104
5
5
  SHA512:
6
- metadata.gz: 2bda9712a570a0bef6e11f1bdb6e06189d4983c56d32efa1280c5535d14c80cfedc5292ec3b34e68e9e20d9269197e9cc8889523afc73a96c8c041e519c80166
7
- data.tar.gz: 27da095e39ac9e7de6e816f5bd50d800622c32310af10499d7fd6248fd4d89a94bc68489d6eb0acf9627aae7bb04ef3ac327b1300794c4c74b1f9540027e5f7d
6
+ metadata.gz: e190fa283c6cc58a736169715aedf981f155b082f6299205a4043d51a3f089bf8d9e8d210142501e0d85dfc50f0bf608a2cfe87253e867b00a2f333ce05a9b51
7
+ data.tar.gz: 57334072919f7f8b55942318df624ac1100b7d6398745a328521fe998325270cf45f002fcfc854e1c3cc9043cf8a5ee4e03f774e0f4a3701b9f8abd49501de4f
@@ -1,23 +1,8 @@
1
1
  module PaxfulEngine
2
2
  class SyncOrderBookJob < ApplicationJob
3
3
 
4
- HOST = "https://paxful.com/api".freeze
5
-
6
4
  def perform
7
- client = PaxfulClient.new(
8
- host: HOST,
9
- key: PaxfulEngine.configuration.paxful_key,
10
- secret: PaxfulEngine.configuration.paxful_secret,
11
- )
12
-
13
- response = client.get_completed_trades
14
- return unless response.success?
15
-
16
- trades = response.parsed_body["data"]["trades"]
17
-
18
- trades.each do |payload|
19
- EnqueueCreateTradeJob.perform_async(payload)
20
- end
5
+ SyncOrderBook.()
21
6
  end
22
7
 
23
8
  end
@@ -0,0 +1,35 @@
1
+ module PaxfulEngine
2
+ class SyncOrderBook
3
+
4
+ HOST = "https://paxful.com/api".freeze
5
+ DEFAULT_PAGE = 1.freeze
6
+
7
+ def self.call(page: DEFAULT_PAGE, max_page: nil)
8
+ response = client.get_completed_trades(page: page)
9
+ return unless response.success?
10
+
11
+ trades = response.parsed_body["data"]["trades"]
12
+ return if trades.empty?
13
+
14
+ unsynced_trades = trades.select do |payload|
15
+ Trade.where(trade_hash: payload["trade_hash"]).none?
16
+ end
17
+ unsynced_trades.each { |payload| EnqueueCreateTradeJob.perform_async(payload) }
18
+
19
+ return if unsynced_trades.none?
20
+ return if max_page == page
21
+
22
+ self.(page: page + 1, max_page: max_page)
23
+ end
24
+
25
+ def self.client
26
+ PaxfulClient.new(
27
+ host: HOST,
28
+ key: PaxfulEngine.configuration.paxful_key,
29
+ secret: PaxfulEngine.configuration.paxful_secret,
30
+ )
31
+ end
32
+ private_class_method :client
33
+
34
+ end
35
+ end
@@ -1,3 +1,3 @@
1
1
  module PaxfulEngine
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paxful_engine-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Chavez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-19 00:00:00.000000000 Z
11
+ date: 2020-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.0'
33
+ version: '1.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.0'
40
+ version: '1.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +186,7 @@ files:
186
186
  - app/models/paxful_engine/application_record.rb
187
187
  - app/models/paxful_engine/trade.rb
188
188
  - app/services/paxful_engine/create_trade.rb
189
+ - app/services/paxful_engine/sync_order_book.rb
189
190
  - app/views/layouts/paxful_engine/application.html.erb
190
191
  - app/views/paxful_engine/trades/index.html.erb
191
192
  - app/views/paxful_engine/trades/show.html.erb
@@ -217,7 +218,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
218
  - !ruby/object:Gem::Version
218
219
  version: '0'
219
220
  requirements: []
220
- rubygems_version: 3.0.8
221
+ rubyforge_project:
222
+ rubygems_version: 2.7.6
221
223
  signing_key:
222
224
  specification_version: 4
223
225
  summary: Mountable engine that fetches completed paxful trades.