feature/IO-3182-Phone-Number-Consent - Checkpoint

This commit is contained in:
Dave Richer
2025-05-20 16:04:36 -04:00
parent 9d81c68a4d
commit 83860152a9
12 changed files with 540 additions and 43 deletions

View File

@@ -2805,6 +2805,7 @@ exports.GET_BODYSHOP_BY_ID = `
intellipay_config
state
notification_followers
enforce_sms_consent
}
}
`;
@@ -2968,3 +2969,103 @@ exports.GET_JOB_WATCHERS_MINIMAL = `
}
}
`;
// Query to get consent status for a phone number
exports.GET_PHONE_NUMBER_CONSENT = `
query GET_PHONE_NUMBER_CONSENT($bodyshopid: uuid!, $phone_number: String!) {
phone_number_consent(where: { bodyshopid: { _eq: $bodyshopid }, phone_number: { _eq: $phone_number } }) {
id
bodyshopid
phone_number
consent_status
created_at
updated_at
consent_updated_at
history(order_by: { changed_at: desc }) {
id
old_value
new_value
reason
changed_at
changed_by
}
}
}
`;
// Query to get consent history
exports.GET_PHONE_NUMBER_CONSENT_HISTORY = `
query GET_PHONE_NUMBER_CONSENT_HISTORY($phone_number_consent_id: uuid!) {
phone_number_consent_history(where: { phone_number_consent_id: { _eq: $phone_number_consent_id } }, order_by: { changed_at: desc }) {
id
phone_number_consent_id
old_value
new_value
reason
changed_at
changed_by
}
}
`;
// Mutation to set consent status
exports.SET_PHONE_NUMBER_CONSENT = `
mutation SET_PHONE_NUMBER_CONSENT($bodyshopid: uuid!, $phone_number: String!, $consent_status: Boolean!, $reason: String!) {
insert_phone_number_consent_one(
object: {
bodyshopid: $bodyshopid
phone_number: $phone_number
consent_status: $consent_status
consent_updated_at: "now()"
}
on_conflict: {
constraint: phone_number_consent_bodyshopid_phone_number_key
update_columns: [consent_status, consent_updated_at]
}
) {
id
bodyshopid
phone_number
consent_status
created_at
updated_at
consent_updated_at
}
insert_phone_number_consent_history_one(
object: {
phone_number_consent_id: $id
old_value: $old_value
new_value: $consent_status
reason: $reason
changed_by: $changed_by
}
) {
id
reason
changed_at
changed_by
}
}
`;
// Mutation for bulk consent updates
exports.BULK_SET_PHONE_NUMBER_CONSENT = `
mutation BULK_SET_PHONE_NUMBER_CONSENT($objects: [phone_number_consent_insert_input!]!) {
insert_phone_number_consent(
objects: $objects
on_conflict: {
constraint: phone_number_consent_bodyshopid_phone_number_key
update_columns: [consent_status, consent_updated_at]
}
) {
affected_rows
returning {
id
bodyshopid
phone_number
consent_status
consent_updated_at
}
}
}
`;