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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4150cefcec59c38ceb8a97b03e3f266c691c051c
4
- data.tar.gz: 0ce2ca3659b30ac78487da2ba5a016270b31a206
3
+ metadata.gz: 6753e45814c471fd45538ad16ed2dd3f76ce3da7
4
+ data.tar.gz: 7f287e56037d1f85fca9848140c115cb3df035cd
5
5
  SHA512:
6
- metadata.gz: dd8ff23df2b4ac0175443478e5157c89b15a5161036887edebc80f3b18ad5a2a6e26ebca4f5398ac631710afe970d37e736a06bba891b5970bdb4f9cab8f39c9
7
- data.tar.gz: 9964dcf7b3d1d19cb4d48e1902602a41497eded31b40f10618d6c1a86e87135ef688c5ccdc1df2f56abcdcb35c2cb8be87c36487977706d37c14d6e3971542a8
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::Document::Errors`.
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
- coinbase_wallet_primary_account.send(
23
- to: bitcoin_address,
24
- amount: price_in_btc,
25
- currency: 'BTC'
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
@@ -1,3 +1,3 @@
1
1
  module Docproof
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-14 00:00:00.000000000 Z
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: