Class: Spree::Api::V2::Storefront::PinCodeOtpGeneratorsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Api::V2::Storefront::PinCodeOtpGeneratorsController
- Defined in:
- app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
:phone_number, :email, :type, :recaptcha_token, :recaptcha_action, :recaptcah_site_key.
- #otp_attrs ⇒ Object
- #resource_serializer ⇒ Object
- #serialize_resource(resource) ⇒ Object
Instance Method Details
#create ⇒ Object
:phone_number, :email, :type, :recaptcha_token, :recaptcha_action, :recaptcah_site_key
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 7 def create = otp_attrs [:type] = 'SpreeCmCommissioner::PinCodeOtp' context = SpreeCmCommissioner::PinCodeGenerator.call() if context.success? render_serialized_payload(201) { serialize_resource(context.pin_code) } else render_error_payload(context., 400) end end |
#otp_attrs ⇒ Object
30 31 32 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 30 def otp_attrs params.slice(:phone_number, :email) end |
#resource_serializer ⇒ Object
26 27 28 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 26 def resource_serializer SpreeCmCommissioner::V2::Storefront::PinCodeSerializer end |
#serialize_resource(resource) ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 20 def serialize_resource(resource) resource_serializer.new( resource ).serializable_hash end |