Skip to content

Add shortcut for basic_auth #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/api_struct/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def self.method_missing(method_name, *args, &block)
define_method(:headers) do
endpoints[method_name][:headers]
end

define_method(:basic_auth) do
endpoints[method_name][:basic_auth]
end
end

HTTP_METHODS = %i[get post patch put delete].freeze
Expand All @@ -38,6 +42,7 @@ def initialize
api_settings_exist
client_headers = headers || DEFAULT_HEADERS
@client = HTTP::Client.new(headers: client_headers)
@client = @client.basic_auth(basic_auth) if basic_auth
end

private
Expand Down