File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 8
8
require 'auth0/api/v2/rules'
9
9
require 'auth0/api/v2/stats'
10
10
require 'auth0/api/v2/users'
11
+ require 'auth0/api/v2/users_by_email'
11
12
require 'auth0/api/v2/user_blocks'
12
13
require 'auth0/api/v2/tenants'
13
14
require 'auth0/api/v2/tickets'
@@ -28,6 +29,7 @@ module V2
28
29
include Auth0 ::Api ::V2 ::Rules
29
30
include Auth0 ::Api ::V2 ::Stats
30
31
include Auth0 ::Api ::V2 ::Users
32
+ include Auth0 ::Api ::V2 ::UsersByEmail
31
33
include Auth0 ::Api ::V2 ::UserBlocks
32
34
include Auth0 ::Api ::V2 ::Tenants
33
35
include Auth0 ::Api ::V2 ::Tickets
Original file line number Diff line number Diff line change
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the Users By Email endpoints
5
+ module UsersByEmail
6
+ attr_reader :users_by_email_path
7
+
8
+ # Retrieves a list of existing users by their email.
9
+ # @see https://auth0.com/docs/api/v2#!/Users/get_users
10
+ # @see https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email
11
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
12
+ # @param include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
13
+ # @param email [string] E-mail to be searched
14
+ #
15
+ # @return [json] Returns the list of existing users.
16
+ def users_by_email ( email , options = { } )
17
+ raise Auth0 ::InvalidParameter , 'Must supply a valid email' if email . to_s . empty?
18
+ request_params = {
19
+ fields : options . fetch ( :fields , nil ) ,
20
+ include_fields : options . fetch ( :include_fields , nil )
21
+ }
22
+ request_params [ :email ] = email
23
+ get ( users_by_email_path , request_params )
24
+ end
25
+
26
+ private
27
+
28
+ # Users By Emails API path
29
+ def users_by_email_path
30
+ @users_by_email_path ||= '/api/v2/users-by-email'
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+ describe Auth0 ::Api ::V2 ::UsersByEmail do
3
+ before :all do
4
+ dummy_instance = DummyClass . new
5
+ dummy_instance . extend ( Auth0 ::Api ::V2 ::UsersByEmail )
6
+ @instance = dummy_instance
7
+ end
8
+
9
+ context '.users_by_email' do
10
+ it { expect ( @instance ) . to respond_to ( :users_by_email ) }
11
+ it 'is expected to call /api/v2/users-by-email' do
12
+ expect ( @instance ) . to receive ( :get ) . with (
13
+ '/api/v2/users-by-email' ,
14
+ fields : nil ,
15
+ include_fields : nil ,
16
+ email : 'email'
17
+ )
18
+ expect { @instance . users_by_email ( 'email' ) } . not_to raise_error
19
+ end
20
+ end
21
+ end
You can’t perform that action at this time.
0 commit comments