mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
Pipeline: rename Location to City, wire postal code into breweries
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_POSTAL_CODE_MOCK_POSTAL_CODE_SERVICE_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_POSTAL_CODE_MOCK_POSTAL_CODE_SERVICE_H_
|
||||
|
||||
/**
|
||||
* @file services/postal_code/mock_postal_code_service.h
|
||||
* @brief Placeholder IPostalCodeService used until xeger-based generation is
|
||||
* implemented.
|
||||
*/
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "data_model/models.h"
|
||||
#include "services/postal_code/postal_code_service.h"
|
||||
|
||||
/**
|
||||
* @brief Postal code service that returns the location's first known
|
||||
* example postal code rather than generating one from its regex.
|
||||
*/
|
||||
class MockPostalCodeService final : public IPostalCodeService {
|
||||
public:
|
||||
std::string GeneratePostalCode(const City& location) override {
|
||||
if (location.postal_code_examples.empty()) {
|
||||
throw std::runtime_error(
|
||||
"MockPostalCodeService: location has no postal_code_examples: " +
|
||||
location.city);
|
||||
}
|
||||
return location.postal_code_examples.front();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_POSTAL_CODE_MOCK_POSTAL_CODE_SERVICE_H_
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_POSTAL_CODE_POSTAL_CODE_SERVICE_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_POSTAL_CODE_POSTAL_CODE_SERVICE_H_
|
||||
|
||||
/**
|
||||
* @file services/postal_code/postal_code_service.h
|
||||
* @brief Abstraction for generating a postal code for a location.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "data_model/models.h"
|
||||
|
||||
/**
|
||||
* @brief Interface for services that generate a postal code string matching
|
||||
* a location's postal code format (`City::postal_regex`).
|
||||
*/
|
||||
class IPostalCodeService {
|
||||
public:
|
||||
virtual ~IPostalCodeService() = default;
|
||||
|
||||
/**
|
||||
* @brief Generates a postal code for the given location.
|
||||
*
|
||||
* @param location Location whose postal code format to generate for.
|
||||
* @return A postal code string matching `location.postal_regex`.
|
||||
*/
|
||||
virtual std::string GeneratePostalCode(const City& location) = 0;
|
||||
};
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_POSTAL_CODE_POSTAL_CODE_SERVICE_H_
|
||||
Reference in New Issue
Block a user