UNPKG

makeimpact

Version:
100 lines (99 loc) 5.59 kB
import { PlantTreeParams, CleanOceanParams, CaptureCarbonParams, DonateMoneyParams, GetRecordsParams, GetCustomerRecordsParams, GetCustomersParams, Environment, PlantTreeResponse, CleanOceanResponse, CaptureCarbonResponse, DonateMoneyResponse, GetRecordsResponse, GetCustomerRecordsResponse, GetCustomersResponse, ImpactResponse, WhoAmIResponse } from "./types"; export declare class OneClickImpact { private apiKey; private baseUrl; /** * Initialize the 1ClickImpact SDK * @param apiKey - Your 1ClickImpact API key (get a free key from https://www.1clickimpact.com/pricing) * @param environment - Optional: Specify whether to use production or sandbox environment */ constructor(apiKey: string, environment?: Environment); /** * Plant trees through 1ClickImpact * @param params - Configuration for planting trees * @param params.amount - Number of trees to plant (1-10,000,000) * @param params.category - Optional: Category for the tree planting * @param params.customerEmail - Optional: Customer's email * @param params.customerName - Optional: Customer's name (only used if email is provided) * @returns PlantTreeResponse */ plantTree(params: PlantTreeParams): Promise<PlantTreeResponse>; /** * Clean ocean plastic through 1ClickImpact * @param params - Configuration for cleaning ocean plastic * @param params.amount - Amount of waste to clean in pounds (lbs) (1-10,000,000) * @param params.customerEmail - Optional: Customer's email * @param params.customerName - Optional: Customer's name (only used if email is provided) * @returns CleanOceanResponse */ cleanOcean(params: CleanOceanParams): Promise<CleanOceanResponse>; /** * Capture carbon through 1ClickImpact * @param params - Configuration for capturing carbon * @param params.amount - Amount of carbon to capture in pounds (lbs) (1-10,000,000) * @param params.customerEmail - Optional: Customer's email * @param params.customerName - Optional: Customer's name (only used if email is provided) * @returns CaptureCarbonResponse */ captureCarbon(params: CaptureCarbonParams): Promise<CaptureCarbonResponse>; /** * Donate money through 1ClickImpact * @param params - Configuration for donating money * @param params.amount - Amount in smallest USD units (cents). For example, $1 = 100, $0.10 = 10 (1-1,000,000,000) * @param params.customerEmail - Optional: Customer's email * @param params.customerName - Optional: Customer's name (only used if email is provided) * @returns DonateMoneyResponse */ donateMoney(params: DonateMoneyParams): Promise<DonateMoneyResponse>; /** * Get impact statistics * @returns Impact statistics for your organization */ getImpact(): Promise<ImpactResponse>; /** * Verify API key and get account information * @returns Account information for the provided API key */ whoAmI(): Promise<WhoAmIResponse>; /** * Get impact records * @param params - Optional parameters to filter records * @param params.filterBy - Optional: Filter records by type. The value could be either "tree_planted", "waste_removed", "carbon_captured" or "money_donated". * @param params.startDate - Optional: Filter records created on or after this date (format: YYYY-MM-DD) * @param params.endDate - Optional: Filter records created on or before this date (format: YYYY-MM-DD) * @param params.cursor - Optional: Pagination cursor from previous response for fetching next page * @param params.limit - Optional: Maximum number of records to return (1-1000, default: 10) * @returns Records based on the provided filters */ getRecords(params?: GetRecordsParams): Promise<GetRecordsResponse>; /** * Get customer records * @param params - Optional parameters to filter customer records * @param params.customerEmail - Optional: Filter records by customer email * @param params.filterBy - Optional: Filter records by type. The value could be either "tree_planted", "waste_removed", "carbon_captured" or "money_donated". * @param params.startDate - Optional: Filter records created on or after this date (format: YYYY-MM-DD) * @param params.endDate - Optional: Filter records created on or before this date (format: YYYY-MM-DD) * @param params.cursor - Optional: Pagination cursor from previous response for fetching next page * @param params.limit - Optional: Maximum number of records to return (1-1000, default: 10) * @returns Customer records based on the provided filters */ getCustomerRecords(params?: GetCustomerRecordsParams): Promise<GetCustomerRecordsResponse>; /** * Get customers * @param params - Optional parameters to filter customers * @param params.customerEmail - Optional: Filter customers by email * @param params.limit - Optional: Maximum number of customers to return (1-1000, default: 10) * @param params.cursor - Optional: Pagination cursor from previous response for fetching next page * @returns Customers based on the provided filters */ getCustomers(params?: GetCustomersParams): Promise<GetCustomersResponse>; /** * Makes a request to the 1ClickImpact API * @param endpoint - API endpoint * @param body - Request body * @param method - HTTP method (default: POST) * @returns API response * @throws Error if the API returns an error */ private makeRequest; }