Skip to content

Commit

Permalink
Make account_id optional in register_payment method
Browse files Browse the repository at this point in the history
- Updated the `register_payment` method to make `account_id` optional by setting its default value to `nil`.
- Added test cases for optional `account_id`
  • Loading branch information
brunoekferrari committed Oct 17, 2024
1 parent d8c97a1 commit f43d103
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/incognia_api/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def register_feedback(event:, occurred_at: nil, expires_at: nil, timestamp: nil,
response.success?
end

def register_payment(account_id:, request_token: nil, **opts)
def register_payment(account_id: nil, request_token: nil, **opts)
params = {
type: :payment,
account_id: account_id,
Expand Down
28 changes: 28 additions & 0 deletions spec/incognia_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,34 @@ module Incognia
it_behaves_like 'receiving one of the required tokens with account_id', :installation_id
it_behaves_like 'receiving one of the required tokens with account_id', :session_token

shared_examples_for 'receiving one of the required tokens without account_id' do |token_name|
let(:token_value) { SecureRandom.uuid }

it "hits the endpoint with #{token_name}" do
stub_token_request

stub = stub_payment_request.with(
body: {
type: 'payment',
token_name => token_value
},
headers: {
'Content-Type' => 'application/json', 'Authorization' => /Bearer.*/
}
)

api.register_payment(
token_name => token_value
)

expect(stub).to have_been_made.once
end
end

it_behaves_like 'receiving one of the required tokens without account_id', :request_token
it_behaves_like 'receiving one of the required tokens without account_id', :installation_id
it_behaves_like 'receiving one of the required tokens without account_id', :session_token

context 'when receiving any other optional arguments' do
shared_examples_for 'receiving optional args' do |optional_arguments|
it "hits the endpoint also with #{optional_arguments}" do
Expand Down

0 comments on commit f43d103

Please sign in to comment.