Class: Spree::Api::V2::Storefront::PinCodeGeneratorsController
- Inherits:
-
ResourceController
- Object
- ResourceController
- Spree::Api::V2::Storefront::PinCodeGeneratorsController
- Defined in:
- app/controllers/spree/api/v2/storefront/pin_code_generators_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
:phone_number, :email, :type, :tenant.
- #resource_serializer ⇒ Object
- #serialize_resource(resource) ⇒ Object
- #validate_recaptcha ⇒ Object
Instance Method Details
#create ⇒ Object
:phone_number, :email, :type, :tenant
23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_generators_controller.rb', line 23 def create context = SpreeCmCommissioner::PinCodeGenerator.call(pin_code_attrs) if context.success? render_serialized_payload(201) { serialize_resource(context.pin_code) } else render_error_payload(context., 400) end end |
#resource_serializer ⇒ Object
39 40 41 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_generators_controller.rb', line 39 def resource_serializer SpreeCmCommissioner::V2::Storefront::PinCodeSerializer end |
#serialize_resource(resource) ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_generators_controller.rb', line 33 def serialize_resource(resource) resource_serializer.new( resource ).serializable_hash end |
#validate_recaptcha ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/spree/api/v2/storefront/pin_code_generators_controller.rb', line 8 def validate_recaptcha return unless ENV['RECAPTCHA_TOKEN_VALIDATOR_ENABLE'] == 'yes' context = SpreeCmCommissioner::RecaptchaTokenValidator.call( token: params[:recaptcha_token], action: params[:recaptcha_action], site_key: params[:recaptcah_site_key] ) return if context.success? render_error_payload(context., 400) end |