@@ -52,6 +52,27 @@ def delete_user(user_id:)
5252 make_request ( :delete , "users/#{ url_encode ( user_id ) } " )
5353 end
5454
55+ def query_users (
56+ username : nil ,
57+ email : nil ,
58+ phone_number : nil ,
59+ token : nil ,
60+ limit : nil ,
61+ last_evaluated_user_id : nil
62+ )
63+ params = {
64+ username : username ,
65+ email : email ,
66+ phoneNumber : phone_number ,
67+ token : token ,
68+ limit : limit &.to_s ,
69+ lastEvaluatedUserId : last_evaluated_user_id
70+ } . compact
71+
72+ path = params . empty? ? 'users' : "users?#{ URI . encode_www_form ( params ) } "
73+ make_request ( :get , path )
74+ end
75+
5576 def get_authenticators ( user_id :)
5677 make_request ( :get , "users/#{ url_encode ( user_id ) } /authenticators" )
5778 end
@@ -81,10 +102,131 @@ def get_action(user_id:, action:, idempotency_key:)
81102 make_request ( :get , "users/#{ url_encode ( user_id ) } /actions/#{ action } /#{ url_encode ( idempotency_key ) } " )
82103 end
83104
105+ def query_user_actions (
106+ user_id :,
107+ from_date : nil ,
108+ action_codes : [ ] ,
109+ state : nil
110+ )
111+ params = {
112+ fromDate : from_date ,
113+ codes : action_codes . empty? ? nil : action_codes . join ( ',' ) ,
114+ state : state
115+ } . compact
116+
117+ base_path = "users/#{ url_encode ( user_id ) } /actions"
118+ path = params . empty? ? base_path : "#{ base_path } ?#{ URI . encode_www_form ( params ) } "
119+ make_request ( :get , path )
120+ end
121+
84122 def update_action ( user_id :, action :, idempotency_key :, attributes :)
85123 make_request ( :patch , "users/#{ url_encode ( user_id ) } /actions/#{ action } /#{ url_encode ( idempotency_key ) } " , body : attributes )
86124 end
87125
126+ def challenge (
127+ verification_method :,
128+ action :,
129+ idempotency_key : nil ,
130+ user_id : nil ,
131+ email : nil ,
132+ phone_number : nil ,
133+ sms_channel : nil ,
134+ locale : nil ,
135+ device_id : nil ,
136+ ip_address : nil ,
137+ user_agent : nil ,
138+ custom : nil ,
139+ scope : nil
140+ )
141+ body = {
142+ verification_method : verification_method ,
143+ action : action ,
144+ idempotency_key : idempotency_key ,
145+ user_id : user_id ,
146+ email : email ,
147+ phone_number : phone_number ,
148+ sms_channel : sms_channel ,
149+ locale : locale ,
150+ device_id : device_id ,
151+ ip_address : ip_address ,
152+ user_agent : user_agent ,
153+ custom : custom ,
154+ scope : scope
155+ }
156+ make_request ( :post , 'challenge' , body : body )
157+ end
158+
159+ def verify ( challenge_id :, verification_code :)
160+ body = {
161+ challenge_id : challenge_id ,
162+ verification_code : verification_code
163+ }
164+ make_request ( :post , 'verify' , body : body )
165+ end
166+
167+ def claim_challenge (
168+ challenge_id :,
169+ user_id :,
170+ skip_verification_check : nil
171+ )
172+ body = {
173+ challenge_id : challenge_id ,
174+ user_id : user_id ,
175+ skip_verification_check : skip_verification_check
176+ }
177+ make_request ( :post , 'claim' , body : body )
178+ end
179+
180+ def get_challenge (
181+ challenge_id : nil ,
182+ user_id : nil ,
183+ action : nil ,
184+ verification_method : nil
185+ )
186+ params = { }
187+ params [ :challengeId ] = challenge_id if challenge_id
188+ params [ :userId ] = user_id if user_id
189+ params [ :action ] = action if action
190+ params [ :verificationMethod ] = verification_method if verification_method
191+
192+ query_string = URI . encode_www_form ( params ) unless params . empty?
193+ path = query_string ? "challenges?#{ query_string } " : 'challenges'
194+
195+ make_request ( :get , path )
196+ end
197+
198+ def create_session ( client_id :, token :, action : nil )
199+ body = {
200+ client_id : client_id ,
201+ token : token ,
202+ action : action
203+ } . compact
204+ make_request ( :post , 'sessions' , body : body )
205+ end
206+
207+ def validate_session ( access_token :, client_ids : nil )
208+ body = {
209+ access_token : access_token ,
210+ client_ids : client_ids
211+ } . compact
212+ make_request ( :post , 'sessions/validate' , body : body )
213+ end
214+
215+ def refresh_session ( refresh_token :)
216+ body = { refresh_token : refresh_token }
217+ make_request ( :post , 'sessions/refresh' , body : body )
218+ end
219+
220+ def revoke_session ( access_token :)
221+ body = { access_token : access_token }
222+ make_request ( :post , 'sessions/revoke' , body : body )
223+ end
224+
225+ def revoke_user_sessions ( user_id :)
226+ body = { user_id : user_id }
227+ make_request ( :post , 'sessions/user/revoke' , body : body )
228+ end
229+
88230 ##
89231 # TODO: delete identify?
90232 def identify ( user_id , user_payload )
0 commit comments