Class: Stormpath::Rails::ResendEmailVerification

Inherits:
Object
  • Object
show all
Defined in:
app/services/stormpath/rails/resend_email_verification.rb

Constant Summary collapse

PROPERTY_VALUE_DOES_NOT_MATCH_A_STORMPATH_RESOURCE_CODE =
2016
NoEmailError =
Class.new(ArgumentError)
UnexistingEmailError =
Class.new(ArgumentError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(email, account_store = nil) ⇒ ResendEmailVerification

Returns a new instance of ResendEmailVerification.

Raises:



8
9
10
11
12
# File 'app/services/stormpath/rails/resend_email_verification.rb', line 8

def initialize(email,  = nil)
  raise(NoEmailError, 'Email parameter not provided.') if email.blank?
  @email = email
  @account_store = 
end

Instance Attribute Details

#account_storeObject (readonly)

Returns the value of attribute account_store.



6
7
8
# File 'app/services/stormpath/rails/resend_email_verification.rb', line 6

def 
  @account_store
end

#emailObject (readonly)

Returns the value of attribute email.



6
7
8
# File 'app/services/stormpath/rails/resend_email_verification.rb', line 6

def email
  @email
end

Instance Method Details

#applicationObject



33
34
35
# File 'app/services/stormpath/rails/resend_email_verification.rb', line 33

def application
  Stormpath::Rails::Client.application
end

#callObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/stormpath/rails/resend_email_verification.rb', line 14

def call
  begin
    application.verification_emails.create(email_verification_params)
  rescue Stormpath::Error => error
    if error.code == PROPERTY_VALUE_DOES_NOT_MATCH_A_STORMPATH_RESOURCE_CODE
      raise UnexistingEmailError, error.message
    else
      raise
    end
  end
end

#email_verification_paramsObject



26
27
28
29
30
31
# File 'app/services/stormpath/rails/resend_email_verification.rb', line 26

def email_verification_params
  {}.tap do |body|
    body[:login] = email
    body[:account_store] = { name_key: .name_key } if .present?
  end
end