auth0 3.6.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +7 -0
  5. data/.travis.yml +12 -7
  6. data/CHANGELOG.md +10 -0
  7. data/Gemfile +4 -2
  8. data/Guardfile +13 -10
  9. data/LICENSE +2 -2
  10. data/README.md +9 -11
  11. data/Rakefile +33 -7
  12. data/auth0.gemspec +12 -12
  13. data/deploy_documentation.sh +29 -0
  14. data/doc_config/templates/default/fulldoc/html/css/full_list.css +79 -0
  15. data/doc_config/templates/default/fulldoc/html/css/style.css +546 -0
  16. data/doc_config/templates/default/layout/html/breadcrumb.erb +11 -0
  17. data/doc_config/templates/default/layout/html/footer.erb +115 -0
  18. data/doc_config/templates/default/layout/html/headers.erb +17 -0
  19. data/doc_config/templates/default/layout/html/layout.erb +27 -0
  20. data/lib/auth0.rb +5 -5
  21. data/lib/auth0/api/authentication_endpoints.rb +264 -46
  22. data/lib/auth0/api/v1.rb +5 -5
  23. data/lib/auth0/api/v1/clients.rb +7 -7
  24. data/lib/auth0/api/v1/connections.rb +9 -10
  25. data/lib/auth0/api/v1/logs.rb +9 -16
  26. data/lib/auth0/api/v1/rules.rb +5 -5
  27. data/lib/auth0/api/v1/users.rb +28 -27
  28. data/lib/auth0/api/v2.rb +17 -9
  29. data/lib/auth0/api/v2/blacklists.rb +30 -9
  30. data/lib/auth0/api/v2/clients.rb +60 -19
  31. data/lib/auth0/api/v2/connections.rb +63 -10
  32. data/lib/auth0/api/v2/emails.rb +58 -0
  33. data/lib/auth0/api/v2/jobs.rb +44 -7
  34. data/lib/auth0/api/v2/rules.rb +104 -0
  35. data/lib/auth0/api/v2/stats.rb +22 -5
  36. data/lib/auth0/api/v2/tenants.rb +39 -0
  37. data/lib/auth0/api/v2/tickets.rb +58 -0
  38. data/lib/auth0/api/v2/users.rb +128 -39
  39. data/lib/auth0/client.rb +8 -6
  40. data/lib/auth0/exception.rb +29 -23
  41. data/lib/auth0/mixins.rb +12 -10
  42. data/lib/auth0/mixins/httparty_proxy.rb +13 -10
  43. data/lib/auth0/mixins/initializer.rb +25 -27
  44. data/lib/auth0/version.rb +2 -2
  45. data/spec/integration/lib/auth0/api/v1/api_clients_spec.rb +2 -4
  46. data/spec/integration/lib/auth0/api/v1/api_users_spec.rb +25 -32
  47. data/spec/integration/lib/auth0/api/v2/api_blacklist_spec.rb +14 -0
  48. data/spec/integration/lib/auth0/api/v2/api_clients_spec.rb +61 -6
  49. data/spec/integration/lib/auth0/api/v2/api_connections_spec.rb +68 -42
  50. data/spec/integration/lib/auth0/api/v2/api_email_spec.rb +71 -0
  51. data/spec/integration/lib/auth0/api/v2/api_jobs_spec.rb +69 -0
  52. data/spec/integration/lib/auth0/api/v2/api_rules_spec.rb +83 -0
  53. data/spec/integration/lib/auth0/api/v2/api_stats_spec.rb +16 -0
  54. data/spec/integration/lib/auth0/api/v2/api_tenants_spec.rb +37 -0
  55. data/spec/integration/lib/auth0/api/v2/api_tickets_spec.rb +33 -0
  56. data/spec/integration/lib/auth0/api/v2/api_users_spec.rb +88 -36
  57. data/spec/integration/lib/auth0/auth0_client_spec.rb +43 -35
  58. data/spec/lib/auth0/api/authentication_endpoints_spec.rb +253 -47
  59. data/spec/lib/auth0/api/v1/clients_spec.rb +37 -38
  60. data/spec/lib/auth0/api/v1/connections_spec.rb +44 -38
  61. data/spec/lib/auth0/api/v1/logs_spec.rb +24 -24
  62. data/spec/lib/auth0/api/v1/rules_spec.rb +23 -22
  63. data/spec/lib/auth0/api/v1/users_spec.rb +153 -130
  64. data/spec/lib/auth0/api/v2/blacklists_spec.rb +12 -11
  65. data/spec/lib/auth0/api/v2/clients_spec.rb +38 -33
  66. data/spec/lib/auth0/api/v2/connections_spec.rb +59 -34
  67. data/spec/lib/auth0/api/v2/emails_spec.rb +47 -0
  68. data/spec/lib/auth0/api/v2/jobs_spec.rb +24 -10
  69. data/spec/lib/auth0/api/v2/rules_spec.rb +69 -0
  70. data/spec/lib/auth0/api/v2/stats_spec.rb +11 -11
  71. data/spec/lib/auth0/api/v2/tenants_spec.rb +25 -0
  72. data/spec/lib/auth0/api/v2/tickets_spec.rb +31 -0
  73. data/spec/lib/auth0/api/v2/users_spec.rb +101 -39
  74. data/spec/lib/auth0/client_spec.rb +46 -58
  75. data/spec/lib/auth0/mixins/httparty_proxy_spec.rb +98 -69
  76. data/spec/lib/auth0/mixins/initializer_spec.rb +2 -2
  77. data/spec/spec_helper.rb +2 -2
  78. data/spec/spec_helper_full.rb +16 -15
  79. data/spec/spec_helper_unit.rb +5 -5
  80. data/spec/support/credentials.rb +9 -3
  81. data/spec/support/dummy_class.rb +7 -1
  82. data/spec/support/dummy_class_for_proxy.rb +2 -2
  83. data/spec/support/import_users.json +13 -0
  84. data/spec/support/stub_response.rb +1 -2
  85. metadata +78 -41
