Skip to content

Commit 7d46547

Browse files
committed
Optionally accept client options in arguments
1 parent 134fb99 commit 7d46547

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

lib/drip/client.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class Client
1616

1717
attr_accessor :access_token, :api_key, :account_id
1818

19-
def initialize
19+
def initialize(options = {})
20+
@account_id = options[:account_id]
21+
@access_token = options[:access_token]
22+
@api_key = options[:api_key]
2023
yield(self) if block_given?
2124
end
2225

test/drip/client_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ class Drip::ClientTest < Drip::TestCase
2626

2727
assert_equal "1234567", client.account_id
2828
end
29+
30+
should "accept options via arguments" do
31+
client = Drip::Client.new(
32+
account_id: "1234567",
33+
api_key: "aaaa",
34+
access_token: "bbbb"
35+
)
36+
37+
assert_equal "1234567", client.account_id
38+
assert_equal "aaaa", client.api_key
39+
assert_equal "bbbb", client.access_token
40+
end
2941
end
3042

3143
context "#generate_resource" do

0 commit comments

Comments
 (0)