Skip to content

Commit

Permalink
feat!: renames User class and other function argument names (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
ctran88 committed Jan 2, 2025
1 parent d031054 commit 7988bec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/passageidentity/client.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

require_relative 'auth'
require_relative 'user_api'
require_relative 'user'
require_relative 'version'

module Passage
Expand Down Expand Up @@ -30,7 +30,7 @@ def initialize(app_id:, api_key:)
req_opts[:debug_auth_names] = ['header']

@auth = Passage::Auth.new(app_id: app_id, req_opts: req_opts)
@user = Passage::UserAPI.new(app_id: app_id, req_opts: req_opts)
@user = Passage::User.new(app_id: app_id, req_opts: req_opts)
end
end
end
10 changes: 5 additions & 5 deletions lib/passageidentity/user_api.rb → lib/passageidentity/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
require_relative '../openapi_client'

module Passage
# The UserAPI class provides methods for interacting with Passage Users
class UserAPI
# The User class provides methods for interacting with Passage Users
class User
def initialize(app_id:, req_opts:)
@app_id = app_id
@req_opts = req_opts
Expand All @@ -28,11 +28,11 @@ def get(user_id:)
end
end

def get_by_identifier(user_identifier:)
raise ArgumentError, 'identifier is required.' unless user_identifier && !user_identifier.empty?
def get_by_identifier(identifier:)
raise ArgumentError, 'identifier is required.' unless identifier && !identifier.empty?

begin
req_opts = set_get_by_identifier_query_params(identifier: user_identifier)
req_opts = set_get_by_identifier_query_params(identifier: identifier)
response = @user_client.list_paginated_users(@app_id, req_opts)
rescue Faraday::Error => e
raise PassageError.new(
Expand Down
12 changes: 6 additions & 6 deletions tests/user_api_test.rb → tests/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

Dotenv.load('.env')

# This is a test suite for the Passage User API using the Test::Unit framework.
class TestUserAPI < Test::Unit::TestCase
# This is a test suite for the Passage User using the Test::Unit framework.
class TestUser < Test::Unit::TestCase
PassageClient = Passage::Client.new(app_id: ENV['APP_ID'], api_key: ENV['API_KEY'])

def setup
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_get_user_by_identifier
user = PassageClient.user.get(user_id: @test_user.id)
assert_equal @test_user.id, user.id

user_by_identifier = PassageClient.user.get_by_identifier(user_identifier: @test_user.email)
user_by_identifier = PassageClient.user.get_by_identifier(identifier: @test_user.email)
assert_equal @test_user.id, user_by_identifier.id

assert_equal user, user_by_identifier
Expand All @@ -55,7 +55,7 @@ def test_get_user_by_identifier_upper_case
user = PassageClient.user.get(user_id: @test_user.id)
assert_equal @test_user.id, user.id

user_by_identifier = PassageClient.user.get_by_identifier(user_identifier: @test_user.email.upcase)
user_by_identifier = PassageClient.user.get_by_identifier(identifier: @test_user.email.upcase)
assert_equal @test_user.id, user_by_identifier.id

assert_equal user, user_by_identifier
Expand All @@ -70,7 +70,7 @@ def test_get_user_by_identifier_phone
user = PassageClient.user.get(user_id: create_user.id)
assert_equal create_user.id, user.id

user_by_identifier = PassageClient.user.get_by_identifier(user_identifier: phone)
user_by_identifier = PassageClient.user.get_by_identifier(identifier: phone)
assert_equal create_user.id, user_by_identifier.id

assert_equal user, user_by_identifier
Expand All @@ -81,7 +81,7 @@ def test_invalid_get_by_identifier
assert_equal @test_user.id, user.id

assert_raise Passage::PassageError do
PassageClient.user.get_by_identifier(user_identifier: '[email protected]')
PassageClient.user.get_by_identifier(identifier: '[email protected]')
end
end

Expand Down

0 comments on commit 7988bec

Please sign in to comment.