Search in sources :

Example 1 with EntityExists

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

the class TaxRateIntegrationTest method manageTaxRates.

@Test
public void manageTaxRates() throws Exception {
    // create tax class
    PersistableTaxRate taxRate = new PersistableTaxRate();
    taxRate.setCode("taxcode1");
    taxRate.setCountry("US");
    taxRate.setPriority(0);
    taxRate.setRate(new BigDecimal(5));
    taxRate.setStore("DEFAULT");
    taxRate.setTaxClass("DEFAULT");
    taxRate.setZone("NY");
    // descriptions
    TaxRateDescription en = new TaxRateDescription();
    en.setLanguage("en");
    en.setName("TaxCode1EN");
    en.setDescription("TaxCode1EN description");
    TaxRateDescription fr = new TaxRateDescription();
    fr.setLanguage("fr");
    fr.setName("TaxCode1FR");
    fr.setDescription("TaxCode1fr description");
    taxRate.getDescriptions().add(en);
    taxRate.getDescriptions().add(fr);
    final HttpEntity<PersistableTaxRate> taxClassEntity = new HttpEntity<>(taxRate, getHeader());
    final ResponseEntity<Entity> response = testRestTemplate.postForEntity(String.format("/api/v1/private/tax/rate/"), 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/rate/unique?code=" + taxRate.getCode()), HttpMethod.GET, httpEntity, EntityExists.class);
    assertTrue(exists.getBody().isExists());
}
Also used : TaxRateDescription(com.salesmanager.shop.model.tax.TaxRateDescription) 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) PersistableTaxRate(com.salesmanager.shop.model.tax.PersistableTaxRate) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with EntityExists

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

the class ContentApi method boxExists.

@GetMapping(value = "/private/content/box/{code}/exists")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(httpMethod = "GET", value = "Check unique content box", notes = "", response = EntityExists.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public EntityExists boxExists(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    boolean exists = contentFacade.codeExist(code, BOX, merchantStore);
    EntityExists entity = new EntityExists(exists);
    return entity;
}
Also used : EntityExists(com.salesmanager.shop.model.entity.EntityExists) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with EntityExists

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

the class ContentApi method pageExists.

@GetMapping(value = "/private/content/page/{code}/exists")
@ResponseStatus(HttpStatus.OK)
@ApiOperation(httpMethod = "GET", value = "Check unique content page", notes = "", response = EntityExists.class)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "String", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "String", defaultValue = "en") })
public EntityExists pageExists(@PathVariable String code, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    boolean exists = contentFacade.codeExist(code, PAGE, merchantStore);
    EntityExists entity = new EntityExists(exists);
    return entity;
}
Also used : EntityExists(com.salesmanager.shop.model.entity.EntityExists) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with EntityExists

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

the class ProductInstanceApi method exists.

@ResponseStatus(HttpStatus.OK)
@GetMapping(value = { "/private/product/{id}/instance/{sku}/unique" }, produces = MediaType.APPLICATION_JSON_VALUE)
@ApiImplicitParams({ @ApiImplicitParam(name = "store", dataType = "string", defaultValue = "DEFAULT"), @ApiImplicitParam(name = "lang", dataType = "string", defaultValue = "en") })
@ApiOperation(httpMethod = "GET", value = "Check if option set code already exists", notes = "", response = EntityExists.class)
@ResponseBody
public ResponseEntity<EntityExists> exists(@PathVariable Long id, @RequestParam(value = "code") String sku, @ApiIgnore MerchantStore merchantStore, @ApiIgnore Language language) {
    String authenticatedUser = userFacade.authenticatedUser();
    if (authenticatedUser == null) {
        throw new UnauthorizedException();
    }
    userFacade.authorizedGroup(authenticatedUser, Stream.of(Constants.GROUP_SUPERADMIN, Constants.GROUP_ADMIN, Constants.GROUP_ADMIN_CATALOGUE, Constants.GROUP_ADMIN_RETAIL).collect(Collectors.toList()));
    boolean exist = productInstanceFacade.exists(sku, merchantStore, id, language);
    return new ResponseEntity<EntityExists>(new EntityExists(exist), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) UnauthorizedException(com.salesmanager.shop.store.api.exception.UnauthorizedException) EntityExists(com.salesmanager.shop.model.entity.EntityExists) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(io.swagger.annotations.ApiOperation) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with EntityExists

use of com.salesmanager.shop.model.entity.EntityExists 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)

Aggregations

EntityExists (com.salesmanager.shop.model.entity.EntityExists)5 ApiImplicitParams (io.swagger.annotations.ApiImplicitParams)3 ApiOperation (io.swagger.annotations.ApiOperation)3 ResponseEntity (org.springframework.http.ResponseEntity)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 Entity (com.salesmanager.shop.model.entity.Entity)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 HttpEntity (org.springframework.http.HttpEntity)2 PersistableTaxClass (com.salesmanager.shop.model.tax.PersistableTaxClass)1 PersistableTaxRate (com.salesmanager.shop.model.tax.PersistableTaxRate)1 TaxRateDescription (com.salesmanager.shop.model.tax.TaxRateDescription)1 UnauthorizedException (com.salesmanager.shop.store.api.exception.UnauthorizedException)1 BigDecimal (java.math.BigDecimal)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1