Search in sources :

Example 6 with Entity

use of com.salesmanager.shop.model.entity.Entity in project shopizer by shopizer-ecommerce.

the class ProductApiV2 method createV2.

/**
 * ------------ V2
 *
 * --- product definition
 */
@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = { "/private/product/definition" })
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
@ResponseBody
public Entity createV2(@Valid @RequestBody PersistableProductDefinition product, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    // make sure product id is null
    product.setId(null);
    Long id = productDefinitionFacade.saveProductDefinition(merchantStore, product, language);
    Entity returnEntity = new Entity();
    returnEntity.setId(id);
    return returnEntity;
}
Also used : Entity(com.salesmanager.shop.model.entity.Entity) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Entity

use of com.salesmanager.shop.model.entity.Entity in project shopizer by shopizer-ecommerce.

the class TaxRateIntegrationTest method manageTaxClass.

@Test
public void manageTaxClass() throws Exception {
    // create tax class
    PersistableTaxClass taxClass = new PersistableTaxClass();
    taxClass.setCode("TESTTX");
    taxClass.setName("Test tax class");
    final HttpEntity<PersistableTaxClass> taxClassEntity = new HttpEntity<>(taxClass, getHeader());
    final ResponseEntity<Entity> response = testRestTemplate.postForEntity(String.format("/api/v1/private/tax/class/"), taxClassEntity, Entity.class);
    Entity e = response.getBody();
    assertNotNull(e.getId());
    assertTrue(e.getId() > 0);
    final HttpEntity<String> httpEntity = new HttpEntity<>(getHeader());
    // tax class exists
    final ResponseEntity<EntityExists> exists = testRestTemplate.exchange(String.format("/api/v1/private/tax/class/unique?code=" + taxClass.getCode()), HttpMethod.GET, httpEntity, EntityExists.class);
    assertTrue(exists.getBody().isExists());
/**
 *        //list 1 taxClass
 *        @SuppressWarnings("rawtypes")
 *		final ResponseEntity<ReadableEntityList> listOfTaxClasses = testRestTemplate.exchange(String.format("/private/tax/class"), HttpMethod.GET,
 *                httpEntity, ReadableEntityList.class);
 *
 *        assertTrue(listOfTaxClasses.getBody().getRecordsTotal() == 1);
 */
}
Also used : Entity(com.salesmanager.shop.model.entity.Entity) HttpEntity(org.springframework.http.HttpEntity) ResponseEntity(org.springframework.http.ResponseEntity) HttpEntity(org.springframework.http.HttpEntity) EntityExists(com.salesmanager.shop.model.entity.EntityExists) PersistableTaxClass(com.salesmanager.shop.model.tax.PersistableTaxClass) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 8 with Entity

use of com.salesmanager.shop.model.entity.Entity in project shopizer by shopizer-ecommerce.

the class ContentApi method createPage.

/**
 * Create content page
 * @param page
 * @param merchantStore
 * @param language
 */
@PostMapping(value = "/private/content/page")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(httpMethod = "POST", value = "Create content page", notes = "", response = Entity.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public Entity createPage(@RequestBody @Valid PersistableContentPage page, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    Long id = contentFacade.saveContentPage(page, merchantStore, language);
    Entity entity = new Entity();
    entity.setId(id);
    return entity;
}
Also used : ReadableContentEntity(com.salesmanager.shop.model.content.ReadableContentEntity) Entity(com.salesmanager.shop.model.entity.Entity) PersistableContentEntity(com.salesmanager.shop.model.content.PersistableContentEntity) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation)

Example 9 with Entity

use of com.salesmanager.shop.model.entity.Entity in project shopizer by shopizer-ecommerce.

the class ContentApi method createBox.

/**
 * Create content box
 *
 * @param page
 * @param merchantStore
 * @param language
 * @param pageCode
 */
@PostMapping(value = "/private/content/box")
@ResponseStatus(HttpStatus.CREATED)
@ApiOperation(httpMethod = "POST", value = "Create content box", notes = "", response = Entity.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public Entity createBox(@RequestBody @Valid PersistableContentBox box, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    Long id = contentFacade.saveContentBox(box, merchantStore, language);
    Entity entity = new Entity();
    entity.setId(id);
    return entity;
}
Also used : ReadableContentEntity(com.salesmanager.shop.model.content.ReadableContentEntity) Entity(com.salesmanager.shop.model.entity.Entity) PersistableContentEntity(com.salesmanager.shop.model.content.PersistableContentEntity) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation)

Example 10 with Entity

use of com.salesmanager.shop.model.entity.Entity in project shopizer by shopizer-ecommerce.

the class ProductApi method createV2.

/**
 * ------------ V2
 *
 * --- product definition
 */
@ResponseStatus(HttpStatus.CREATED)
@PostMapping(value = { "/v2/private/product/definition" })
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
@ResponseBody
public Entity createV2(@Valid @RequestBody PersistableProductDefinition product, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    // make sure product id is null
    product.setId(null);
    Long id = productDefinitionFacade.saveProductDefinition(merchantStore, product, language);
    Entity returnEntity = new Entity();
    returnEntity.setId(id);
    return returnEntity;
}
Also used : Entity(com.salesmanager.shop.model.entity.Entity) ResponseEntity(org.springframework.http.ResponseEntity) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Entity (com.salesmanager.shop.model.entity.Entity)10 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)6 ResponseEntity (org.springframework.http.ResponseEntity)5 PostMapping (org.springframework.web.bind.annotation.PostMapping)5 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)5 ApiOperation (io.swagger.annotations.ApiOperation)3 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)3 ServiceException (com.salesmanager.core.business.exception.ServiceException)2 PersistableContentEntity (com.salesmanager.shop.model.content.PersistableContentEntity)2 ReadableContentEntity (com.salesmanager.shop.model.content.ReadableContentEntity)2 EntityExists (com.salesmanager.shop.model.entity.EntityExists)2 PersistableTaxClass (com.salesmanager.shop.model.tax.PersistableTaxClass)2 PersistableTaxRate (com.salesmanager.shop.model.tax.PersistableTaxRate)2 OperationNotAllowedException (com.salesmanager.shop.store.api.exception.OperationNotAllowedException)2 ServiceRuntimeException (com.salesmanager.shop.store.api.exception.ServiceRuntimeException)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 HttpEntity (org.springframework.http.HttpEntity)2 TaxClass (com.salesmanager.core.model.tax.taxclass.TaxClass)1 TaxRate (com.salesmanager.core.model.tax.taxrate.TaxRate)1