Skip to main content

Module mapping

Module mapping 

Source
Expand description

Promotion helpers from quarantined Gingr records into source-agnostic candidates.

Mapping code may read Gingr-shaped DTOs, but the values it returns are domain candidates plus caller-owned source refs. Provider ids stay inside this adapter; the domain does not learn Gingr vocabulary.

use std::collections::BTreeMap;

use domain::source;
use gingr::{endpoint, mapping, response};

let provider_record = response::OwnerRecord {
    id: endpoint::OwnerId::new(501),
    first_name: Some("Sam".to_owned()),
    last_name: Some("Rivera".to_owned()),
    email: Some(response::provider::Email::new("sam@example.test")),
    cell_phone: None,
    unknown: BTreeMap::new(),
};

let source_ref = source::RecordRef::new(
    source::System::Gingr,
    source::record::Id::try_new(provider_record.id.to_string())?,
);
let promoted = mapping::customer::contact_candidate(&provider_record)?;

assert_eq!(source_ref.system(), source::System::Gingr);
assert_eq!(source_ref.record_id().as_str(), "501");
assert_eq!(promoted.provider_owner_id, endpoint::OwnerId::new(501));
assert!(promoted.email.is_some());

Modules§

customer
Customer mapper that turns a Gingr owner record into a reviewable domain contact candidate.
pet
Pet mapper that turns a Gingr animal record into a reviewable domain pet-name candidate.
retail
Retail mapper that turns a Gingr item DTO into a reviewable domain product candidate.

Enums§

Error
Errors raised when Gingr records are missing fields or fail domain validation during mapping.
ProviderField
Gingr fields required by DTO-to-domain mapping routines.

Type Aliases§

Result
Result type returned by fallible mapping operations.