FINERACT-1760: Get office by external id
- [x] Add new resource to update - [x] Integration test
This commit is contained in:
committed by
Arnold Gálovics
parent
59c5ad4500
commit
f829eaa9d6
+3
@@ -22,6 +22,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import org.apache.fineract.infrastructure.core.config.MapstructMapperConfig;
|
||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.apache.fineract.organisation.office.data.OfficeData;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(config = MapstructMapperConfig.class)
|
||||
@@ -35,4 +36,6 @@ public interface OfficeSwaggerMapper {
|
||||
Optional.ofNullable(changes).map(c -> c.get("name")).ifPresent(c -> response.name = String.valueOf(c));
|
||||
return response;
|
||||
}
|
||||
|
||||
OfficesApiResourceSwagger.GetOfficesResponse toGetOfficesResponse(OfficeData officeData);
|
||||
}
|
||||
|
||||
+19
@@ -164,6 +164,25 @@ public class OfficesApiResource {
|
||||
return toApiJsonSerializer.serialize(settings, office, RESPONSE_DATA_PARAMETERS);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/external-id/{externalId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Operation(summary = "Retrieve an Office using external id", description = "Example Requests:\n" + "\n" + "offices/external-id/asd123\n"
|
||||
+ "\n" + "\n" + "offices/external-id/asd123?template=true\n" + "\n" + "\n"
|
||||
+ "offices/external-id/asd123?fields=id,name,parentName")
|
||||
public OfficesApiResourceSwagger.GetOfficesResponse retrieveOfficeByExternalId(
|
||||
@PathParam("externalId") @Parameter(description = "externalId") final String externalId, @Context final UriInfo uriInfo) {
|
||||
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
|
||||
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||
OfficeData office = readPlatformService.retrieveOfficeWithExternalId(ExternalIdFactory.produce(externalId));
|
||||
if (settings.isTemplate()) {
|
||||
final Collection<OfficeData> allowedParents = readPlatformService.retrieveAllowedParents(office.getId());
|
||||
office = OfficeData.appendedTemplate(office, allowedParents);
|
||||
}
|
||||
return officeSwaggerMapper.toGetOfficesResponse(office);
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{officeId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
|
||||
+6
-8
@@ -34,10 +34,6 @@ final class OfficesApiResourceSwagger {
|
||||
@Schema(description = "GetOfficesResponse")
|
||||
public static final class GetOfficesResponse {
|
||||
|
||||
private GetOfficesResponse() {
|
||||
|
||||
}
|
||||
|
||||
@Schema(example = "1")
|
||||
public Long id;
|
||||
@Schema(example = "Head Office")
|
||||
@@ -50,10 +46,12 @@ final class OfficesApiResourceSwagger {
|
||||
public LocalDate openingDate;
|
||||
@Schema(example = ".")
|
||||
public String hierarchy;
|
||||
// @Schema(example = "")
|
||||
// public Long parentId;
|
||||
// @Schema(example = "")
|
||||
// public String parentName;
|
||||
@Schema(example = "dd MMMM yyyy")
|
||||
public String dateFormat;
|
||||
@Schema(example = "en")
|
||||
public String locale;
|
||||
|
||||
public Collection<GetOfficesResponse> allowedParents;
|
||||
}
|
||||
|
||||
@Schema(description = "GetOfficesTemplateResponse")
|
||||
|
||||
Reference in New Issue
Block a user