@@ -1,26 +1,49 @@
1
1
  module Auth0
2
2
  module Api
3
3
  module V2
4
+ # Methods to use the connections endpoints
4
5
  module Connections
6
+ attr_reader :connections_path
7
+
8
+ # Retrieves every connection matching the specified strategy. All connections are retrieved if no strategy is
9
+ # being specified. Accepts a list of fields to include or exclude in the resulting list of connection objects.
10
+ # @see https://auth0.com/docs/api/v2#!/Connections/get_connections
11
+ # @param strategy [string] Provide a type of strategy to only retrieve connections with that strategy
12
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
13
+ # @param include_fields [boolean] if the fields specified are to be included in the result, false otherwise.
14
+ #
15
+ # @return [json] Returns the existing connections matching the strategy.
5
16
  def connections(strategy: nil, fields: nil, include_fields: true)
6
17
  request_params = {
7
18
  strategy: strategy,
8
19
  fields: fields,
9
20
  include_fields: include_fields
10
21
  }
11
- path = "/api/v2/connections"
12
- get(path, request_params)
22
+ get(connections_path, request_params)
13
23
  end
14
- alias :get_connections :connections
24
+ alias_method :get_connections, :connections
15
25
 
26
+ # Creates a new connection according to the JSON object received in body.
27
+ # @see https://auth0.com/docs/api/v2#!/Connections/post_connections
28
+ # @param body [hash] The Hash options used to define the conecctions's properties.
29
+ #
30
+ # @return [json] Returns the created connection.
16
31
  def create_connection(body)
17
- path = "/api/v2/connections"
32
+ fail Auth0::InvalidParameter, 'Must specify a body to create a connection' if body.to_s.empty?
18
33
  request_params = body
19
- post(path, request_params )
34
+ post(connections_path, request_params)
20
35
  end
21
36
 
37
+ # Retrieves a connection by its id.
38
+ # @see https://auth0.com/docs/api/v2#!/Connections/get_connections_by_id
39
+ # @param connection_id [string] The id of the connection to retrieve
40
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
41
+ # @param include_fields [boolean] if the fields specified are to be included in the result, false otherwise
42
+ #
43
+ # @return [json] Returns the matching connection
22
44
  def connection(connection_id, fields: nil, include_fields: true)
