docproof 0.1.1 → 0.1.2
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 +4 -4
- data/README.md +17 -2
- data/lib/docproof/payment_processor.rb +6 -22
- data/lib/docproof/payment_processor/coinbase.rb +62 -0
- data/lib/docproof/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6753e45814c471fd45538ad16ed2dd3f76ce3da7
|
4
|
+
data.tar.gz: 7f287e56037d1f85fca9848140c115cb3df035cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3f4234ae8e928f18e0c485275b6cab51ccd0070b13f793d929a1beda7c601326d7d600582971892adb942fd9edf71f77d977aca9f2e6496af2bc40a571f1728
|
7
|
+
data.tar.gz: 491c3259452a4ab605a77a95776d602d422dcf9baf7ffa390923458db496b3a0d81e658fe94e9dce383a4e523c29397d6c761babd94ab0d3ad626601178893c3
|
data/README.md
CHANGED
@@ -30,7 +30,22 @@ and requires `coinbase/wallet`
|
|
30
30
|
```ruby
|
31
31
|
require 'coinbase/wallet`
|
32
32
|
|
33
|
-
docproof_document = Docproof::Document.new('y0urd0cum3nt5ha256h45h')
|
33
|
+
docproof_document = Docproof::Document.new('y0urd0cum3nt5ha256h45h')
|
34
|
+
docproof_document.register! && docproof_document.notarize!
|
35
|
+
```
|
36
|
+
|
37
|
+
You can also configure the Coinbase API Key and Secret like so:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require 'coinbase/wallet`
|
41
|
+
|
42
|
+
Docproof::PaymentProcessor::Coinbase.configure do |config|
|
43
|
+
config.api_key = 'YOUR-COINBASE-API-KEY'
|
44
|
+
config.api_secret = 'YOUR-COINBASE-API-SECRET'
|
45
|
+
end
|
46
|
+
|
47
|
+
docproof_document = Docproof::Document.new('y0urd0cum3nt5ha256h45h')
|
48
|
+
docproof_document.register! && docproof_document.notarize!
|
34
49
|
```
|
35
50
|
|
36
51
|
## Usage
|
@@ -59,4 +74,4 @@ The JSON response is stored in `Docproof::Document#response` and keys with the v
|
|
59
74
|
|
60
75
|
### Errors
|
61
76
|
|
62
|
-
If the request is not successful, the gem will raise an error. All errors are subclasses of `Docproof::
|
77
|
+
If the request is not successful, the gem will raise an error. All errors are subclasses of `Docproof::Error`.
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Docproof
|
2
2
|
class PaymentProcessor
|
3
|
+
require 'docproof/payment_processor/coinbase'
|
4
|
+
|
3
5
|
class MissingDependency < Error; end
|
4
6
|
class MissingCredentials < Error; end
|
5
7
|
|
@@ -19,28 +21,10 @@ module Docproof
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def perform!
|
22
|
-
|
23
|
-
|
24
|
-
amount:
|
25
|
-
|
26
|
-
)
|
24
|
+
Coinbase.new(
|
25
|
+
recipient: bitcoin_address,
|
26
|
+
amount: price_in_btc
|
27
|
+
).perform!
|
27
28
|
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def coinbase_wallet_primary_account
|
32
|
-
require 'coinbase/wallet'
|
33
|
-
|
34
|
-
Coinbase::Wallet::Client.new(
|
35
|
-
api_key: ENV.fetch('COINBASE_API_KEY'),
|
36
|
-
api_secret: ENV.fetch('COINBASE_API_SECRET')
|
37
|
-
).primary_account
|
38
|
-
rescue LoadError
|
39
|
-
raise MissingDependency,
|
40
|
-
'Coinbase is required, You can install it with: `gem install coinbase`'
|
41
|
-
rescue KeyError
|
42
|
-
raise MissingCredentials,
|
43
|
-
'Please set `COINBASE_API_KEY` and `COINBASE_API_SECRET` environment variables'
|
44
|
-
end
|
45
29
|
end
|
46
30
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Docproof
|
2
|
+
class PaymentProcessor
|
3
|
+
class Coinbase
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :api_key,
|
6
|
+
:api_secret
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@api_key = ENV['COINBASE_API_KEY']
|
10
|
+
@api_secret = ENV['COINBASE_API_SECRET']
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :recipient,
|
15
|
+
:amount
|
16
|
+
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Configuration.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.configuration=(config)
|
22
|
+
@configuration = config
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def self.configure
|
27
|
+
yield configuration
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(recipient:, amount:)
|
31
|
+
if !Coinbase.configuration.api_key || !Coinbase.configuration.api_secret
|
32
|
+
raise MissingCredentials, 'Coinbase API key and secret in not set'
|
33
|
+
end
|
34
|
+
|
35
|
+
@recipient = recipient
|
36
|
+
@amount = amount
|
37
|
+
end
|
38
|
+
|
39
|
+
def perform!
|
40
|
+
coinbase_wallet_primary_account.send(
|
41
|
+
to: recipient,
|
42
|
+
amount: amount,
|
43
|
+
currency: 'BTC'
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def coinbase_wallet_primary_account
|
50
|
+
require 'coinbase/wallet'
|
51
|
+
|
52
|
+
@coinbase_wallet_primary_account ||= ::Coinbase::Wallet::Client.new(
|
53
|
+
api_key: Coinbase.configuration.api_key,
|
54
|
+
api_secret: Coinbase.configuration.api_secret
|
55
|
+
).primary_account
|
56
|
+
rescue LoadError
|
57
|
+
raise MissingDependency,
|
58
|
+
'Coinbase is required, You can install it with: `gem install coinbase`'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/docproof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docproof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ikhsan Maulana
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/docproof/mocks/helper_methods.rb
|
128
128
|
- lib/docproof/mocks/proof_of_existence.rb
|
129
129
|
- lib/docproof/payment_processor.rb
|
130
|
+
- lib/docproof/payment_processor/coinbase.rb
|
130
131
|
- lib/docproof/version.rb
|
131
132
|
homepage: https://github.com/ixandidu/docproof
|
132
133
|
licenses:
|