Class: Spree::Api::V3::Store::Customer::AddressesController

Inherits:
ResourceController show all
Defined in:
app/controllers/spree/api/v3/store/customer/addresses_controller.rb

Constant Summary

Constants inherited from BaseController

BaseController::RATE_LIMIT_RESPONSE

Constants included from Idempotent

Idempotent::IDEMPOTENCY_HEADER, Idempotent::IDEMPOTENCY_TTL, Idempotent::MAX_KEY_LENGTH, Idempotent::MUTATING_METHODS

Constants included from ErrorHandler

ErrorHandler::ERROR_CODES

Constants included from JwtAuthentication

JwtAuthentication::JWT_AUDIENCE_ADMIN, JwtAuthentication::JWT_AUDIENCE_STORE, JwtAuthentication::JWT_ISSUER, JwtAuthentication::USER_TYPE_ADMIN, JwtAuthentication::USER_TYPE_CUSTOMER

Instance Method Summary collapse

Methods inherited from ResourceController

#destroy, #index, #show

Methods included from ApiKeyAuthentication

#authenticate_api_key!, #authenticate_secret_key!

Methods included from JwtAuthentication

#authenticate_user, #require_authentication!

Instance Method Details

#createObject

POST /api/v3/store/customers/me/addresses



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spree/api/v3/store/customer/addresses_controller.rb', line 11

def create
  result = Spree.address_create_service.call(
    address_params: permitted_params,
    user: current_user
  )

  if result.success?
    render json: serialize_resource(result.value), status: :created
  else
    render_errors(result.value.errors)
  end
end

#updateObject

PATCH /api/v3/store/customers/me/addresses/:id



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/spree/api/v3/store/customer/addresses_controller.rb', line 25

def update
  result = Spree.address_update_service.call(
    address: @resource,
    address_params: permitted_params
  )

  if result.success?
    render json: serialize_resource(result.value)
  else
    render_errors(result.value.errors)
  end
end