diff --git a/types/chartmogul-node/chartmogul-node-tests.ts b/types/chartmogul-node/chartmogul-node-tests.ts index 328be18429fe41..c0e0ccfe29aa45 100644 --- a/types/chartmogul-node/chartmogul-node-tests.ts +++ b/types/chartmogul-node/chartmogul-node-tests.ts @@ -7,11 +7,35 @@ config.VERSION; // $ExpectType string ChartMogul.Ping.ping(config); // $ExpectType Promise +// $ExpectType Promise +ChartMogul.Account.retrieve(config); + +// $ExpectType Promise +ChartMogul.Account.retrieve(config, { + include: "refund_handling", +}); + +// $ExpectType Promise +ChartMogul.Account.retrieve(config, { + include: "churn_recognition,churn_when_zero_mrr", +}); + +// $ExpectType Promise +ChartMogul.Account.retrieve(config, { + include: + "churn_recognition,churn_when_zero_mrr,auto_churn_subscription,refund_handling,proximate_movement_reclassification", +}); + // $ExpectType Promise ChartMogul.DataSource.create(config, { name: "", }); +// $ExpectType Promise +ChartMogul.DataSource.create(config, { + name: "In-house billing", +}); + // $ExpectType Promise ChartMogul.DataSource.retrieve(config, ""); @@ -22,7 +46,7 @@ ChartMogul.DataSource.retrieve(config, "", { with_invoice_handling_setting: true, }); -// $ExpectType Promise<{}> +// $ExpectType Promise ChartMogul.DataSource.destroy(config, ""); // $ExpectType Promise @@ -39,22 +63,21 @@ ChartMogul.DataSource.all(config, { with_invoice_handling_setting: true, }); -ChartMogul.DataSource.all(config).then(data => { - data.data_sources[0]; // $ExpectType DataSource - data.data_sources[0].name; // $ExpectType string - data.data_sources[0].processing_status!.processed!; // $ExpectType number - data.data_sources[0].processing_status!.pending!; // $ExpectType number - data.data_sources[0].processing_status!.failed!; // $ExpectType number - data.data_sources[0].auto_churn_subscription_setting!.enabled; // $ExpectType boolean - data.data_sources[0].auto_churn_subscription_setting!.interval; // $ExpectType number | null - data.data_sources[0].invoice_handling_setting; // $ExpectType Record | undefined -}); - // $ExpectType Promise ChartMogul.Customer.create(config, { data_source_uuid: "", - name: "", external_id: "", + name: "", + email: "test@example.com", + company: "Test Company", + country: "US", + state: "US-NY", + city: "New York", + zip: "10001", + lead_created_at: "2022-10-14 00:00:00", + free_trial_started_at: "2022-11-01 00:00:00", + owner: "owner@example.com", + website_url: "https://example.com", attributes: { tags: ["important", "Prio1"], custom: [ @@ -62,6 +85,22 @@ ChartMogul.Customer.create(config, { { type: "Integer", key: "age", value: 18 }, ], }, + primary_contact: { + first_name: "John", + last_name: "Doe", + email: "john@example.com", + title: "CEO", + phone: "+1234567890", + linked_in: "https://linkedin.com/in/johndoe", + twitter: "https://twitter.com/johndoe", + notes: "Primary contact notes", + }, +}); + +// $ExpectType Promise +ChartMogul.Customer.create(config, { + data_source_uuid: "", + external_id: "", }); // $ExpectType Promise @@ -70,32 +109,153 @@ ChartMogul.Customer.retrieve(config, ""); // $ExpectType Promise ChartMogul.Customer.modify(config, "", {}); -// $ExpectType Promise<{}> +// $ExpectType Promise +ChartMogul.Customer.modify(config, "", { + name: "Updated Name", + email: "updated@example.com", + company: "Updated Company", + country: "US", + state: "US-CA", + city: "San Francisco", + zip: "94102", + lead_created_at: "2023-01-01 00:00:00", + free_trial_started_at: "2023-06-13 15:45:13", + owner: "newowner@example.com", + website_url: "https://newsite.example.com", + status: "Working Lead", + attributes: { + tags: ["high-value", "enterprise"], + custom: { + CAC: 25, + channel: "Twitter", + pro: true, + }, + }, + primary_contact: { + first_name: "Jane", + last_name: "Smith", + email: "jane@example.com", + title: "CTO", + phone: "+9876543210", + linked_in: "https://linkedin.com/in/janesmith", + twitter: "https://twitter.com/janesmith", + notes: "Updated contact", + }, +}); + +// $ExpectType Promise ChartMogul.Customer.destroy(config, ""); +// $ExpectType Promise> +ChartMogul.Customer.all(config); + // $ExpectType Promise> ChartMogul.Customer.all(config, { data_source_uuid: "", }); -ChartMogul.Customer.all(config).then(data => { - data.entries[0]; // $ExpectType Customer - data.entries[0].attributes!.stripe!["something"]; // $ExpectType any - data.page!; // $ExpectType number +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + external_id: "", }); +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + status: "Active", +}); + +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + status: "Working Lead", +}); + +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + system: "Stripe", +}); + +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k", + per_page: 50, +}); + +// $ExpectType Promise> +ChartMogul.Customer.all(config, { + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", + status: "Active", + system: "Stripe", + external_id: "34916129", +}); + +// $ExpectType Promise> +ChartMogul.Customer.search(config); + // $ExpectType Promise> ChartMogul.Customer.search(config, { email: "", }); + +// $ExpectType Promise> +ChartMogul.Customer.search(config, { + email: "adam@example.com", +}); + +// $ExpectType Promise> +ChartMogul.Customer.search(config, { + email: "adam@example.com", + cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k", + per_page: 50, +}); + // $ExpectType Promise<{}> ChartMogul.Customer.merge(config, { - from: { customer_uuid: "" }, - into: { customer_uuid: "" }, + from: { customer_uuid: "cus_5915ee5a-babd-406b-b8ce-d207133fb4cb" }, + into: { customer_uuid: "cus_2123290f-09c8-4628-a205-db5596bd58f7" }, }); + +// $ExpectType Promise<{}> +ChartMogul.Customer.merge(config, { + from: { + data_source_uuid: "ds_ade45e52-47a4-231a-1ed2-eb6b9e541213", + external_id: "cus_187544", + }, + into: { + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", + external_id: "34916129", + }, +}); + +// $ExpectType Promise<{}> +ChartMogul.Customer.unmerge(config, { + customer_uuid: "cus_cd9e5f29-6299-40e5-b343-0bd1ed228b4f", +}); + +// $ExpectType Promise<{}> +ChartMogul.Customer.unmerge(config, { + data_source_uuid: "ds_788ec6ae-dd51-11ee-bd46-a3ec952dc041", + external_id: "cus_O075O8NH0LrtG8", +}); + +// $ExpectType Promise<{}> +ChartMogul.Customer.unmerge(config, { + customer_uuid: "cus_cd9e5f29-6299-40e5-b343-0bd1ed228b4f", + move_to_new_customer: ["tasks", "opportunities", "notes"], +}); + +// $ExpectType Promise<{}> +ChartMogul.Customer.unmerge(config, { + data_source_uuid: "ds_788ec6ae-dd51-11ee-bd46-a3ec952dc041", + external_id: "cus_O075O8NH0LrtG8", + move_to_new_customer: ["tasks", "opportunities", "notes"], +}); + // $ExpectType Promise ChartMogul.Customer.attributes(config, ""); +// $ExpectType Promise +ChartMogul.Customer.attributes(config, "cus_de305d54-75b4-431b-adb2-eb6b9e546012"); + // $ExpectType Promise<{}> ChartMogul.Customer.connectSubscriptions(config, "customer-uuid", { subscriptions: [{ uuid: "sub-uuid", data_source_uuid: "ds-uuid" }], @@ -106,85 +266,918 @@ ChartMogul.Customer.disconnectSubscriptions(config, "customer-uuid", { subscriptions: [{ uuid: "sub-uuid" }], }); +// $ExpectType Promise> +ChartMogul.Customer.contacts(config, ""); + +// $ExpectType Promise> +ChartMogul.Customer.contacts(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0"); + +// $ExpectType Promise> +ChartMogul.Customer.contacts(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + cursor: "aabbcc", + per_page: 50, +}); + +// $ExpectType Promise> +ChartMogul.Customer.contacts(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + email: "adam@example.com", +}); + +// $ExpectType Promise +ChartMogul.Customer.createContact(config, "cus_3819e09a-50a2-11ee-ada7-9fcf71cd4580", { + data_source_uuid: "ds_92cc7226-509f-11ee-acf4-639f264f875d", +}); + +// $ExpectType Promise +ChartMogul.Customer.createContact(config, "cus_3819e09a-50a2-11ee-ada7-9fcf71cd4580", { + data_source_uuid: "ds_92cc7226-509f-11ee-acf4-639f264f875d", + first_name: "Adam", + last_name: "Smith", + position: 9, + title: "CEO", + email: "adam@example.com", + phone: "+1234567890", + linked_in: "https://linkedin.com/example", + twitter: "https://twitter.com/example", + notes: "Heading\nBody\nFooter", + custom: [ + { key: "Facebook", value: "https://www.facebook.com/example" }, + { key: "date_of_birth", value: "1985-01-22" }, + ], +}); + +ChartMogul.Customer.createContact( + config, + "cus_3819e09a-50a2-11ee-ada7-9fcf71cd4580", + { data_source_uuid: "ds_92cc7226-509f-11ee-acf4-639f264f875d" }, +); + +// $ExpectType Promise +ChartMogul.Contact.create(config, { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + data_source_uuid: "ds_35542640-d9f1-11ed-9c30-7727168c74a5", +}); + +// $ExpectType Promise +ChartMogul.Contact.create(config, { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + data_source_uuid: "ds_35542640-d9f1-11ed-9c30-7727168c74a5", + first_name: "Adam", + last_name: "Smith", + position: 1, + title: "CEO", + email: "adam@example.com", + phone: "+1234567890", + linked_in: "https://linkedin.com/example", + twitter: "https://twitter.com/example", + notes: "Heading\\nBody\\nFooter", + custom: [ + { key: "Facebook", value: "https://www.facebook.com/example" }, + { key: "date_of_birth", value: "1985-01-22" }, + ], +}); + +// $ExpectType Promise +ChartMogul.Contact.retrieve(config, "con_653af916-dea0-11ed-845b-3be1ac0039ac"); + +// $ExpectType Promise +ChartMogul.Contact.destroy(config, "con_d018335c-56d2-11ee-897c-830bb2bba6ec"); + +// $ExpectType Promise +ChartMogul.Contact.merge( + config, + "con_653af916-dea0-11ed-845b-3be1ac0039ac", + "con_36c9f236-ea66-11ed-b81d-cf0d715ced77", +); + +// $ExpectType Promise> +ChartMogul.Contact.all(config); + +// $ExpectType Promise> +ChartMogul.Contact.all(config, { + email: "adam@example.com", +}); + +// $ExpectType Promise> +ChartMogul.Contact.all(config, { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", +}); + +// $ExpectType Promise> +ChartMogul.Contact.all(config, { + data_source_uuid: "ds_35542640-d9f1-11ed-9c30-7727168c74a5", +}); + +// $ExpectType Promise> +ChartMogul.Contact.all(config, { + customer_external_id: "cus_0001", +}); + +// $ExpectType Promise> +ChartMogul.Contact.all(config, { + cursor: "aabbcc", + per_page: 50, +}); + +// $ExpectType Promise +ChartMogul.Contact.modify(config, "con_f90ba380-57a8-11ee-9500-7f50256329a7", {}); + +// $ExpectType Promise +ChartMogul.Contact.modify(config, "con_f90ba380-57a8-11ee-9500-7f50256329a7", { + first_name: "Bill", + last_name: "Thompson", + position: 10, + title: "CTO", + email: "bill@example.com", + phone: "+987654321", + linked_in: "https://linkedin.com/example", + twitter: "https://twitter.com/example", + notes: "New Heading\\nNew Body\\nNew Footer", + custom: [ + { key: "Facebook", value: "https://www.facebook.com/example" }, + { key: "date_of_birth", value: "1990-01-01" }, + ], +}); + +// $ExpectType Promise> +ChartMogul.Customer.notes(config, ""); + +// $ExpectType Promise> +ChartMogul.Customer.notes(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0"); + +// $ExpectType Promise> +ChartMogul.Customer.notes(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + type: "note", +}); + +// $ExpectType Promise> +ChartMogul.Customer.notes(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + type: "call", + author_email: "sara@example.com", +}); + +// $ExpectType Promise> +ChartMogul.Customer.notes(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + cursor: "aabbcc", + per_page: 20, +}); + +// $ExpectType Promise +ChartMogul.Customer.createNote(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + type: "note", +}); + +// $ExpectType Promise +ChartMogul.Customer.createNote(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + type: "note", + author_email: "adam@example.com", + text: "They are a world leader in specialized software.\\n", + created_at: "2023-11-01T00:00:00Z", +}); + +// $ExpectType Promise +ChartMogul.Customer.createNote(config, "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + type: "call", + call_duration: 300, + text: "Discussed pricing options", +}); + +// $ExpectType Promise +ChartMogul.CustomerNote.create(config, { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + type: "note", + author_email: "adam@example.com", + text: "They are a world leader in specialized software.\\n", + created_at: "2023-11-01T00:00:00Z", +}); + +// $ExpectType Promise +ChartMogul.CustomerNote.create(config, { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", + type: "call", + call_duration: 120, +}); + +// $ExpectType Promise +ChartMogul.CustomerNote.retrieve(config, "note_39351ba6-dea0-11ee-ac96-37b2b3de29af"); + +// $ExpectType Promise +ChartMogul.CustomerNote.modify(config, "note_39351ba6-dea0-11ee-ac96-37b2b3de29af", { + author_email: "sara@example.com", + text: "They are a world leader in specialized software.\nThey are in SaaS business.", +}); + +// $ExpectType Promise +ChartMogul.CustomerNote.modify(config, "note_39351ba6-dea0-11ee-ac96-37b2b3de29af", { + call_duration: 180, + updated_at: "2023-12-21T10:53:50.082Z", +}); + +// $ExpectType Promise +ChartMogul.CustomerNote.destroy(config, "note_39351ba6-dea0-11ee-ac96-37b2b3de29af"); + +// $ExpectType Promise> +ChartMogul.CustomerNote.all(config); + +// $ExpectType Promise> +ChartMogul.CustomerNote.all(config, { + customer_uuid: "cus_52eb54c2-dea0-11ed-ac96-ef735d89fca0", +}); + +// $ExpectType Promise> +ChartMogul.CustomerNote.all(config, { + type: "note", +}); + +// $ExpectType Promise> +ChartMogul.CustomerNote.all(config, { + type: "call", + author_email: "sara@example.com", +}); + +// $ExpectType Promise> +ChartMogul.CustomerNote.all(config, { + cursor: "aabbcc", + per_page: 20, +}); + +// $ExpectType Promise> +ChartMogul.Customer.opportunities(config, ""); + +// $ExpectType Promise> +ChartMogul.Customer.opportunities(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7"); + +// $ExpectType Promise> +ChartMogul.Customer.opportunities(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + owner: "bob@example.com", +}); + +// $ExpectType Promise> +ChartMogul.Customer.opportunities(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + pipeline: "New Business", + pipeline_stage: "Discovery", +}); + +// $ExpectType Promise> +ChartMogul.Customer.opportunities(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + estimated_close_date_on_or_after: "2024-01-01", + estimated_close_date_on_or_before: "2024-12-31", +}); + +// $ExpectType Promise> +ChartMogul.Customer.opportunities(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + cursor: "aabbcc", + per_page: 20, +}); + +// $ExpectType Promise +ChartMogul.Customer.createOpportunity(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + owner: "bob@example.com", + pipeline: "New Business", + pipeline_stage: "Discovery", + estimated_close_date: "2024-04-21", + currency: "USD", + amount_in_cents: 100000, +}); + +ChartMogul.Customer.createOpportunity( + config, + "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + owner: "bob@example.com", + pipeline: "New Business", + pipeline_stage: "Discovery", + estimated_close_date: "2024-04-21", + currency: "USD", + amount_in_cents: 100000, + type: "recurring", + forecast_category: "best_case", + win_likelihood: 40, + custom: [{ key: "seats", value: 3 }, { key: "marketing_campaign", value: "Facebook" }], + }, +); + +// $ExpectType Promise +ChartMogul.Opportunity.create(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + owner: "bob@example.com", + pipeline: "New Business", + pipeline_stage: "Discovery", + estimated_close_date: "2024-04-21", + currency: "USD", + amount_in_cents: 100000, +}); + +// $ExpectType Promise +ChartMogul.Opportunity.create(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + owner: "bob@example.com", + pipeline: "Renewals", + pipeline_stage: "Negotiation", + estimated_close_date: "2024-04-21", + currency: "USD", + amount_in_cents: 100000, + type: "recurring", +}); + +// $ExpectType Promise +ChartMogul.Opportunity.create(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + owner: "bob@example.com", + pipeline: "New Business", + pipeline_stage: "Discovery", + estimated_close_date: "2024-04-21", + currency: "USD", + amount_in_cents: 100000, + type: "one-time", + forecast_category: "pipeline", +}); + +// $ExpectType Promise +ChartMogul.Opportunity.create(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + owner: "bob@example.com", + pipeline: "New Business", + pipeline_stage: "Discovery", + estimated_close_date: "2024-04-21", + currency: "USD", + amount_in_cents: 100000, + type: "recurring", + forecast_category: "best_case", + win_likelihood: 40, + custom: [{ key: "seats", value: 3 }, { key: "marketing_campaign", value: "Facebook" }], +}); + +// $ExpectType Promise +ChartMogul.Opportunity.retrieve(config, "4ee13ca4-e7fe-11ee-fa7f-f303abf41acc"); + +// $ExpectType Promise> +ChartMogul.Opportunity.all(config); + +// $ExpectType Promise> +ChartMogul.Opportunity.all(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", +}); + +// $ExpectType Promise> +ChartMogul.Opportunity.all(config, { + owner: "bob@example.com", +}); + +// $ExpectType Promise> +ChartMogul.Opportunity.all(config, { + pipeline: "New Business", + pipeline_stage: "Discovery", +}); + +// $ExpectType Promise> +ChartMogul.Opportunity.all(config, { + estimated_close_date_on_or_after: "2024-01-01", + estimated_close_date_on_or_before: "2024-12-31", +}); + +// $ExpectType Promise> +ChartMogul.Opportunity.all(config, { + cursor: "aabbcc", + per_page: 20, +}); + +// $ExpectType Promise +ChartMogul.Opportunity.modify(config, "4ee13ca4-e7fe-11ee-fa7f-f303abf41acc", { + amount_in_cents: 20000, +}); + +// $ExpectType Promise +ChartMogul.Opportunity.modify(config, "4ee13ca4-e7fe-11ee-fa7f-f303abf41acc", { + owner: "alice@example.com", + pipeline_stage: "Negotiation", +}); + +// $ExpectType Promise +ChartMogul.Opportunity.modify(config, "4ee13ca4-e7fe-11ee-fa7f-f303abf41acc", { + estimated_close_date: "2024-06-30", + forecast_category: "committed", + win_likelihood: 80, +}); + +// $ExpectType Promise +ChartMogul.Opportunity.modify(config, "4ee13ca4-e7fe-11ee-fa7f-f303abf41acc", { + amount_in_cents: 20000, + custom: [{ key: "seats", value: 4 }], +}); + +// $ExpectType Promise +ChartMogul.Opportunity.destroy(config, "4ee13ca4-e7fe-11ee-fa7f-f303abf41acc"); + +// $ExpectType Promise> +ChartMogul.Customer.tasks(config, ""); + +// $ExpectType Promise> +ChartMogul.Customer.tasks(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7"); + +// $ExpectType Promise> +ChartMogul.Customer.tasks(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + assignee: "bob@example.com", +}); + +// $ExpectType Promise> +ChartMogul.Customer.tasks(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + due_date_on_or_after: "2024-01-01", + due_date_on_or_before: "2024-12-31", +}); + +// $ExpectType Promise> +ChartMogul.Customer.tasks(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + completed: false, +}); + +// $ExpectType Promise> +ChartMogul.Customer.tasks(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + cursor: "aabbcc", + per_page: 20, +}); + +// $ExpectType Promise +ChartMogul.Customer.createTask(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + task_details: "Schedule product demo", + assignee: "bob@myriapodlabs.com", + due_date: "2025-04-21", +}); + +// $ExpectType Promise +ChartMogul.Customer.createTask(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + task_details: "Schedule product demo", + assignee: "bob@myriapodlabs.com", + due_date: "2025-04-21", + completed_at: "2025-04-20", +}); + +// $ExpectType Promise +ChartMogul.Task.create(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + task_details: "Schedule product demo", + assignee: "bob@myriapodlabs.com", + due_date: "2025-04-21", +}); + +// $ExpectType Promise +ChartMogul.Task.create(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", + task_details: "Follow up on contract", + assignee: "alice@myriapodlabs.com", + due_date: "2025-05-01", + completed_at: "2025-04-30", +}); + +// $ExpectType Promise +ChartMogul.Task.retrieve(config, "5d6ec2cc-280d-11f0-b50e-5bd43fc8c28c"); + +// $ExpectType Promise> +ChartMogul.Task.all(config); + +// $ExpectType Promise> +ChartMogul.Task.all(config, { + customer_uuid: "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", +}); + +// $ExpectType Promise> +ChartMogul.Task.all(config, { + assignee: "bob@myriapodlabs.com", +}); + +// $ExpectType Promise> +ChartMogul.Task.all(config, { + due_date_on_or_after: "2025-01-01", + due_date_on_or_before: "2025-12-31", +}); + +// $ExpectType Promise> +ChartMogul.Task.all(config, { + completed: true, +}); + +// $ExpectType Promise> +ChartMogul.Task.all(config, { + cursor: "aabbcc", + per_page: 20, +}); + +// $ExpectType Promise +ChartMogul.Task.modify(config, "5d6ec2cc-280d-11f0-b50e-5bd43fc8c28c", { + assignee: "ana@myriapodlabs.com", +}); + +// $ExpectType Promise +ChartMogul.Task.modify(config, "5d6ec2cc-280d-11f0-b50e-5bd43fc8c28c", { + task_details: "Updated task description", + due_date: "2025-06-30", +}); + +// $ExpectType Promise +ChartMogul.Task.modify(config, "5d6ec2cc-280d-11f0-b50e-5bd43fc8c28c", { + completed_at: "2025-04-19", +}); + +// $ExpectType Promise +ChartMogul.Task.modify(config, "5d6ec2cc-280d-11f0-b50e-5bd43fc8c28c", { + assignee: "ana@myriapodlabs.com", + completed_at: "2025-04-19", +}); + +// $ExpectType Promise +ChartMogul.Task.destroy(config, "5d6ec2cc-280d-11f0-b50e-5bd43fc8c28c"); + // $ExpectType Promise ChartMogul.Plan.create(config, { - data_source_uuid: "", - name: "", + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", + name: "Bronze Plan", interval_count: 1, - interval_unit: "", - external_id: "", + interval_unit: "month", }); // $ExpectType Promise -ChartMogul.Plan.retrieve(config, ""); +ChartMogul.Plan.create(config, { + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", + name: "Silver Plan", + interval_count: 1, + interval_unit: "month", + external_id: "plan_0001", +}); // $ExpectType Promise -ChartMogul.Plan.modify(config, "", { - name: "", +ChartMogul.Plan.create(config, { + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", + name: "Annual Gold Plan", + interval_count: 1, + interval_unit: "year", + external_id: "plan_gold_annual", }); -// $ExpectType Promise<{}> -ChartMogul.Plan.destroy(config, ""); +// $ExpectType Promise +ChartMogul.Plan.retrieve(config, "pl_eed05d54-75b4-431b-adb2-eb6b9e543206"); + +// $ExpectType Promise +ChartMogul.Plan.modify(config, "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", { + name: "Bronze Monthly Plan", +}); + +// $ExpectType Promise +ChartMogul.Plan.modify(config, "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", { + interval_count: 3, + interval_unit: "month", +}); + +// $ExpectType Promise +ChartMogul.Plan.modify(config, "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", { + name: "Updated Plan", + interval_count: 1, + interval_unit: "year", +}); + +// $ExpectType Promise +ChartMogul.Plan.destroy(config, "pl_eed05d54-75b4-431b-adb2-eb6b9e543206"); +// $ExpectType Promise +ChartMogul.Plan.all(config); + +// $ExpectType Promise ChartMogul.Plan.all(config, { - page: 1, -}).then(data => { - data.plans[0]; // $ExpectType Plan - data.plans[0].name!; // $ExpectType string - data.page!; // $ExpectType number + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", +}); + +// $ExpectType Promise +ChartMogul.Plan.all(config, { + external_id: "plan_0001", +}); + +// $ExpectType Promise +ChartMogul.Plan.all(config, { + system: "Stripe", +}); + +// $ExpectType Promise +ChartMogul.Plan.all(config, { + cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k", + per_page: 3, +}); + +// $ExpectType Promise +ChartMogul.PlanGroup.create(config, { + name: "Growth Plans", + plans: ["pl_6add9607-23ce-11eb-8b6f-cfcb12b8f91f", "pl_b4eaffff-23ce-11eb-8b6f-03cebf8dcd12"], +}); + +// $ExpectType Promise +ChartMogul.PlanGroup.create(config, { + name: "Enterprise Plans", + plans: ["pl_eed05d54-75b4-431b-adb2-eb6b9e543206"], }); +// $ExpectType Promise +ChartMogul.PlanGroup.retrieve(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206"); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, {}); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, { per_page: 2 }); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, { cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k" }); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, { per_page: 10, cursor: "cursor_value" }); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206"); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", {}); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", { per_page: 5 }); + +// $ExpectType Promise +ChartMogul.PlanGroup.all(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", { cursor: "cursor123" }); + +// $ExpectType Promise +ChartMogul.PlanGroup.modify(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", {}); + +// $ExpectType Promise +ChartMogul.PlanGroup.modify(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", { + name: "Updated Growth Plans", +}); + +// $ExpectType Promise +ChartMogul.PlanGroup.modify(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", { + plans: ["pl_5d42c34e-c720-4a5b-8deb-a73ee2585803", "pl_14483884-6d43-47a9-ae1c-c362c2036c1d"], +}); + +// $ExpectType Promise +ChartMogul.PlanGroup.modify(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206", { + name: "Enterprise Plans", + plans: ["pl_5d42c34e-c720-4a5b-8deb-a73ee2585803"], +}); + +// $ExpectType Promise +ChartMogul.PlanGroup.destroy(config, "plg_eed05d54-75b4-431b-adb2-eb6b9e543206"); + // $ExpectType Promise ChartMogul.Invoice.retrieve(config, ""); // $ExpectType Promise -ChartMogul.Invoice.create(config, "", { +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9"); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", {}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + validation_type: "valid", +}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + validation_type: "invalid", +}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + validation_type: "all", +}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + include_edit_histories: true, +}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + with_disabled: true, +}); + +// $ExpectType Promise +ChartMogul.Invoice.retrieve(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + validation_type: "all", + include_edit_histories: true, + with_disabled: true, +}); + +// $ExpectType Promise<{ invoices: Invoice[]; }> +ChartMogul.Invoice.create(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { invoices: [ { - external_id: "", + external_id: "inv_0001", + date: "2022-11-10 00:00:00", + currency: "USD", + line_items: [ + { + type: "subscription", + subscription_external_id: "sub_0001", + plan_uuid: "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", + service_period_start: "2022-11-10 00:00:00", + service_period_end: "2022-12-01 00:00:00", + amount_in_cents: 5000, + }, + ], }, ], }); -// $ExpectType Promise<{}> -ChartMogul.Invoice.destroy(config, ""); -ChartMogul.Invoice.all(config, { - external_id: "", -}).then(data => { - data.invoices[0]; // $ExpectType Invoice - data.invoices[0].uuid!; // $ExpectType string - data.page!; // $ExpectType number +// $ExpectType Promise<{ invoices: Invoice[]; }> +ChartMogul.Invoice.create(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + invoices: [ + { + external_id: "inv_0002", + date: "2022-11-10 00:00:00", + currency: "USD", + due_date: "2022-11-15 00:00:00", + customer_external_id: "cus_0001", + data_source_uuid: "ds_fef05d54-47b4-431b-aed2-eb6b9e545430", + collection_method: "automatic", + line_items: [ + { + type: "subscription", + subscription_external_id: "sub_0001", + subscription_set_external_id: "set_0001", + plan_uuid: "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", + service_period_start: "2022-11-10 00:00:00", + service_period_end: "2022-12-01 00:00:00", + amount_in_cents: 5000, + prorated: true, + proration_type: "differential", + quantity: 1, + discount_code: "PSO86", + discount_amount_in_cents: 1000, + tax_amount_in_cents: 900, + transaction_fees_in_cents: 200, + transaction_fees_currency: "USD", + discount_description: "New signup promo", + event_order: 5, + }, + { + type: "one_time", + description: "Setup Fees", + amount_in_cents: 2500, + quantity: 1, + discount_code: "PSO86", + discount_amount_in_cents: 500, + tax_amount_in_cents: 450, + transaction_fees_currency: "USD", + discount_description: "New signup promo", + }, + ], + transactions: [ + { + date: "2022-11-10 00:14:23", + type: "payment", + result: "successful", + }, + ], + }, + ], +}); + +// $ExpectType Promise<{ invoices: Invoice[]; }> +ChartMogul.Invoice.create(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + invoices: [ + { + external_id: "inv_0003", + date: "2022-11-10 00:00:00", + currency: "USD", + line_items: [ + { + type: "trial", + subscription_external_id: "trial_sub_001", + plan_uuid: "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", + service_period_start: "2022-11-01 00:00:00", + service_period_end: "2022-11-14 00:00:00", + amount_in_cents: 0, + }, + ], + }, + ], +}); + +// $ExpectType Promise<{ invoices: Invoice[]; }> +ChartMogul.Invoice.create(config, "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + invoices: [ + { + external_id: "inv_0004", + date: "2022-11-10 00:00:00", + currency: "USD", + line_items: [ + { + type: "subscription", + subscription_external_id: "sub_0002", + plan_uuid: "pl_eed05d54-75b4-431b-adb2-eb6b9e543206", + service_period_start: "2022-11-10 00:00:00", + amount_in_cents: 0, + cancelled_at: "2022-11-20 00:00:00", + }, + ], + transactions: [ + { + date: "2022-11-10 00:14:23", + type: "refund", + result: "failed", + amount_in_cents: 1000, + external_id: "txn_001", + }, + ], + }, + ], +}); + +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", {}); + +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + date: "2024-11-10T00:00:00Z", +}); + +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + due_date: "2024-12-02T00:00:00Z", +}); + +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + currency: "EUR", +}); + +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + collection_method: "automatic", }); +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + collection_method: "manual", +}); + +// $ExpectType Promise +ChartMogul.Invoice.modify(config, "inv_f466e33d-ff2b-4a11-8f85-417eb02157a7", { + date: "2024-11-10T00:00:00Z", + due_date: "2024-12-02T00:00:00Z", + currency: "EUR", + collection_method: "manual", +}); + +// $ExpectType Promise +ChartMogul.Invoice.destroy(config, ""); + ChartMogul.Invoice.all(config, "", { page: 1, -}).then(data => { - data.customer_uuid!; // $ExpectType string - data.invoices[0]; // $ExpectType Invoice - data.invoices[0].uuid!; // $ExpectType string - data.page!; // $ExpectType number }); // $ExpectType Promise -ChartMogul.Transaction.create(config, "", { - type: "", - date: "", - result: "", +ChartMogul.Transaction.create(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + type: "payment", + date: "2022-11-10 00:14:23", + result: "successful", }); -ChartMogul.Subscription.all(config, "", { - page: 1, -}).then(data => { - data.customer_uuid!; // $ExpectType string - data.subscriptions[0]; // $ExpectType Subscription - data.subscriptions[0].uuid; // $ExpectType string - data.current_page!; // $ExpectType number +// $ExpectType Promise +ChartMogul.Transaction.create(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + type: "refund", + date: "2022-12-25 18:10:00", + result: "successful", + external_id: "trans_00241", +}); + +// $ExpectType Promise +ChartMogul.Transaction.create(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + type: "payment", + date: "2022-11-10T00:14:23Z", + result: "failed", + amount_in_cents: 5000, +}); + +// $ExpectType Promise +ChartMogul.Transaction.create(config, "inv_565c73b2-85b9-49c9-a25e-2b7df6a677c9", { + type: "refund", + date: "2022-11-10T00:14:23Z", + result: "successful", + external_id: "txn_001", + amount_in_cents: 1000, + transaction_fees_in_cents: 350, + transaction_fees_currency: "EUR", }); ChartMogul.Subscription.cancel(config, "", { cancelled_at: "", -}).then(data => { - data.customer_uuid; // $ExpectType string }); // $ExpectType Promise> @@ -227,8 +1220,6 @@ ChartMogul.CustomAttribute.update(config, "", { ChartMogul.CustomAttribute.remove(config, "", { custom: [""], -}).then(data => { - data.custom["key"]; // $ExpectType any }); // $ExpectType Promise @@ -287,10 +1278,6 @@ ChartMogul.Metrics.mrrChurnRate(config, { ChartMogul.Metrics.ltv(config, { "start-date": "2015-01-01", "end-date": "2015-11-01", -}).then(data => { - data.entries[0].ltv; // $ExpectType number - data.summary; // $ExpectType Summary - data.summary.current; // $ExpectType number }); // $ExpectType Promise> @@ -300,19 +1287,302 @@ ChartMogul.Metrics.Customer.subscriptions(config, "", { ChartMogul.Metrics.Customer.activities(config, "", { page: 1, -}).then(data => { - data.entries; // $ExpectType MetricsActivity[] - data.entries[0]; // $ExpectType MetricsActivity - data.entries[0]["activity-mrr"]; // $ExpectType number - data.page!; // $ExpectType number }); // $ExpectType Promise<{}> -ChartMogul.Metrics.Customer.connectSubscriptions(config, "ds-uuid", "customer-uuid", { - subscriptions: [{ uuid: "sub-uuid", data_source_uuid: "ds-uuid" }], -}); +ChartMogul.Metrics.Customer.connectSubscriptions(config, "ds-uuid", "customer-uuid", [ + { uuid: "sub-uuid" }, +]); // $ExpectType Promise<{}> -ChartMogul.Metrics.Customer.disconnectSubscriptions(config, "ds-uuid", "customer-uuid", { - subscriptions: [{ uuid: "sub-uuid", data_source_uuid: "ds-uuid" }], +ChartMogul.Metrics.Customer.disconnectSubscriptions(config, "ds-uuid", "customer-uuid", [ + { uuid: "sub-uuid" }, +]); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.create(config, { + subscription_event: { + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", + customer_external_id: "cus_0001", + event_type: "subscription_start_scheduled", + event_date: "2022-03-30", + effective_date: "2022-04-01", + subscription_external_id: "sub_0001", + plan_external_id: "gold_monthly", + currency: "USD", + amount_in_cents: 1000, + quantity: 1, + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.create(config, { + subscription_event: { + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", + customer_external_id: "cus_0001", + event_type: "subscription_cancelled", + event_date: "2022-05-30", + effective_date: "2022-06-01", + subscription_external_id: "sub_0001", + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.create(config, { + subscription_event: { + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", + customer_external_id: "cus_0001", + event_type: "subscription_event_retracted", + event_date: "2022-03-31", + effective_date: "2022-04-01", + subscription_external_id: "sub_0001", + retracted_event_id: "evnt_001", + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config, {}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config, { + event_type: "subscription_cancelled", + plan_external_id: "gold_monthly", +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config, { + customer_external_id: "cus_0001", + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config, { + subscription_external_id: "sub_0001", + event_date: "2022-04-09T11:17:14Z", +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config, { + per_page: 5, + cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k", +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.all(config, { + include_edit_histories: true, + with_disabled: true, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.modify(config, { + subscription_event: { + external_id: "evnt_001", + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", + effective_date: "2022-04-30", + currency: "USD", + amount_in_cents: 100, + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.modify(config, { + subscription_event: { + id: 23223966, + quantity: 2, + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.modify(config, { + subscription_event: { + external_id: "evnt_001", + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", + event_type: "subscription_updated", + plan_external_id: "silver_monthly", + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.updateWithParams(config, { + subscription_event: { + external_id: "evnt_001", + data_source_uuid: "ds_1fm3eaac-62d0-31ec-clf4-4bf0mbe81aba", + effective_date: "2022-04-30", + currency: "USD", + amount_in_cents: 100, + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.updateWithParams(config, { + subscription_event: { + id: 23223966, + event_order: 200, + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.destroy(config, { + subscription_event: { + external_id: "evnt_0001", + data_source_uuid: "ds_14336c0c-ab0b-11ec-8c55-c3902af70e1c", + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.destroy(config, { + subscription_event: { + id: 23223966, + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.deleteWithParams(config, { + subscription_event: { + external_id: "evnt_0001", + data_source_uuid: "ds_14336c0c-ab0b-11ec-8c55-c3902af70e1c", + }, +}); + +// $ExpectType Promise +ChartMogul.SubscriptionEvent.deleteWithParams(config, { + subscription_event: { + id: 23223966, + }, +}); + +// Metrics.ActivitiesExport.create + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, {}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + "start-date": "2022-01-01T00:00:00", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + "end-date": "2022-12-31T00:00:00", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + type: "churn", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + type: "new_biz", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + type: "reactivation", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + type: "expansion", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + type: "contraction", +}); + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.create(config, { + "start-date": "2022-01-01T00:00:00", + "end-date": "2022-12-31T00:00:00", + type: "churn", +}); + +// Metrics.ActivitiesExport.retrieve + +// $ExpectType Promise +ChartMogul.Metrics.ActivitiesExport.retrieve(config, "17042239-3674-4a61-b838-b6b307f28506"); + +// Metrics.Activity.all + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, {}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + "per-page": 200, +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + "start-date": "2023-01-01T00:00:00", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + "end-date": "2023-12-31T00:00:00", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + type: "churn", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + type: "new_biz", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + type: "reactivation", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + type: "expansion", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + type: "contraction", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + order: "date", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + order: "-date", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + "start-after": "f1a49735-21c7-4e3f-9ddc-67927aaadcf4", +}); + +// $ExpectType Promise +ChartMogul.Metrics.Activity.all(config, { + cursor: "AjMx90kC0yMVQwNNwoYToyNC4wMDAwMDAwMDBgks68k", + "per-page": 100, + "start-date": "2023-01-01T00:00:00", + "end-date": "2023-12-31T00:00:00", + type: "churn", + order: "-date", }); diff --git a/types/chartmogul-node/common.d.ts b/types/chartmogul-node/common.d.ts index 50e41698b26de9..599b3a3136d20c 100644 --- a/types/chartmogul-node/common.d.ts +++ b/types/chartmogul-node/common.d.ts @@ -2,17 +2,19 @@ export interface Map { [key: string]: any; } export interface CursorParams { - page?: number | undefined; - per_page?: number | undefined; + page?: number; + per_page?: number; + cursor?: string; } export type Strings = string[]; export interface Cursor { - page?: number | undefined; - per_page?: number | undefined; - has_more?: boolean | undefined; - current_page?: number | undefined; - total_pages?: number | undefined; + page?: number; + per_page?: number; + cursor?: string; + has_more?: boolean; + current_page?: number; + total_pages?: number; } export interface Entries extends Cursor { entries: T[]; diff --git a/types/chartmogul-node/index.d.ts b/types/chartmogul-node/index.d.ts index 6da4deb2595d6b..340a2866226450 100644 --- a/types/chartmogul-node/index.d.ts +++ b/types/chartmogul-node/index.d.ts @@ -1,5 +1,9 @@ import { Cursor, CursorParams, Entries, EntriesSummary, Map, Strings } from "./common"; +export interface ResourceDestroyed { + message: string; +} + export class Config { VERSION: string; API_BASE: string; @@ -13,14 +17,60 @@ export namespace Ping { function ping(config: Config): Promise; } +export namespace Account { + type WeekStartOn = "monday" | "sunday"; + type ChurnRecognition = + | "churn_at_time_of_cancelation" + | "churn_at_period_end" + | "churn_at_click"; + type RefundHandling = "refund_ignore" | "refund_full_only"; + type ProximateMovementReclassification = + | "reclassification_off" + | "one_minute_reclassification" + | "ten_minutes_reclassification" + | "one_hour_reclassification" + | "one_day_reclassification" + | "one_week_reclassification" + | "thirty_days_reclassification" + | "sixty_days_reclassification" + | "ninety_days_reclassification"; + + interface ExtraAccountParams { + /** + * Comma-separated list of fields to include. Allowed values: + * - churn_recognition, + * - churn_when_zero_mrr, + * - auto_churn_subscription, + * - refund_handling, + * - proximate_movement_reclassification + * Example: auto_churn_subscription,churn_when_zero_mrr + */ + include?: string; + } + + interface Account { + id: string; + name: string; + currency: string; + time_zone: string; + week_start_on: WeekStartOn; + churn_recognition?: ChurnRecognition; + churn_when_zero_mrr?: boolean; + auto_churn_subscription?: boolean; + refund_handling?: RefundHandling; + proximate_movement_reclassification?: ProximateMovementReclassification; + } + + function retrieve(config: Config, params?: ExtraAccountParams): Promise; +} + export namespace DataSource { type DataSourceStatus = | "never_imported" | "import_complete" | "import_in_progress" | "import_failed" - | string - | undefined; + | string; interface ProcessingStatus { processed?: number; @@ -50,109 +100,140 @@ export namespace DataSource { auto_churn_subscription_setting?: AutoChurnSubscriptionSetting; invoice_handling_setting?: Record; } + interface NewDataSource { + name: string; + } interface DataSources { data_sources: DataSource[]; } - function create(config: Config, data: DataSource): Promise; + function create(config: Config, data: NewDataSource): Promise; function retrieve(config: Config, uuid: string, params?: ExtraDataSourceParams): Promise; - function destroy(config: Config, uuid: string): Promise<{}>; + function destroy(config: Config, uuid: string): Promise; function all(config: Config, params?: ListDataSourcesParams): Promise; } export namespace Customer { interface Customer { - id?: number | undefined; - data_source_uuid?: string | undefined; - data_source_uuids?: Strings | undefined; - uuid?: string | undefined; - external_id?: string | undefined; - external_ids?: Strings | undefined; - name?: string | undefined; - email?: string | undefined; - status?: string | undefined; - ["customer-since"]?: string | undefined; - attributes?: Attributes | undefined; + id?: number; + data_source_uuid?: string; + data_source_uuids?: Strings; + uuid?: string; + external_id?: string; + external_ids?: Strings; + name?: string; + email?: string; + status?: string; + ["customer-since"]?: string; + attributes?: Attributes; address?: { - address_zip?: string | undefined; - city?: string | undefined; - state?: string | undefined; - country?: string | undefined; - } | undefined; - mrr?: number | undefined; - arr?: number | undefined; - ["billing-system-url"]?: string | undefined; - ["chartmogul-url"]?: string | undefined; - ["billing-system-type"]?: string | undefined; - currency?: string | undefined; - ["currency-sign"]?: string | undefined; - company?: string | undefined; - country?: string | undefined; - state?: string | undefined; - city?: string | undefined; - zip?: string | undefined; - lead_created_at?: string | undefined; - free_trial_started_at?: string | undefined; + address_zip?: string; + city?: string; + state?: string; + country?: string; + }; + mrr?: number; + arr?: number; + ["billing-system-url"]?: string; + ["chartmogul-url"]?: string; + ["billing-system-type"]?: string; + currency?: string; + ["currency-sign"]?: string; + company?: string; + country?: string; + state?: string; + city?: string; + zip?: string; + lead_created_at?: string; + free_trial_started_at?: string; + owner?: string; + website_url?: string; + } + interface PrimaryContact { + first_name?: string; + last_name?: string; + email?: string; + title?: string; + phone?: string; + linked_in?: string; + twitter?: string; + notes?: string; } interface NewCustomer { data_source_uuid: string; external_id: string; - name: string; - email?: string | undefined; - company?: string | undefined; - country?: string | undefined; - state?: string | undefined; - city?: string | undefined; - zip?: string | undefined; - lead_created_at?: string | undefined; - free_trial_started_at?: string | undefined; - attributes?: NewAttributes | undefined; + name?: string; + email?: string; + company?: string; + country?: string; + state?: string; + city?: string; + zip?: string; + lead_created_at?: string; + free_trial_started_at?: string; + attributes?: NewAttributes; + owner?: string; + primary_contact?: PrimaryContact; + website_url?: string; } interface UpdateCustomer { - name?: string | undefined; - email?: string | undefined; - company?: string | undefined; - country?: string | undefined; - state?: string | undefined; - city?: string | undefined; - zip?: string | undefined; - lead_created_at?: string | undefined; - free_trial_started_at?: string | undefined; - attributes?: NewAttributes | undefined; + name?: string; + email?: string; + company?: string; + country?: string; + state?: string; + city?: string; + zip?: string; + lead_created_at?: string; + free_trial_started_at?: string; + attributes?: UpdateAttributes; + owner?: string; + primary_contact?: PrimaryContact; + website_url?: string; + status?: string; } - interface NewAttributes { - tags?: Strings | undefined; - custom?: NewCustomAttributes[] | undefined; + interface UpdateAttributes { + tags?: Strings; + custom?: Map; } - interface NewCustomAttributes { - type?: string | undefined; - key: string; - value: any; - source?: string | undefined; + interface NewAttributes { + tags?: Strings; + custom?: CustomAttribute.NewCustomAttribute[]; } interface Attributes { - tags?: Strings | undefined; - stripe?: Map | undefined; - clearbit?: Map | undefined; - custom?: Map | undefined; + tags?: Strings; + stripe?: Map; + clearbit?: Map; + custom?: Map; } interface ListCustomersParams extends CursorParams { - data_source_uuid?: string | undefined; - status?: string | undefined; - system?: string | undefined; - external_id?: string | undefined; + data_source_uuid?: string; + status?: string; + system?: string; + external_id?: string; } interface SearchCustomersParams extends CursorParams { - email: string; - } - interface MergeID { - customer_uuid?: string | undefined; - external_id?: string | undefined; + email?: string; } + type MergeID = + | { + customer_uuid: string; + data_source_uuid?: never; + external_id?: never; + } + | { + customer_uuid?: never; + data_source_uuid: string; + external_id: string; + }; interface MergeCustomersParams { from: MergeID; into: MergeID; } + type MoveToNewCustomerField = "tasks" | "opportunities" | "notes"; + type UnmergeCustomersParams = MergeID & { + move_to_new_customer?: MoveToNewCustomerField[]; + }; interface SubscriptionData { subscriptions: Array<{ uuid: string; data_source_uuid?: string }>; @@ -161,10 +242,11 @@ export namespace Customer { function create(config: Config, data: NewCustomer): Promise; function retrieve(config: Config, uuid: string): Promise; function modify(config: Config, uuid: string, data: UpdateCustomer): Promise; - function destroy(config: Config, uuid: string): Promise<{}>; + function destroy(config: Config, uuid: string): Promise; function all(config: Config, params?: ListCustomersParams): Promise>; function search(config: Config, params?: SearchCustomersParams): Promise>; function merge(config: Config, params?: MergeCustomersParams): Promise<{}>; + function unmerge(config: Config, params: UnmergeCustomersParams): Promise<{}>; function attributes(config: Config, uuid: string): Promise; /** * @deprecated Use Metrics.Customer.connectSubscriptions instead @@ -174,101 +256,484 @@ export namespace Customer { * @deprecated Use Metrics.Customer.disconnectSubscriptions instead */ function disconnectSubscriptions(config: Config, customerUuid: string, data: SubscriptionData): Promise<{}>; + + function contacts( + config: Config, + customerId: string, + params?: Contact.ListContactsParams, + ): Promise>; + function createContact( + config: Config, + customerId: string, + data: Contact.NewCustomerContact, + ): Promise; + + function notes( + config: Config, + customerId: string, + params?: CustomerNote.ListCustomerNotesParams, + ): Promise>; + function createNote( + config: Config, + customerId: string, + data: CustomerNote.NewCustomerNote, + ): Promise; + + function opportunities( + config: Config, + customerId: string, + params?: Opportunity.ListOpportunitiesParams, + ): Promise>; + function createOpportunity( + config: Config, + customerId: string, + data: Opportunity.NewOpportunity, + ): Promise; + + function tasks( + config: Config, + customerId: string, + params?: Task.ListTasksParams, + ): Promise>; + function createTask(config: Config, customerId: string, data: Task.NewTask): Promise; +} + +export namespace Opportunity { + type OpportunityType = "one-time" | "recurring"; + type ForecastCategory = "pipeline" | "best_case" | "committed" | "omitted"; + type OpportunityPipeline = "New Business" | "Renewals"; + type OpportunityPipelineStage = + | "Discovery" + | "Evaluation" + | "Negotiation" + | "Verbal Commit" + | "Closed Won" + | "Closed Lost"; + interface Opportunity { + uuid?: string; + customer_uuid?: string; + owner?: string; + pipeline?: OpportunityPipeline | (string & {}); + pipeline_stage?: OpportunityPipelineStage | (string & {}); + estimated_close_date?: string; + currency?: string; + amount_in_cents?: number; + type?: OpportunityType; + forecast_category?: ForecastCategory; + win_likelihood?: number; + custom?: Map; + created_at?: string; + updated_at?: string; + } + interface ListOpportunitiesParams extends CursorParams { + customer_uuid?: string; + owner?: string; + pipeline?: OpportunityPipeline | (string & {}); + pipeline_stage?: OpportunityPipelineStage | (string & {}); + estimated_close_date_on_or_after?: string; + estimated_close_date_on_or_before?: string; + } + interface NewOpportunity { + customer_uuid: string; + owner: string; + pipeline: OpportunityPipeline | (string & {}); + pipeline_stage: OpportunityPipelineStage | (string & {}); + estimated_close_date: string; + amount_in_cents: number; + currency: string; + type?: OpportunityType; + forecast_category?: ForecastCategory; + win_likelihood?: number; + custom?: Array<{ key: string; value: any }>; + } + interface UpdateOpportunity { + owner?: string; + pipeline?: OpportunityPipeline | (string & {}); + pipeline_stage?: OpportunityPipelineStage | (string & {}); + estimated_close_date?: string; + amount_in_cents?: number; + currency?: string; + type?: OpportunityType; + forecast_category?: ForecastCategory; + win_likelihood?: number; + custom?: Array<{ key: string; value: any }>; + } + + function create(config: Config, data: NewOpportunity): Promise; + function retrieve(config: Config, uuid: string): Promise; + function modify(config: Config, uuid: string, data: UpdateOpportunity): Promise; + function destroy(config: Config, uuid: string): Promise; + function all(config: Config, params?: ListOpportunitiesParams): Promise>; +} + +export namespace Task { + interface Task { + task_uuid?: string; + customer_uuid?: string; + task_details?: string; + assignee?: string; + due_date?: string; + completed_at?: string; + created_at?: string; + updated_at?: string; + } + interface ListTasksParams extends CursorParams { + customer_uuid?: string; + assignee?: string; + due_date_on_or_after?: string; + due_date_on_or_before?: string; + completed?: boolean; + } + interface NewTask { + customer_uuid: string; + task_details: string; + assignee: string; + due_date: string; + completed_at?: string; + } + interface UpdateTask { + task_details?: string; + assignee?: string; + due_date?: string; + completed_at?: string; + } + + function create(config: Config, data: NewTask): Promise; + function retrieve(config: Config, taskUuid: string): Promise; + function modify(config: Config, taskUuid: string, data: UpdateTask): Promise; + function destroy(config: Config, taskUuid: string): Promise; + function all(config: Config, params?: ListTasksParams): Promise>; +} + +export namespace CustomerNote { + type CustomerNoteType = "note" | "call"; + interface CustomerNote { + uuid?: string; + customer_uuid?: string; + type?: CustomerNoteType; + text?: string; + author?: string; + call_duration?: number; + created_at?: string; + updated_at?: string; + } + interface ListCustomerNotesParams extends CursorParams { + customer_uuid?: string; + type?: CustomerNoteType; + author_email?: string; + } + interface NewCustomerNote { + customer_uuid: string; + type: CustomerNoteType; + author_email?: string; + text?: string; + call_duration?: number; + created_at?: string; + } + interface UpdateCustomerNote { + author_email?: string; + text?: string; + call_duration?: number; + created_at?: string; + updated_at?: string; + } + + function create(config: Config, data: NewCustomerNote): Promise; + function retrieve(config: Config, uuid: string): Promise; + function modify(config: Config, uuid: string, data: UpdateCustomerNote): Promise; + function destroy(config: Config, uuid: string): Promise; + function all(config: Config, params?: ListCustomerNotesParams): Promise>; +} + +export namespace Contact { + interface Contact { + uuid?: string; + customer_uuid?: string; + customer_external_id?: string; + data_source_uuid?: string; + position?: number; + first_name?: string; + last_name?: string; + title?: string; + email?: string; + phone?: string; + linked_in?: string; + twitter?: string; + notes?: string; + custom?: Map; + } + interface ListContactsParams extends CursorParams { + customer_uuid?: string; + data_source_uuid?: string; + email?: string; + customer_external_id?: string; + } + interface NewContact { + customer_uuid: string; + data_source_uuid: string; + position?: number; + first_name?: string; + last_name?: string; + title?: string; + email?: string; + phone?: string; + linked_in?: string; + twitter?: string; + notes?: string; + custom?: CustomAttribute.NewCustomAttribute[]; + } + type NewCustomerContact = Omit; + interface UpdateContact { + position?: number; + first_name?: string; + last_name?: string; + title?: string; + email?: string; + phone?: string; + linked_in?: string; + twitter?: string; + notes?: string; + custom?: CustomAttribute.NewCustomAttribute[]; + } + + function create(config: Config, data: NewContact): Promise; + function retrieve(config: Config, uuid: string): Promise; + function modify(config: Config, uuid: string, data: UpdateContact): Promise; + function destroy(config: Config, uuid: string): Promise; + function merge(config: Config, intoContactUuid: string, fromContactUuid: string): Promise; + function all(config: Config, params?: ListContactsParams): Promise>; } export namespace Plan { interface Plan { - uuid?: string | undefined; - data_source_uuid?: string | undefined; - external_id?: string | undefined; - name?: string | undefined; - interval_count?: number | undefined; - interval_unit?: string | undefined; + uuid?: string; + data_source_uuid?: string; + external_id?: string; + name?: string; + interval_count?: number; + interval_unit?: string; } interface ListPlansParams extends CursorParams { - data_source_uuid?: string | undefined; - system?: string | undefined; - external_id?: string | undefined; + data_source_uuid?: string; + system?: string; + external_id?: string; } interface Plans extends Cursor { plans: Plan[]; } + interface NewPlan { + data_source_uuid: string; + name: string; + interval_count: number; + interval_unit: string; + external_id?: string; + } + interface UpdatePlan { + name?: string; + interval_count?: number; + interval_unit?: string; + } - function create(config: Config, data: Plan): Promise; + function create(config: Config, data: NewPlan): Promise; function retrieve(config: Config, uuid: string): Promise; - function modify(config: Config, uuid: string, data: Plan): Promise; - function destroy(config: Config, uuid: string): Promise<{}>; + function modify(config: Config, uuid: string, data: UpdatePlan): Promise; + function destroy(config: Config, uuid: string): Promise; function all(config: Config, params?: ListPlansParams): Promise; } +export namespace PlanGroup { + interface PlanGroup { + uuid?: string; + name?: string; + plans_count?: number; + } + interface PlanGroups extends Cursor { + plan_groups: PlanGroup[]; + } + interface NewPlanGroup { + name: string; + plans: string[]; + } + interface UpdatePlanGroup { + name?: string; + plans?: string[]; + } + + function create(config: Config, data: NewPlanGroup): Promise; + function retrieve(config: Config, uuid: string): Promise; + function modify(config: Config, uuid: string, data: UpdatePlanGroup): Promise; + function destroy(config: Config, uuid: string): Promise; + function all(config: Config, planGroupUuid: string, params?: CursorParams): Promise; + function all(config: Config, params?: CursorParams): Promise; +} + export namespace Invoice { interface Invoice { - uuid?: string | undefined; - customer_uuid?: string | undefined; - currency?: string | undefined; - data_source_uuid?: string | undefined; - date?: string | undefined; - due_date?: string | undefined; - external_id?: string | undefined; - line_items?: LineItem[] | undefined; - transactions?: Transaction[] | undefined; + uuid?: string; + customer_uuid?: string; + currency?: string; + data_source_uuid?: string; + date?: string; + due_date?: string; + external_id?: string; + line_items?: LineItem[]; + transactions?: Transaction[]; } interface LineItem { - uuid?: string | undefined; - account_code?: string | undefined; - amount_in_cents?: number | undefined; - cancelled_at?: string | undefined; - description?: string | undefined; - discount_amount_in_cents?: number | undefined; - discount_code?: string | undefined; - external_id?: string | undefined; - plan_uuid?: string | undefined; - prorated?: boolean | undefined; - quantity?: number | undefined; - service_period_end?: string | undefined; - service_period_start?: string | undefined; - subscription_external_id?: string | undefined; - subscription_uuid?: string | undefined; - tax_amount_in_cents?: number | undefined; - transaction_fees_in_cents?: number | undefined; - type?: string | undefined; + uuid?: string; + account_code?: string; + amount_in_cents?: number; + cancelled_at?: string; + description?: string; + discount_amount_in_cents?: number; + discount_code?: string; + external_id?: string; + plan_uuid?: string; + prorated?: boolean; + quantity?: number; + service_period_end?: string; + service_period_start?: string; + subscription_external_id?: string; + subscription_uuid?: string; + tax_amount_in_cents?: number; + transaction_fees_in_cents?: number; + type?: string; } interface Transaction { - uuid?: string | undefined; - date?: string | undefined; - external_id?: string | undefined; - result?: string | undefined; - type?: string | undefined; + uuid?: string; + date?: string; + external_id?: string; + result?: string; + type?: string; + } + + interface NewLineItemBase { + amount_in_cents: number; + quantity?: number; + discount_amount_in_cents?: number; + discount_code?: string; + tax_amount_in_cents?: number; + transaction_fees_in_cents?: number; + external_id?: string; + account_code?: string; + transaction_fees_currency?: string; + discount_description?: string; + event_order?: number; + } + + interface NewSubscriptionLineItem extends NewLineItemBase { + type: "subscription"; + subscription_external_id: string; + subscription_set_external_id?: string; + plan_uuid: string; + service_period_start: string; + service_period_end?: string; + cancelled_at?: string; + prorated?: boolean; + proration_type?: "differential" | "full" | "differential_mrr"; + } + + interface NewOneTimeLineItem extends NewLineItemBase { + type: "one_time"; + description?: string; } + + interface NewTrialLineItem extends NewLineItemBase { + type: "trial"; + subscription_external_id: string; + subscription_set_external_id?: string; + plan_uuid: string; + service_period_start: string; + service_period_end: string; + cancelled_at?: string; + prorated?: boolean; + proration_type?: "differential" | "full" | "differential_mrr"; + } + + type NewLineItem = NewSubscriptionLineItem | NewOneTimeLineItem | NewTrialLineItem; + + interface NewTransaction { + date: string; + type: "payment" | "refund"; + result: "successful" | "failed"; + amount_in_cents?: number; + external_id?: string; + } + + interface NewInvoice { + external_id: string; + date: string; + currency: string; + line_items: NewLineItem[]; + customer_external_id?: string; + data_source_uuid?: string; + transactions?: NewTransaction[]; + due_date?: string; + collection_method?: "automatic" | "manual"; + } + interface ListInvoicesParams extends CursorParams { - data_source_uuid?: string | undefined; - customer_uuid?: string | undefined; - external_id?: string | undefined; + data_source_uuid?: string; + customer_uuid?: string; + external_id?: string; + } + interface RetrieveInvoiceParams { + validation_type?: "valid" | "invalid" | "all"; + include_edit_histories?: boolean; + with_disabled?: boolean; + } + interface UpdateInvoice { + date?: string; + due_date?: string; + currency?: string; + collection_method?: "automatic" | "manual"; } interface Invoices extends Cursor { - customer_uuid?: string | undefined; + customer_uuid?: string; invoices: Invoice[]; } - function create(config: Config, uuid: string, data: { - invoices: Invoice[]; - }): Promise; - function retrieve(config: Config, uuid: string): Promise; - function destroy(config: Config, uuid: string): Promise<{}>; + function create( + config: Config, + uuid: string, + data: { + invoices: NewInvoice[]; + }, + ): Promise<{ invoices: Invoice[] }>; + function retrieve(config: Config, uuid: string, params?: RetrieveInvoiceParams): Promise; + function modify(config: Config, uuid: string, data: UpdateInvoice): Promise; + function destroy(config: Config, uuid: string): Promise; function all(config: Config, uuid: string, params?: ListInvoicesParams): Promise; function all(config: Config, params?: ListInvoicesParams): Promise; } export namespace Transaction { interface Transaction { - uuid?: string | undefined; + uuid?: string; + external_id?: string; + type?: string; + date?: string; + result?: string; + amount_in_cents?: number | null; + transaction_fees_in_cents?: number | null; + transaction_fees_currency?: string | null; + disabled?: boolean; + disabled_at?: string | null; + disabled_by?: string | null; + user_created?: boolean; + } + + interface NewTransaction { + type: "payment" | "refund"; date: string; - external_id?: string | undefined; - result: string; - type: string; + result: "successful" | "failed"; + external_id?: string; + amount_in_cents?: number; + transaction_fees_in_cents?: number; + transaction_fees_currency?: string; } - function create(config: Config, uuid: string, data: Transaction): Promise; + function create(config: Config, invoiceUuid: string, data: NewTransaction): Promise; } export namespace Subscription { @@ -281,11 +746,11 @@ export namespace Subscription { data_source_uuid: string; } interface CancelSubscriptionParams { - cancelled_at?: string | undefined; - cancellation_dates?: Strings | undefined; + cancelled_at?: string; + cancellation_dates?: Strings; } interface Subscriptions extends Cursor { - customer_uuid?: string | undefined; + customer_uuid?: string; subscriptions: Subscription[]; } @@ -293,6 +758,118 @@ export namespace Subscription { function cancel(config: Config, uuid: string, data: CancelSubscriptionParams): Promise; } +export namespace SubscriptionEvent { + type SubscriptionEventType = + | "subscription_start" + | "subscription_start_scheduled" + | "scheduled_subscription_start_retracted" + | "subscription_cancelled" + | "subscription_cancellation_scheduled" + | "scheduled_subscription_cancellation_retracted" + | "subscription_updated" + | "subscription_update_scheduled" + | "scheduled_subscription_update_retracted" + | "subscription_event_retracted"; + + interface SubscriptionEvent { + id?: number; + data_source_uuid?: string; + customer_external_id?: string; + subscription_set_external_id?: string | null; + subscription_external_id?: string; + plan_external_id?: string; + event_date?: string; + effective_date?: string; + event_type?: SubscriptionEventType; + external_id?: string; + errors?: Record; + created_at?: string; + updated_at?: string; + quantity?: number; + currency?: string; + amount_in_cents?: number | string; + tax_amount_in_cents?: number; + event_order?: number | null; + retracted_event_id?: string | null; + } + + interface NewSubscriptionEvent { + data_source_uuid: string; + customer_external_id: string; + event_type: SubscriptionEventType; + event_date: string; + effective_date: string; + subscription_external_id: string; + plan_external_id?: string; + currency?: string; + amount_in_cents?: number; + quantity?: number; + subscription_set_external_id?: string; + tax_amount_in_cents?: number; + retracted_event_id?: string; + external_id?: string; + event_order?: number; + } + + interface ListSubscriptionEventsParams extends CursorParams { + external_id?: string; + customer_external_id?: string; + data_source_uuid?: string; + subscription_external_id?: string; + event_type?: SubscriptionEventType; + event_date?: string; + effective_date?: string; + plan_external_id?: string; + include_edit_histories?: boolean; + with_disabled?: boolean; + } + + interface SubscriptionEvents extends Cursor { + subscription_events: SubscriptionEvent[]; + } + + interface UpdateSubscriptionEvent { + external_id?: string; + data_source_uuid?: string; + id?: number; + customer_external_id?: string; + event_type?: SubscriptionEventType; + event_date?: string; + effective_date?: string; + subscription_external_id?: string; + plan_external_id?: string; + currency?: string; + amount_in_cents?: number; + quantity?: number; + subscription_set_external_id?: string; + tax_amount_in_cents?: number; + retracted_event_id?: string; + event_order?: number; + } + + interface DestroySubscriptionEvent { + external_id?: string; + data_source_uuid?: string; + id?: number; + } + + function create(config: Config, data: { subscription_event: NewSubscriptionEvent }): Promise; + function all(config: Config, params?: ListSubscriptionEventsParams): Promise; + function modify(config: Config, data: { subscription_event: UpdateSubscriptionEvent }): Promise; + function updateWithParams( + config: Config, + data: { subscription_event: UpdateSubscriptionEvent }, + ): Promise; + function destroy( + config: Config, + data: { subscription_event: DestroySubscriptionEvent }, + ): Promise; + function deleteWithParams( + config: Config, + data: { subscription_event: DestroySubscriptionEvent }, + ): Promise; +} + export namespace Tag { interface Tags { tags: Strings; @@ -307,17 +884,22 @@ export namespace Tag { } export namespace CustomAttribute { - import NewCustomAttributes = Customer.NewCustomAttributes; + interface NewCustomAttribute { + type?: string; + key: string; + value: any; + source?: string; + } interface CustomAttributes { custom: Map; } function add(config: Config, uuid: string, data: { email: string; - custom: NewCustomAttributes[]; + custom: NewCustomAttribute[]; }): Promise>; function add(config: Config, uuid: string, data: { - custom: NewCustomAttributes[]; + custom: NewCustomAttribute[]; }): Promise; function update(config: Config, uuid: string, data: CustomAttributes): Promise; function remove(config: Config, uuid: string, data: { @@ -327,25 +909,60 @@ export namespace CustomAttribute { export namespace Metrics { interface Params extends ParamsNoInterval { - interval?: string | undefined; + interval?: string; } interface ParamsNoInterval { ["start-date"]: string; ["end-date"]: string; - geo?: string | undefined; - plans?: string | undefined; + geo?: string; + plans?: string; + filters?: string; } interface All { entries: { date: string; + mrr: number; + ["mrr-percentage-change"]: number; + arr: number; + ["arr-percentage-change"]: number; ["customer-churn-rate"]: number; + ["customer-churn-rate-percentage-change"]: number; ["mrr-churn-rate"]: number; + ["mrr-churn-rate-percentage-change"]: number; ltv: number; + ["ltv-percentage-change"]: number; customers: number; + ["customers-percentage-change"]: number; asp: number; + ["asp-percentage-change"]: number; arpa: number; - arr: number; - mrr: number; + ["arpa-percentage-change"]: number; + }; + summary: { + ["current-mrr"]: number; + ["previous-mrr"]: number; + ["mrr-percentage-change"]: number; + ["current-arr"]: number; + ["previous-arr"]: number; + ["arr-percentage-change"]: number; + ["current-customer-churn-rate"]: number; + ["previous-customer-churn-rate"]: number; + ["customer-churn-rate-percentage-change"]: number; + ["current-mrr-churn-rate"]: number; + ["previous-mrr-churn-rate"]: number; + ["mrr-churn-rate-percentage-change"]: number; + ["current-ltv"]: number; + ["previous-ltv"]: number; + ["ltv-percentage-change"]: number; + ["current-customers"]: number; + ["previous-customers"]: number; + ["customers-percentage-change"]: number; + ["current-asp"]: number; + ["previous-asp"]: number; + ["asp-percentage-change"]: number; + ["current-arpa"]: number; + ["previous-arpa"]: number; + ["arpa-percentage-change"]: number; }; } @@ -403,6 +1020,7 @@ export namespace Metrics { external_id: string; plan: string; quantity: number; + uuid: string; mrr: number; arr: number; status: string; @@ -425,10 +1043,6 @@ export namespace Metrics { type: string; } - interface SubscriptionConnectionData { - subscriptions: Array<{ uuid: string; data_source_uuid: string }>; - } - function subscriptions( config: Config, uuid: string, @@ -439,15 +1053,83 @@ export namespace Metrics { config: Config, dataSourceUuid: string, customerUuid: string, - data: SubscriptionConnectionData, + data: Array<{ uuid: string }>, ): Promise<{}>; function disconnectSubscriptions( config: Config, dataSourceUuid: string, customerUuid: string, - data: SubscriptionConnectionData, + data: Array<{ uuid: string }>, ): Promise<{}>; } + + namespace Activity { + type ActivityType = "new_biz" | "reactivation" | "expansion" | "contraction" | "churn"; + + interface Activity { + description?: string; + ["activity-mrr-movement"]?: number; + ["activity-mrr"]?: number; + ["activity-arr"]?: number; + date?: string; + type?: ActivityType; + currency?: string; + ["subscription-external-id"]?: string; + ["plan-external-id"]?: string; + subscription_set_external_id?: string | null; + ["customer-name"]?: string; + ["customer-uuid"]?: string; + ["customer-external-id"]?: string; + ["billing-connector-uuid"]?: string; + uuid?: string; + } + + interface ListActivitiesParams { + cursor?: string; + ["per-page"]?: number; + ["start-date"]?: string; + ["end-date"]?: string; + type?: ActivityType; + order?: "date" | "-date"; + ["start-after"]?: string; + } + + interface Activities extends Cursor { + entries: Activity[]; + } + + function all(config: Config, params?: ListActivitiesParams): Promise; + } + + namespace ActivitiesExport { + type ActivityType = "new_biz" | "reactivation" | "expansion" | "contraction" | "churn"; + type ExportStatus = "pending" | "processing" | "failed" | "successful"; + + interface ActivitiesExport { + id?: string; + status?: ExportStatus; + file_url?: string | null; + params?: { + kind?: string; + params?: { + activity_type?: ActivityType; + start_date?: string; + end_date?: string; + }; + }; + expires_at?: string | null; + created_at?: string; + } + + interface NewActivitiesExport { + ["start-date"]?: string; + ["end-date"]?: string; + type?: ActivityType; + } + + function create(config: Config, data?: NewActivitiesExport): Promise; + function retrieve(config: Config, id: string): Promise; + } } export class ChartMogulError extends Error { diff --git a/types/koa-qs/index.d.ts b/types/koa-qs/index.d.ts index c04bf385b0b356..20c9fa99f8196c 100644 --- a/types/koa-qs/index.d.ts +++ b/types/koa-qs/index.d.ts @@ -1,9 +1,10 @@ import koa = require("koa"); +import qs = require("qs"); declare namespace koaQs { type ParseMode = "extended" | "strict" | "first"; } -declare function koaQs(app: koa, mode?: koaQs.ParseMode): koa; +declare function koaQs(app: koa, mode?: koaQs.ParseMode, options?: qs.IParseOptions): koa; export = koaQs; diff --git a/types/koa-qs/koa-qs-tests.ts b/types/koa-qs/koa-qs-tests.ts index 78d603f2cf20a3..39ed9f9ccb1854 100644 --- a/types/koa-qs/koa-qs-tests.ts +++ b/types/koa-qs/koa-qs-tests.ts @@ -4,3 +4,7 @@ import Koa = require("koa"); const app = koaQs(new Koa()); app.listen(80); + +const appWithOptions = koaQs(new Koa(), "extended", { arrayLimit: 50 }); + +appWithOptions.listen(80); diff --git a/types/koa-qs/package.json b/types/koa-qs/package.json index 69938f70fa8e92..d1bfe4c4cbae48 100644 --- a/types/koa-qs/package.json +++ b/types/koa-qs/package.json @@ -6,7 +6,8 @@ "https://github.com/koajs/qs#readme" ], "dependencies": { - "@types/koa": "*" + "@types/koa": "*", + "@types/qs": "*" }, "devDependencies": { "@types/koa-qs": "workspace:."