paxful_engine-rails 0.3.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -2
- data/app/controllers/paxful_engine/trades_controller.rb +1 -1
- data/app/models/paxful_engine/trade.rb +12 -0
- data/app/services/paxful_engine/create_trade.rb +6 -0
- data/app/views/paxful_engine/trades/index.html.erb +2 -0
- data/app/views/paxful_engine/trades/show.html.erb +4 -1
- data/lib/paxful_engine.rb +1 -0
- data/lib/paxful_engine/factories.rb +16 -0
- data/lib/paxful_engine/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1b07c79152a0e9d297bd7bd4e6895f3e594cd4b308028a4bc0a67ffe685075f
|
4
|
+
data.tar.gz: 880e805c345090fccc40d0555f4b07254d8375977693ff2f1228ffe79795e190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a8cafa05d39f5b146b5220032498c67cda837844653a47f5c649eca38e0011b01a8098b822d62b02cda45fb8c517e06c01e54a17a3177b96de04e8063dfc383
|
7
|
+
data.tar.gz: 1faf67ac478fc2b17a0b257be6486c3389749c867cc003de0ba37aff4abee9f08a4cc2dabb7fee60b9d48adce9336777b45c78391dae1cf41488fe08a468e56d
|
data/README.md
CHANGED
@@ -34,7 +34,8 @@ Create an initializer in your Rails application:
|
|
34
34
|
PaxfulEngine.configure do |c|
|
35
35
|
c.paxful_key = "your paxful key"
|
36
36
|
c.paxful_secret = "your paxful secret"
|
37
|
-
c.on_sync_callback = "
|
37
|
+
c.on_sync_callback = "SyncCallback"
|
38
|
+
c.on_failure_callback = "FailureCallback"
|
38
39
|
end
|
39
40
|
```
|
40
41
|
|
@@ -45,7 +46,7 @@ It accepts a `Trade` as its only argument.
|
|
45
46
|
|
46
47
|
```
|
47
48
|
# example
|
48
|
-
class
|
49
|
+
class SyncCallback
|
49
50
|
|
50
51
|
def self.call(trade)
|
51
52
|
# do anything you want with this record
|
@@ -54,6 +55,25 @@ class YourCallback
|
|
54
55
|
end
|
55
56
|
```
|
56
57
|
|
58
|
+
#### c.on_failure_callback
|
59
|
+
|
60
|
+
An object that responds to `call` that gets executed when a trade cannot be created.
|
61
|
+
|
62
|
+
It accepts two arguments:
|
63
|
+
- exception
|
64
|
+
- payload
|
65
|
+
|
66
|
+
```
|
67
|
+
# example
|
68
|
+
class FailureCallback
|
69
|
+
|
70
|
+
def self.call(e, payload)
|
71
|
+
# log somewhere...
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
57
77
|
### Usage
|
58
78
|
|
59
79
|
Add this to your scheduler somewhere:
|
@@ -24,6 +24,12 @@ module PaxfulEngine
|
|
24
24
|
end
|
25
25
|
|
26
26
|
trade
|
27
|
+
|
28
|
+
rescue => exception
|
29
|
+
if PaxfulEngine.configuration.on_failure_callback.present?
|
30
|
+
callback = PaxfulEngine.configuration.on_failure_callback
|
31
|
+
callback.constantize.(exception, payload)
|
32
|
+
end
|
27
33
|
end
|
28
34
|
|
29
35
|
end
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<thead>
|
7
7
|
<tr>
|
8
8
|
<th scope="col">Created</th>
|
9
|
+
<th scope="col">Completed</th>
|
9
10
|
<th scope="col">Trade hash</th>
|
10
11
|
<th scope="col">Type</th>
|
11
12
|
<th scope="col">Status</th>
|
@@ -24,6 +25,7 @@
|
|
24
25
|
<% @trades.each do |trade| %>
|
25
26
|
<tr scope="row">
|
26
27
|
<td> <%= trade.created_at.strftime("%m/%d/%Y %I:%M%p") %> </td>
|
28
|
+
<td> <%= trade.completed_at&.strftime("%m/%d/%Y %I:%M%p") || "-" %> </td>
|
27
29
|
<td> <%= trade.trade_hash %> </td>
|
28
30
|
<td> <%= trade.offer_type.upcase %> </td>
|
29
31
|
<td>
|
@@ -35,7 +35,10 @@
|
|
35
35
|
|
36
36
|
<hr />
|
37
37
|
|
38
|
-
<div>
|
38
|
+
<div>
|
39
|
+
<strong>Status:</strong>
|
40
|
+
<span class="<%= highlight_status(@trade) %>"> <%= @trade.status.upcase %> </span>
|
41
|
+
</div>
|
39
42
|
<div> <strong>Payment Method:</strong> <%= @trade.payment_method_name %> </div>
|
40
43
|
</div>
|
41
44
|
</div>
|
data/lib/paxful_engine.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
|
3
|
+
factory :paxful_engine_trade, class: "PaxfulEngine::Trade" do
|
4
|
+
trade_hash { "trade-hash" }
|
5
|
+
offer_hash { "offer-hash" }
|
6
|
+
offer_type { "buy" }
|
7
|
+
crypto_amount_requested { 0.05 }
|
8
|
+
crypto_currency_code { "BTC" }
|
9
|
+
fiat_amount_requested { 1_000 }
|
10
|
+
fiat_currency_code { "PHP" }
|
11
|
+
started_at { Time.current }
|
12
|
+
ended_at { Time.current + 2.days }
|
13
|
+
status { "successful" }
|
14
|
+
end
|
15
|
+
|
16
|
+
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: 0.
|
4
|
+
version: 0.7.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
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_config
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '2.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: factory_bot_rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: pry
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,6 +194,7 @@ files:
|
|
180
194
|
- lib/paxful_engine-rails.rb
|
181
195
|
- lib/paxful_engine.rb
|
182
196
|
- lib/paxful_engine/engine.rb
|
197
|
+
- lib/paxful_engine/factories.rb
|
183
198
|
- lib/paxful_engine/version.rb
|
184
199
|
- lib/tasks/paxful_engine_tasks.rake
|
185
200
|
homepage: https://github.com/bloom-solutions/paxful_engine-rails
|