23
- path = "/api/v2/connections/" + connection_id.to_s
45
+ fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
46
+ path = "#{connections_path}/#{connection_id}"
24
47
  request_params = {
25
48
  fields: fields,
26
49
  include_fields: include_fields
@@ -28,17 +51,47 @@ module Auth0
28
51
  get(path, request_params)
29
52
  end
30
53
 
54
+ # Deletes a connection and all its users.
55
+ # @see https://auth0.com/docs/api/v2#!/Connections/delete_connections_by_id
56
+ # @param connection_id [string] The id of the connection to delete
31
57
  def delete_connection(connection_id)
32
- raise Auth0::MissingConnectionId, "you must specify a connection id" if connection_id.to_s.empty?
33
- path = "/api/v2/connections/#{connection_id}"
58
+ fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
59
+ path = "#{connections_path}/#{connection_id}"
60
+ delete(path)
61
+ end
62
+
63
+ # Deletes a specified connection user by its email (currently only database connections are supported and you
64
+ # cannot delete all users from specific connection).
65
+ # @see https://auth0.com/docs/api/v2#!/Connections/delete_users
66
+ # @param connection_id [string] The id of the connection
67
+ # @param user_email [string] The email of the user to delete
68
+ #
69
+ # @return [json] Returns the updated connection.
70
+ def delete_connection_user(connection_id, user_email)
71
+ fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
72
+ fail Auth0::InvalidParameter, 'Must supply a valid user email' if user_email.to_s.empty?
73
+ path = "#{connections_path}/#{connection_id}/users?email=#{user_email}"
34
74
  delete(path)
35
75
  end
36
76
 
77
+ # Updates a connection. Updates the fields specified in the body parameter.
78
+ # @see https://auth0.com/docs/api/v2#!/Connections/patch_connections_by_id
79
+ # @param connection_id [string] The id of the connection to delete
80
+ # @param body [hash] The Hash options used to update the conecctions's properties.
81
+ #
82
+ # @return [json] Returns the updated connection.
37
83
  def update_connection(connection_id, body)
38
- raise Auth0::MissingConnectionId, "you must specify a connection id" if connection_id.to_s.empty?
39
- path = "/api/v2/connections/" + connection_id.to_s
84
+ fail Auth0::InvalidParameter, 'Must supply a valid connection id' if connection_id.to_s.empty?
85
+ path = "#{connections_path}/#{connection_id}"
40
86
  patch(path, body)
41
87
  end
88
+
89
+ private
90
+
91
+ # Connections API path
92
+ def connections_path
93
+ @connections_path ||= '/api/v2/connections'
94
+ end
42
95
  end
43
96
  end
44
97
  end
@@ -0,0 +1,58 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the connections endpoints
5
+ module Emails
6
+ attr_reader :email_path
7
+
8
+ # Get all the email providers.
9
+ # @see https://auth0.com/docs/api/v2#!/Emails/get_provider
10
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
11
+ # @param include_fields [boolean] if the fields specified are to be included in the result, false otherwise.
12
+ #
13
+ # @return [json] Returns the existing email providers.
14
+ def get_provider(fields: nil, include_fields: nil)
15
+ request_params = {
16
+ fields: fields,
17
+ include_fields: include_fields
18
+ }
19
+ get(email_path, request_params)
20
+ end
21
+
22
+ # Configure a new email provider.
23
+ # @see https://auth0.com/docs/api/v2#!/Emails/post_provider
24
+ # @param body [hash] The Hash options used to spcify the email provider's properties.
25
+ #
26
+ # @return [json] Returns the created email provider.
27
+ def configure_provider(body)
28
+ fail Auth0::InvalidParameter, 'Must supply a valid body to create an email provider' if body.to_s.empty?
29
+ post(email_path, body)
30
+ end
31
+
32
+ # Deletes the configured email provider.
33
+ # @see https://auth0.com/docs/api/v2#!/Emails/delete_provider
34
+ #
35
+ # @return [json] Returns the created email provider.
36
+ def delete_provider
37
+ delete(email_path)
38
+ end
39
+
40
+ # Updates the configured email provider.
41
+ # @see https://auth0.com/docs/api/v2#!/Emails/patch_provider
42
+ # @param body [hash] The Hash options used to spcify the email provider's properties.
43
+ #
44
+ # @return [json] Returns the updated email provider.
45
+ def update_provider(body)
46
+ fail Auth0::InvalidParameter, 'Must supply a valid body to update an email provider' if body.to_s.empty?
47
+ patch(email_path, body)
48
+ end
49
+
50
+ private
51
+
52
+ def email_path
53
+ @email_path ||= '/api/v2/emails/provider'
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,18 +1,55 @@
1
1
  module Auth0
2
2
  module Api
3
3
  module V2
4
- # https://auth0.com/docs/apiv2#!/jobs
4
+ # Methods to use the jobs endpoints
5
5
  module Jobs
6
- #https://auth0.com/docs/apiv2#!/jobs/get_jobs_by_job_id
6
+ attr_reader :jobs_path
7
+
8
+ # Retrieves a job. Useful to check its status.
9
+ # @see https://auth0.com/docs/api/v2#!/Jobs/get_jobs_by_job_id
10
+ # @param job_id [string] The id of the job
11
+ #
12
+ # @return [json] the job status and properties
7
13
  def get_job(job_id)
8
- path = "/api/v2/jobs/#{job_id}"
14
+ fail Auth0::InvalidParameter, 'Must specify a job id' if job_id.to_s.empty?
15
+ path = "#{jobs_path}/#{job_id}"
9
16
  get(path)
10
17
  end
11
18
 
12
- # HTTParty doesn't support multipart upload, will move this functionality to a separate PR
13
- # https://auth0.com/docs/apiv2#!/jobs/post_users_imports
14
- def create_job(users_file, connection_name)
15
- raise NotImplementedError
19
+ # Imports users to a connection from a file using a long running job.
20
+ # Important: The documentation for the file format is at https://docs.auth0.com/bulk-import.
21
+ # @see https://auth0.com/docs/api/v2#!/Jobs/post_users_imports
22
+ # @param users_file [file] A file containing the users to import
23
+ # @param connection_id [string] The connection id of the connection to which users will be inserted
24
+ #
25
+ # @return [json] the job status and properties
26
+ def import_users(users_file, connection_id)
27
+ fail Auth0::InvalidParameter, 'Must specify a valid file' if users_file.to_s.empty?
28
+ fail Auth0::InvalidParameter, 'Must specify a connection_id' if connection_id.to_s.empty?
29
+ request_params = {
30
+ users: users_file,
31
+ connection_id: connection_id
32
+ }
33
+ path = "#{jobs_path}/users-imports"
34
+ post_file(path, request_params)
35
+ end
36
+
37
+ # Send an email to the specified user that asks them to click a link to verify their email address.
38
+ # @see https://auth0.com/docs/api/v2#!/Jobs/post_verification_email
39
+ # @param user_id [string] The user_id of the user to whom the email will be sent
40
+ #
41
+ # @return [json] the job status and properties
42
+ def send_verification_email(user_id)
43
+ fail Auth0::InvalidParameter, 'Must specify a user id' if user_id.to_s.empty?
44
+ path = "#{jobs_path}/verification-email"
45
+ post(path, user_id)
46
+ end
47
+
48
+ private
49
+
50
+ # Jobs API path
51
+ def jobs_path
52
+ @jobs_path ||= '/api/v2/jobs'
16
53
  end
17
54
  end
18
55
  end
@@ -0,0 +1,104 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the rules endpoints
5
+ module Rules
6
+ attr_reader :rules_path
7
+
8
+ # Retrieves a list of all rules. Accepts a list of fields to include or exclude.
9
+ # The enabled parameter can be specified to get enabled or disabled rules.
10
+ # The rule's stage of executing could be set to the following values login_success,
11
+ # login_failure or pre_authorize
12
+ # @see https://auth0.com/docs/api/v2#!/Rules/get_rules
13
+ # @param enabled [boolean] If provided retrieves rules that match the value, otherwise all rules are retrieved
14
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
15
+ # @param include_fields [boolean] If the fields specified are to be included in the result, false otherwise
16
+ # @param stage [string] Retrieves rules that match the execution stage (defaults to login_success)
17
+ #
18
+ # @return [json] Returns the existing rules.
19
+ def rules(enabled: nil, fields: nil, include_fields: nil, stage: nil)
20
+ request_params = {
21
+ enabled: enabled,
22
+ fields: fields,
23
+ include_fields: include_fields,
24
+ stage: stage
25
+ }
26
+ get(rules_path, request_params)
27
+ end
28
+
29
+ alias_method :get_rules, :rules
30
+
31
+ # Retrieves a rule by its ID. Accepts a list of fields to include or exclude in the result.
32
+ # @see https://auth0.com/docs/api/v2#!/Rules/get_rules_by_id
33
+ # @param rule_id [string] The id of the rule to retrieve
34
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
35
+ # @param include_fields [boolean] If the fields specified are to be included in the result, false otherwise
36
+ #
37
+ # @return [json] Returns the rule.
38
+ def rule(rule_id, fields: nil, include_fields: nil)
39
+ fail Auth0::InvalidParameter, 'Must supply a valid rule id' if rule_id.to_s.empty?
40
+ path = "#{rules_path}/#{rule_id}"
41
+ request_params = {
42
+ fields: fields,
43
+ include_fields: include_fields
44
+ }
45
+ get(path, request_params)
46
+ end
47
+
48
+ alias_method :get_rule, :rule
49
+
50
+ # Creates a new rule according to the JSON object received in body.
51
+ # @see https://auth0.com/docs/api/v2#!/Rules/post_rules
52
+ # @param name [string] The name of the rule. Can only contain alphanumeric characters, spaces and '-'.
53
+ # @param script [string] A script that contains the rule's code
54
+ # @param order [integer] The rule's order in relation to other rules. A rule with a lower order than another rule
55
+ # executes first. If no order is provided it will automatically be one greater than the current maximum
56
+ # @param enabled [string] true if the rule is enabled, false otherwise
57
+ # @param stage [string] The rule's execution stage 'login_success' or 'login_failure' or 'pre_authorize' or
58
+ # 'user_registration' or 'user_blocked'
59
+ #
60
+ # @return [json] Returns the rule.
61
+ def create_rule(name, script, order = nil, enabled = true, stage = 'login_success')
62
+ fail Auth0::InvalidParameter, 'Must supply a valid name' if name.to_s.empty?
63
+ fail Auth0::InvalidParameter, 'Must supply a valid script' if script.to_s.empty?
64
+ request_params = {
65
+ name: name,
66
+ enabled: enabled,
67
+ script: script,
68
+ order: order,
69
+ stage: stage
70
+ }
71
+ post(rules_path, request_params)
72
+ end
73
+
74
+ # Updates a rule.
75
+ # @see https://auth0.com/docs/api/v2#!/Rules/patch_rules_by_id
76
+ # @param rule_id [string] The id of the rule to retrieve
77
+ # @param fields_to_update [hash] The Hash fields_to_update used to define the rule's properties.
78
+ # @return [json] Returns the updated rule.
79
+ def update_rule(rule_id, fields_to_update = {})
80
+ fail Auth0::InvalidParameter, 'Must supply a valid rule id' if rule_id.to_s.empty?
81
+
82
+ path = "#{rules_path}/#{rule_id}"
83
+ patch(path, fields_to_update)
84
+ end
85
+
86
+ # Deletes a rule.
87
+ # @see https://auth0.com/docs/api/v2#!/Rules/delete_rules_by_id
88
+ # @param rule_id [string] The id of the rule to retrieve
89
+ def delete_rule(rule_id)
90
+ fail Auth0::InvalidParameter, 'Must supply a valid rule id' if rule_id.to_s.empty?
91
+ path = "#{rules_path}/#{rule_id}"
92
+ delete(path)
93
+ end
94
+
95
+ private
96
+
97
+ # Rules API path
98
+ def rules_path
99
+ @rules_path ||= '/api/v2/rules'
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
@@ -1,23 +1,40 @@
1
1
  module Auth0
2
2
  module Api
3
3
  module V2
4
- # https://auth0.com/docs/apiv2#!/stats
4
+ # Methods to use the stats endpoints
5
5
  module Stats
6
- #https://auth0.com/docs/apiv2#!/stats/get_active_users
6
+ attr_reader :stats_path
7
+
8
+ # Gets the active users count (logged in during the last 30 days).
9
+ # @see https://auth0.com/docs/api/v2#!/Stats/get_active_users
10
+ #
11
+ # @return [integer] Returns numbers
7
12
  def active_users
8
- path = "/api/v2/stats/active-users"
13
+ path = "#{stats_path}/active-users"
9
14
  get(path)
10
15
  end
11
16
 
12
- #https://auth0.com/docs/apiv2#!/stats/get_daily
17
+ # Gets the daily stats for a particular period.
18
+ # @see https://auth0.com/docs/api/v2#!/Stats/get_daily
19
+ # @param from [string] The first day of the period (inclusive) in YYYYMMDD format.
20
+ # @param to [string] The last day of the period (inclusive) in YYYYMMDD format.
21
+ #
22
+ # @return [json] Returns the daily stats.
13
23
  def daily_stats(from, to)
14
- path = "/api/v2/stats/daily"
24
+ path = "#{stats_path}/daily"
15
25
  request_params = {
16
26
  from: from,
17
27
  to: to
18
28
  }
19
29
  get(path, request_params)
20
30
  end
31
+
32
+ private
33
+
34
+ # Stats API path
35
+ def stats_path
36
+ @stats_path ||= '/api/v2/stats'
37
+ end
21
38
  end
22
39
  end
23
40
  end
@@ -0,0 +1,39 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the Tenants endpoints
5
+ module Tenants
6
+ attr_reader :tenant_path
7
+
8
+ # Gets tenants settings.
9
+ # @see https://auth0.com/docs/api/v2#!/Tenants/get_settings
10
+ # @param fields [string] A comma separated list of fields to include or exclude from the result.
11
+ # @param include_fields [boolean] If the fields specified are to be included in the result, false otherwise
12
+ # @return [json] Returns tenants settings.
13
+ def get_tenant_settings(fields: nil, include_fields: true)
14
+ request_params = {
15
+ fields: fields,
16
+ include_fields: include_fields
17
+ }
18
+ get(tenant_path, request_params)
19
+ end
20
+
21
+ # Updates tenants settings.
22
+ # @see https://auth0.com/docs/api/v2#!/Tenants/patch_settings
23
+ # @param body [hash] The Hash body used to define the tenants settings's properties.
24
+ # @return [json] Returns updated tenants settings.
25
+ def update_tenant_settings(body)
26
+ fail Auth0::InvalidParameter, 'Must supply a valid body to update tenant settings' if body.to_s.empty?
27
+ patch(tenant_path, body)
28
+ end
29
+
30
+ private
31
+
32
+ # Tenants settings API path
33
+ def tenant_path
34
+ @tenant_path ||= '/api/v2/tenants/settings'
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,58 @@
1
+ module Auth0
2
+ module Api
3
+ module V2
4
+ # Methods to use the tickets endpoints
5
+ module Tickets
6
+ attr_reader :tickets_path
7
+
8
+ # Create an email verification ticket
9
+ # @see https://auth0.com/docs/api/v2#!/Tickets/post_email_verification
10
+ # @param user_id [string] The user_id of for which the ticket is to be created
11
+ # @param result_url [string] The user will be redirected to this endpoint once the ticket is used
12
+ # @return [json] Returns ticket url
13
+ def post_email_verification(user_id, result_url: nil)
14
+ if user_id.to_s.empty?
15
+ fail Auth0::InvalidParameter, 'Must supply a valid user id to post an email verification'
16
+ end
17
+ path = "#{tickets_path}/email-verification"
18
+ request_params = {
19
+ user_id: user_id,
20
+ result_url: result_url
21
+ }
22
+ post(path, request_params)
23
+ end
24
+
25
+ # Create a password change ticket
26
+ # @see https://auth0.com/docs/api/v2#!/Tickets/post_password_change
27
+ # @param new_password [string] The password to set for the user once the ticket is used
28
+ # @param user_id [string] The user_id of for which the ticket is to be created
29
+ # @param result_url [string] The user will be redirected to this endpoint once the ticket is used
30
+ # @param connection_id [string] The connection that provides the identity for which the password is to be
31
+ # changed. If sending this parameter, the email is also required and the user_id is invalid
32
+ # @param email [string] The user's email
33
+ # @return [json] Returns ticket url
34
+ def post_password_change(new_password, user_id: nil, result_url: nil, connection_id: nil, email: nil)
35
+ if new_password.to_s.empty?
36
+ fail Auth0::InvalidParameter, 'Must supply a valid new password to post a password-change'
37
+ end
38
+ path = "#{tickets_path}/password-change"
39
+ request_params = {
40
+ user_id: user_id,
41
+ result_url: result_url,
42
+ new_password: new_password,
43
+ connection_id: connection_id,
44
+ email: email
45
+ }
46
+ post(path, request_params)
47
+ end
48
+
49
+ private
50
+
51
+ # Tickets API path
52
+ def tickets_path
53
+ @tickets_path ||= '/api/v2/tickets'
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end