Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Commit 04a634a

Browse files
committed
Do not load config by default
1 parent 1dad52d commit 04a634a

File tree

6 files changed

+72
-4
lines changed

6 files changed

+72
-4
lines changed

bin/create_invoice

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Bundler.require :default
55

66
require File.dirname(__FILE__) + "/../lib/bitpay-ruby"
77

8+
BitPayRuby::config = YAML.load_file(File.dirname(__FILE__) + "/../config/bitpay-ruby.yml")
9+
810
require "optparse"
911

1012
begin

bin/fetch_invoice

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Bundler.require :default
55

66
require File.dirname(__FILE__) + "/../lib/bitpay-ruby"
77

8+
BitPayRuby::config = YAML.load_file(File.dirname(__FILE__) + "/../config/bitpay-ruby.yml")
9+
810
require "optparse"
911

1012
begin

bin/receive_updates

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env ruby
2+
3+
require "bundler"
4+
Bundler.require :default
5+
6+
require File.dirname(__FILE__) + "/../lib/bitpay-ruby"
7+
8+
BitPayRuby::config = YAML.load_file(File.dirname(__FILE__) + "/../config/bitpay-ruby.yml")
9+
10+
require "optparse"
11+
12+
begin
13+
options = {}
14+
optparse = OptionParser.new do |opts|
15+
opts.banner = "Usage: #{$0} [options]"
16+
17+
# specify an API key
18+
opts.on("-a", "--api-key API_KEY", "Specify an API key.") do |api_key|
19+
options[:api_key] = api_key
20+
end
21+
opts.on("-r", "--receive", "Receive invoice status updates.") do
22+
exit
23+
end
24+
25+
# version
26+
opts.on("-v", "--version", "Show the version number.") do
27+
$stdout.puts "0.1.0"
28+
exit
29+
end
30+
31+
# help
32+
opts.on("-h", "--help", "Show this help message.") do
33+
$stdout.puts opts
34+
exit
35+
end
36+
end
37+
38+
optparse.parse!
39+
40+
require "sinatra"
41+
require "webrick/https"
42+
43+
class App < Sinatra::Base
44+
post "/" do
45+
params.to_json
46+
end
47+
end
48+
49+
webrick_options = {
50+
:server => "webrick",
51+
:Port => 8443,
52+
:SSLEnable => true,
53+
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
54+
:SSLCertificate => OpenSSL::X509::Certificate.new(File.open("./config/ssl-cert.pem").read),
55+
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.open("./config/ssl-key.pem").read),
56+
:SSLCertName => [ [ "CN",WEBrick::Utils::getservername ] ],
57+
:app => App
58+
}
59+
60+
Rack::Server.start webrick_options
61+
exit
62+
rescue BitPayRuby::BitPayRubyError => e
63+
$stderr.puts e.message
64+
exit e.status_code
65+
rescue Interrupt => e
66+
exit 1
67+
end

config/bitpay-ruby.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
api_endpoint: https://bitpay.com/api
2-
api_key:
2+
api_key:

lib/bitpay-ruby.rb

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ def connection
2222
end
2323
end
2424

25-
BitPayRuby::config = YAML.load_file(File.dirname(__FILE__) + "/../config/bitpay-ruby.yml")
26-
2725
require File.join File.dirname(__FILE__), "bitpay-ruby", "version"
2826
require File.join File.dirname(__FILE__), "bitpay-ruby", "logging"
2927

lib/bitpay-ruby/invoice.rb

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def create
2727
"price" => price,
2828
"currency" => currency
2929
}
30-
3130
update! response.body
3231
self
3332
end

0 commit comments

Comments
 (0)