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
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 11 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
34 35 36 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 34 def otp_attrs params.slice(:phone_number, :email) end |
#resource_serializer ⇒ Object
30 31 32 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 30 def resource_serializer SpreeCmCommissioner::V2::Storefront::PinCodeSerializer end |
#serialize_resource(resource) ⇒ Object
24 25 26 27 28 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_otp_generators_controller.rb', line 24 def serialize_resource(resource) resource_serializer.new( resource ).serializable_hash end |