Package com.skava.web

Class AddressesController

java.lang.Object
com.skava.web.AddressesController

@RestController @RequestMapping("/users") public class AddressesController extends Object
This controller class which contains service end-points that are used to perform CRUD operations of user address resource. This controller class contains service end-points that are used to perform CRUD operations of user address that is used to create, update, get, getAll and delete.
Author:
Infosys Equinox
  • Constructor Details

    • AddressesController

      public AddressesController()
      Default Constructor.
  • Method Details

    • createUserAddress

      @PostMapping("/{userId}/addresses") @ResponseStatus(CREATED) @Audit(action="createAddress") public org.springframework.http.ResponseEntity<Addresses> createUserAddress(@PathVariable @AuditField(field="USER_ID") long userId, @Valid @RequestBody @AuditField(field="ADDRESS") @Valid Addresses address, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTION_ID") Long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId)
      This service end-point creates new address for the registered user, shipping address details will be captured in this object.
      Parameters:
      userId - Indicates the user identifier for which user the address needs to be created. Holds long value.
      address - Holds Addresses Holds the addresses details that needs to be created. It is given in the form of JSON object. An incorrect JSON would throw Bad request error.
      collectionId - This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.
      authToken - This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource.
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      storeId - It Holds a valid unique identifier of the store.Holds long value.
      Returns:
      The ResponseEntity of Addresses. Returns a user's address object
    • updateAddressService

      @PatchMapping("/{userId}/addresses/{addressId}") @Audit(action="updateAddress") public org.springframework.http.ResponseEntity<Addresses> updateAddressService(@PathVariable @AuditField(field="USER_ID") long userId, @PathVariable @AuditField(field="ADDRESS_ID") long addressId, @Valid @RequestBody @AuditField(field="ADDRESS") @Valid Addresses address, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTION_ID") Long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId)
      This service end point updates existing addresses for the registered user.
      Parameters:
      userId - Indicates the user identifier for which user the address needs to be updated. Holds long value.
      addressId - Indicates the address identifier for which address needs to be updated. Holds long value.
      address - Holds Addresses Holds the addresses details that needs to be updated.It is given in the form of JSON object. An incorrect JSON would throw Bad request error.
      collectionId - This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.
      authToken - This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      storeId - It Holds a valid unique identifier of the store.
      Returns:
      The ResponseEntity of Addresses. Returns a user's address object.
    • getAllAddressService

      @GetMapping("/{userId}/addresses") @Audit(action="getAddresses") public org.springframework.http.ResponseEntity<List<Addresses>> getAllAddressService(@PathVariable @AuditField(field="USER_ID") long userId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTION_ID") Long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="search",required=false,defaultValue="") @AuditField(field="FILTER") @DeIdentify String search, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId)
      This service end-point loads all available addresses for the requested user.
      Parameters:
      userId - Indicates the user identifier for which user the address needs to be loaded. Holds long value.
      collectionId - This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.
      authToken - This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      search - Holds String value for search criteria
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      storeId - It Holds a valid unique identifier of the store.
      Returns:
      The ResponseEntity of List of Addresses object. Returns a user's list of address object.
    • getAddressByIdService

      @GetMapping("/{userId}/addresses/{addressId}") @Audit(action="getAddress") public org.springframework.http.ResponseEntity<Addresses> getAddressByIdService(@PathVariable @AuditField(field="USER_ID") long userId, @PathVariable @AuditField(field="ADDRESS_ID") long addressId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTION_ID") Long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId)
      This service loads the requested address for the registered user.
      Parameters:
      userId - Indicates the user identifier for which user the address needs to be loaded. Holds long value.
      addressId - Indicates the address identifier for which address needs to be loaded. Holds long value.
      collectionId - This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.
      authToken - This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      storeId - It Holds a valid unique identifier of the store.
      Returns:
      The ResponseEntity of Addresses. Returns a user's address object.
    • deactivateAddressService

      @DeleteMapping("/{userId}/addresses/{addressId}") @Audit(action="deleteAddress") public org.springframework.http.ResponseEntity<Object> deactivateAddressService(@PathVariable @AuditField(field="USER_ID") long userId, @PathVariable @AuditField(field="ADDRESS_ID") long addressId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTION_ID") Long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId)
      This service deletes the requested address for the registered user.
      Parameters:
      userId - Indicates the identifier of a user for which user the address needs to be deleted. Holds long value.
      addressId - Id of address which need to be deleted. Holds long value.
      collectionId - This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.
      authToken - This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:
      • Token validation against the secret key
      • Expiry time should be in the future
      • Necessary privileges are available for the user to perform the action on the subjected resource
      locale - API Response and error messages will be responded in the locale mentioned in this parameter.
      version - It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.
      storeId - It Holds a valid unique identifier of the store.
      Returns:
      The ResponseEntity of Object.