v2.0.0
The major version bump reflects a breaking change to the shape of the impact-reporting types (see Breaking Changes below).
Added
- Restore Coral API: New
restoreCoral()method to fund coral reef restoration →POST /v1/restore_coralamountis the number of coral fragments to restore (1–10,000,000)- Optional
customerEmail,customerName,notify, andmetadata - Returns
RestoreCoralResponsecontaininguserID,coralRestored,timeUTC,customer
- Cancel Impact API: New
cancelImpact()method to cancel and reverse a previously created impact →POST /v1/cancel_impact- Designed for refund flows — removes the impact from
/impacttotals and reflects on/track - Idempotent: repeat calls return
"impact was already cancelled"without double-reversing aggregates - Params:
userID(e.g."U1234"),timeUTC(ISO 8601), optionalreason(max 200 chars) - Returns
CancelImpactResponseincludinguserID,timeUTC,cancelledOn,message, and the reversed amount for the impact type (treePlanted/wasteRemoved/carbonCaptured/coralRestored/moneyDonated), plus optionalreasonandcategory
- Designed for refund flows — removes the impact from
- Donation categories:
donateMoney()now accepts an optionalcategoryparameter (e.g."veterans","animals","climate") and returnscategoryin the response - Metadata support: All impact actions (
plantTree,cleanOcean,captureCarbon,donateMoney,restoreCoral) accept an optionalmetadataobject of string→string key-value pairs- Limits: up to 20 pairs, keys ≤ 40 chars, values ≤ 500 chars; reserved keys
"gift"and"widgetID"are not allowed - Echoed back on record responses when present
- Limits: up to 20 pairs, keys ≤ 40 chars, values ≤ 500 chars; reserved keys
- Coral in reporting:
coralRestoredis now returned across the read endpoints:getImpact()— top-level total plus in theuserImpact/customerImpactbreakdownsgetDailyImpact()— per-daycoralRestoredgetRecords()/getCustomerRecords()— filter withfilterBy: "coral_restored"; coral records returned asCoralRestoredRecord/CoralRestoredRecordWithCustomertrack()—coralRestoredwhen applicable
- New Types:
RestoreCoralParams,RestoreCoralResponse,CancelImpactParams,CancelImpactResponse,CoralRestoredRecord,CoralRestoredRecordWithCustomer, and theMetadataalias (Record<string, string>)
Breaking Changes
coralRestoredadded toImpactBreakdown,ImpactResponse, andDailyImpactRecordas a new required field, positioned beforemoneyDonatedto match the API field order (treePlanted → wasteRemoved → carbonCaptured → coralRestored → moneyDonated). TypeScript code that constructs these objects directly must add the new field; code that only consumes SDK responses is unaffected at runtime.
Changed
TrackResponse: addedcoralRestored,cancelledOn, andcancellationReasonfields (the latter two populated for cancelled impacts)DonateMoneyParams/DonateMoneyResponse: addedcategory;DonateMoneyParamsalso gainedmetadataPlantTreeParams,CleanOceanParams,CaptureCarbonParams: addedmetadata- Impact record types gained an optional
metadatafield (present only when the API returns it) ImpactRecordandCustomerImpactRecordunions now include the coral record types- Enhanced test suite with full coverage for
restoreCoral(),cancelImpact(), thecategoryandmetadataparameters, and coral mapping acrossgetImpact()/getRecords()
Documentation
- Updated README with new Restore Coral, Cancel Impact, and Metadata sections
- Added
categoryexamples to the Donate Money section - Documented
coralRestoredin the Records, Impact, and Track sections, andcancelledOn/cancellationReasonin the Track response fields
Full Changelog: v1.3.0...v2.0.0