Skip to content

Commit

Permalink
Use compact to remove null parameters on assessments methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaswilliamgomes committed Aug 26, 2024
1 parent 482fecf commit 54b0612
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/incognia_api/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def initialize(client_id:, client_secret:)
end

def register_signup(request_token: nil, address: nil, **opts)
params = {}
params.merge!({ request_token: request_token }) if request_token
params = { request_token: request_token }.compact
params.merge!(opts)
params.merge!(address&.to_hash) if address

Expand All @@ -33,9 +32,9 @@ def register_signup(request_token: nil, address: nil, **opts)
def register_login(account_id:, request_token: nil, **opts)
params = {
type: :login,
account_id: account_id
}
params.merge!({ request_token: request_token }) if request_token
account_id: account_id,
request_token: request_token
}.compact
params.merge!(opts)

response = connection.request(
Expand Down Expand Up @@ -69,8 +68,11 @@ def register_feedback(event:, occurred_at: nil, expires_at: nil, timestamp: nil,
end

def register_payment(account_id:, request_token: nil, **opts)
params = { account_id: account_id, type: :payment }
params.merge!({ request_token: request_token }) if request_token
params = {
type: :payment,
account_id: account_id,
request_token: request_token
}.compact
params.merge!(opts)

response = connection.request(
Expand Down

0 comments on commit 54b0612

Please sign in to comment.