@clientcasa/sdk 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +7 -0
  2. package/esm/funcs/payments-list.js +1 -0
  3. package/esm/funcs/payments-list.js.map +1 -1
  4. package/esm/funcs/sales-get.d.ts +16 -0
  5. package/esm/funcs/sales-get.d.ts.map +1 -0
  6. package/esm/funcs/sales-get.js +107 -0
  7. package/esm/funcs/sales-get.js.map +1 -0
  8. package/esm/funcs/sales-list.d.ts +18 -0
  9. package/esm/funcs/sales-list.d.ts.map +1 -0
  10. package/esm/funcs/sales-list.js +141 -0
  11. package/esm/funcs/sales-list.js.map +1 -0
  12. package/esm/lib/config.d.ts +3 -3
  13. package/esm/lib/config.js +3 -3
  14. package/esm/lib/config.js.map +1 -1
  15. package/esm/models/index.d.ts +2 -0
  16. package/esm/models/index.d.ts.map +1 -1
  17. package/esm/models/index.js +2 -0
  18. package/esm/models/index.js.map +1 -1
  19. package/esm/models/operations/get-sale.d.ts +27 -0
  20. package/esm/models/operations/get-sale.d.ts.map +1 -0
  21. package/esm/models/operations/get-sale.js +20 -0
  22. package/esm/models/operations/get-sale.js.map +1 -0
  23. package/esm/models/operations/index.d.ts +2 -0
  24. package/esm/models/operations/index.d.ts.map +1 -1
  25. package/esm/models/operations/index.js +2 -0
  26. package/esm/models/operations/index.js.map +1 -1
  27. package/esm/models/operations/list-payments.d.ts +5 -0
  28. package/esm/models/operations/list-payments.d.ts.map +1 -1
  29. package/esm/models/operations/list-payments.js +1 -0
  30. package/esm/models/operations/list-payments.js.map +1 -1
  31. package/esm/models/operations/list-sales.d.ts +75 -0
  32. package/esm/models/operations/list-sales.d.ts.map +1 -0
  33. package/esm/models/operations/list-sales.js +60 -0
  34. package/esm/models/operations/list-sales.js.map +1 -0
  35. package/esm/models/operations/list-webhooks.d.ts +15 -2
  36. package/esm/models/operations/list-webhooks.d.ts.map +1 -1
  37. package/esm/models/operations/list-webhooks.js +15 -2
  38. package/esm/models/operations/list-webhooks.js.map +1 -1
  39. package/esm/models/payment.d.ts +4 -0
  40. package/esm/models/payment.d.ts.map +1 -1
  41. package/esm/models/payment.js +1 -0
  42. package/esm/models/payment.js.map +1 -1
  43. package/esm/models/sale-list.d.ts +13 -0
  44. package/esm/models/sale-list.d.ts.map +1 -0
  45. package/esm/models/sale-list.js +17 -0
  46. package/esm/models/sale-list.js.map +1 -0
  47. package/esm/models/sale.d.ts +76 -0
  48. package/esm/models/sale.d.ts.map +1 -0
  49. package/esm/models/sale.js +58 -0
  50. package/esm/models/sale.js.map +1 -0
  51. package/esm/models/webhook-create.d.ts +15 -2
  52. package/esm/models/webhook-create.d.ts.map +1 -1
  53. package/esm/models/webhook-create.js +15 -2
  54. package/esm/models/webhook-create.js.map +1 -1
  55. package/esm/models/webhook-update.d.ts +15 -2
  56. package/esm/models/webhook-update.d.ts.map +1 -1
  57. package/esm/models/webhook-update.js +15 -2
  58. package/esm/models/webhook-update.js.map +1 -1
  59. package/esm/models/webhook.d.ts +15 -2
  60. package/esm/models/webhook.d.ts.map +1 -1
  61. package/esm/models/webhook.js +15 -2
  62. package/esm/models/webhook.js.map +1 -1
  63. package/esm/sdk/sales.d.ts +17 -0
  64. package/esm/sdk/sales.d.ts.map +1 -0
  65. package/esm/sdk/sales.js +23 -0
  66. package/esm/sdk/sales.js.map +1 -0
  67. package/esm/sdk/sdk.d.ts +3 -0
  68. package/esm/sdk/sdk.d.ts.map +1 -1
  69. package/esm/sdk/sdk.js +5 -0
  70. package/esm/sdk/sdk.js.map +1 -1
  71. package/jsr.json +1 -1
  72. package/package.json +1 -1
  73. package/src/funcs/payments-list.ts +1 -0
  74. package/src/funcs/sales-get.ts +202 -0
  75. package/src/funcs/sales-list.ts +277 -0
  76. package/src/lib/config.ts +3 -3
  77. package/src/models/index.ts +2 -0
  78. package/src/models/operations/get-sale.ts +55 -0
  79. package/src/models/operations/index.ts +2 -0
  80. package/src/models/operations/list-payments.ts +6 -0
  81. package/src/models/operations/list-sales.ts +159 -0
  82. package/src/models/operations/list-webhooks.ts +15 -2
  83. package/src/models/payment.ts +5 -0
  84. package/src/models/sale-list.ts +35 -0
  85. package/src/models/sale.ts +124 -0
  86. package/src/models/webhook-create.ts +15 -2
  87. package/src/models/webhook-update.ts +15 -2
  88. package/src/models/webhook.ts +15 -2
  89. package/src/sdk/sales.ts +45 -0
  90. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,124 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v4-mini";
6
+ import { safeParse } from "../lib/schemas.js";
7
+ import * as openEnums from "../types/enums.js";
8
+ import { OpenEnum } from "../types/enums.js";
9
+ import { Result as SafeParseResult } from "../types/fp.js";
10
+ import * as types from "../types/primitives.js";
11
+ import { SDKValidationError } from "./errors/sdk-validation-error.js";
12
+
13
+ export const Channel = {
14
+ Pos: "pos",
15
+ Manual: "manual",
16
+ Stripe: "stripe",
17
+ Shopify: "shopify",
18
+ Etsy: "etsy",
19
+ SquareImport: "square-import",
20
+ Api: "api",
21
+ } as const;
22
+ export type Channel = OpenEnum<typeof Channel>;
23
+
24
+ export const SaleStatus = {
25
+ Completed: "completed",
26
+ Refunded: "refunded",
27
+ PartiallyRefunded: "partially-refunded",
28
+ Voided: "voided",
29
+ } as const;
30
+ export type SaleStatus = OpenEnum<typeof SaleStatus>;
31
+
32
+ export type Sale = {
33
+ /**
34
+ * UUID v4
35
+ */
36
+ id: string;
37
+ saleNumber: string;
38
+ /**
39
+ * UUID v4
40
+ */
41
+ businessId: string | null;
42
+ /**
43
+ * UUID v4
44
+ */
45
+ clientId: string | null;
46
+ /**
47
+ * UUID v4
48
+ */
49
+ contactId: string | null;
50
+ channel: Channel;
51
+ externalId: string | null;
52
+ saleDate: Date;
53
+ currency: string;
54
+ status: SaleStatus;
55
+ /**
56
+ * ISO 8601 timestamp (UTC)
57
+ */
58
+ voidedAt: Date | null;
59
+ voidReason: string | null;
60
+ taxJurisdiction: string | null;
61
+ taxInclusive: boolean;
62
+ subtotal: number | null;
63
+ discountPercent: number | null;
64
+ discountAmount: number | null;
65
+ taxRate: number | null;
66
+ taxAmount: number | null;
67
+ total: number | null;
68
+ amountRefunded: number;
69
+ notes: string | null;
70
+ /**
71
+ * ISO 8601 timestamp (UTC)
72
+ */
73
+ createdAt: Date;
74
+ /**
75
+ * ISO 8601 timestamp (UTC)
76
+ */
77
+ updatedAt: Date;
78
+ };
79
+
80
+ /** @internal */
81
+ export const Channel$inboundSchema: z.ZodMiniType<Channel, unknown> = openEnums
82
+ .inboundSchema(Channel);
83
+
84
+ /** @internal */
85
+ export const SaleStatus$inboundSchema: z.ZodMiniType<SaleStatus, unknown> =
86
+ openEnums.inboundSchema(SaleStatus);
87
+
88
+ /** @internal */
89
+ export const Sale$inboundSchema: z.ZodMiniType<Sale, unknown> = z.object({
90
+ id: types.string(),
91
+ saleNumber: types.string(),
92
+ businessId: types.nullable(types.string()),
93
+ clientId: types.nullable(types.string()),
94
+ contactId: types.nullable(types.string()),
95
+ channel: Channel$inboundSchema,
96
+ externalId: types.nullable(types.string()),
97
+ saleDate: types.date(),
98
+ currency: types.string(),
99
+ status: SaleStatus$inboundSchema,
100
+ voidedAt: types.nullable(types.date()),
101
+ voidReason: types.nullable(types.string()),
102
+ taxJurisdiction: types.nullable(types.string()),
103
+ taxInclusive: types.boolean(),
104
+ subtotal: types.nullable(types.number()),
105
+ discountPercent: types.nullable(types.number()),
106
+ discountAmount: types.nullable(types.number()),
107
+ taxRate: types.nullable(types.number()),
108
+ taxAmount: types.nullable(types.number()),
109
+ total: types.nullable(types.number()),
110
+ amountRefunded: types.number(),
111
+ notes: types.nullable(types.string()),
112
+ createdAt: types.date(),
113
+ updatedAt: types.date(),
114
+ });
115
+
116
+ export function saleFromJSON(
117
+ jsonString: string,
118
+ ): SafeParseResult<Sale, SDKValidationError> {
119
+ return safeParse(
120
+ jsonString,
121
+ (x) => Sale$inboundSchema.parse(JSON.parse(x)),
122
+ `Failed to parse 'Sale' from JSON`,
123
+ );
124
+ }
@@ -13,7 +13,6 @@ export const WebhookCreateEvent = {
13
13
  InvoicePaymentFailed: "invoice_payment_failed",
14
14
  InvoiceDisputed: "invoice_disputed",
15
15
  InvoicePaymentReminder: "invoice_payment_reminder",
16
- InvoiceViewed: "invoice_viewed",
17
16
  PaymentReceived: "payment_received",
18
17
  PaymentRefunded: "payment_refunded",
19
18
  PaymentApplied: "payment_applied",
@@ -38,6 +37,7 @@ export const WebhookCreateEvent = {
38
37
  ClientWon: "client_won",
39
38
  ClientLost: "client_lost",
40
39
  LeadStatusChanged: "lead_status_changed",
40
+ InvoiceViewed: "invoice_viewed",
41
41
  MilestoneApproaching: "milestone_approaching",
42
42
  TimerRunningReminder: "timer_running_reminder",
43
43
  ContractSent: "contract_sent",
@@ -48,12 +48,12 @@ export const WebhookCreateEvent = {
48
48
  ContractCompleted: "contract_completed",
49
49
  ContractExpired: "contract_expired",
50
50
  ContractVoided: "contract_voided",
51
+ FormSubmissionCompleted: "form_submission_completed",
51
52
  SmartFileSent: "smart_file_sent",
52
53
  SmartFileViewed: "smart_file_viewed",
53
54
  SmartFileAccepted: "smart_file_accepted",
54
55
  SmartFileCompleted: "smart_file_completed",
55
56
  SmartFileExpired: "smart_file_expired",
56
- FormSubmissionCompleted: "form_submission_completed",
57
57
  SubscriptionPaymentFailed: "subscription_payment_failed",
58
58
  PayoutPaid: "payout_paid",
59
59
  PayoutFailed: "payout_failed",
@@ -62,6 +62,19 @@ export const WebhookCreateEvent = {
62
62
  EventDayArchived: "event_day_archived",
63
63
  TimelineItemCompleted: "timeline_item_completed",
64
64
  TimelineReminderSent: "timeline_reminder_sent",
65
+ InvoiceRefunded: "invoice_refunded",
66
+ ContractAmended: "contract_amended",
67
+ ReceiptViewed: "receipt_viewed",
68
+ FollowUpDue: "follow_up_due",
69
+ PaymentProcessing: "payment_processing",
70
+ ClientReply: "client_reply",
71
+ ClientRevisionRequested: "client_revision_requested",
72
+ EmailDeliveryFailed: "email_delivery_failed",
73
+ SaleCompleted: "sale_completed",
74
+ SaleRefunded: "sale_refunded",
75
+ SaleVoided: "sale_voided",
76
+ SaleReceiptSent: "sale_receipt_sent",
77
+ SaleViewed: "sale_viewed",
65
78
  } as const;
66
79
  export type WebhookCreateEvent = ClosedEnum<typeof WebhookCreateEvent>;
67
80
 
@@ -13,7 +13,6 @@ export const WebhookUpdateEvent = {
13
13
  InvoicePaymentFailed: "invoice_payment_failed",
14
14
  InvoiceDisputed: "invoice_disputed",
15
15
  InvoicePaymentReminder: "invoice_payment_reminder",
16
- InvoiceViewed: "invoice_viewed",
17
16
  PaymentReceived: "payment_received",
18
17
  PaymentRefunded: "payment_refunded",
19
18
  PaymentApplied: "payment_applied",
@@ -38,6 +37,7 @@ export const WebhookUpdateEvent = {
38
37
  ClientWon: "client_won",
39
38
  ClientLost: "client_lost",
40
39
  LeadStatusChanged: "lead_status_changed",
40
+ InvoiceViewed: "invoice_viewed",
41
41
  MilestoneApproaching: "milestone_approaching",
42
42
  TimerRunningReminder: "timer_running_reminder",
43
43
  ContractSent: "contract_sent",
@@ -48,12 +48,12 @@ export const WebhookUpdateEvent = {
48
48
  ContractCompleted: "contract_completed",
49
49
  ContractExpired: "contract_expired",
50
50
  ContractVoided: "contract_voided",
51
+ FormSubmissionCompleted: "form_submission_completed",
51
52
  SmartFileSent: "smart_file_sent",
52
53
  SmartFileViewed: "smart_file_viewed",
53
54
  SmartFileAccepted: "smart_file_accepted",
54
55
  SmartFileCompleted: "smart_file_completed",
55
56
  SmartFileExpired: "smart_file_expired",
56
- FormSubmissionCompleted: "form_submission_completed",
57
57
  SubscriptionPaymentFailed: "subscription_payment_failed",
58
58
  PayoutPaid: "payout_paid",
59
59
  PayoutFailed: "payout_failed",
@@ -62,6 +62,19 @@ export const WebhookUpdateEvent = {
62
62
  EventDayArchived: "event_day_archived",
63
63
  TimelineItemCompleted: "timeline_item_completed",
64
64
  TimelineReminderSent: "timeline_reminder_sent",
65
+ InvoiceRefunded: "invoice_refunded",
66
+ ContractAmended: "contract_amended",
67
+ ReceiptViewed: "receipt_viewed",
68
+ FollowUpDue: "follow_up_due",
69
+ PaymentProcessing: "payment_processing",
70
+ ClientReply: "client_reply",
71
+ ClientRevisionRequested: "client_revision_requested",
72
+ EmailDeliveryFailed: "email_delivery_failed",
73
+ SaleCompleted: "sale_completed",
74
+ SaleRefunded: "sale_refunded",
75
+ SaleVoided: "sale_voided",
76
+ SaleReceiptSent: "sale_receipt_sent",
77
+ SaleViewed: "sale_viewed",
65
78
  } as const;
66
79
  export type WebhookUpdateEvent = ClosedEnum<typeof WebhookUpdateEvent>;
67
80
 
@@ -18,7 +18,6 @@ export const WebhookEvent = {
18
18
  InvoicePaymentFailed: "invoice_payment_failed",
19
19
  InvoiceDisputed: "invoice_disputed",
20
20
  InvoicePaymentReminder: "invoice_payment_reminder",
21
- InvoiceViewed: "invoice_viewed",
22
21
  PaymentReceived: "payment_received",
23
22
  PaymentRefunded: "payment_refunded",
24
23
  PaymentApplied: "payment_applied",
@@ -43,6 +42,7 @@ export const WebhookEvent = {
43
42
  ClientWon: "client_won",
44
43
  ClientLost: "client_lost",
45
44
  LeadStatusChanged: "lead_status_changed",
45
+ InvoiceViewed: "invoice_viewed",
46
46
  MilestoneApproaching: "milestone_approaching",
47
47
  TimerRunningReminder: "timer_running_reminder",
48
48
  ContractSent: "contract_sent",
@@ -53,12 +53,12 @@ export const WebhookEvent = {
53
53
  ContractCompleted: "contract_completed",
54
54
  ContractExpired: "contract_expired",
55
55
  ContractVoided: "contract_voided",
56
+ FormSubmissionCompleted: "form_submission_completed",
56
57
  SmartFileSent: "smart_file_sent",
57
58
  SmartFileViewed: "smart_file_viewed",
58
59
  SmartFileAccepted: "smart_file_accepted",
59
60
  SmartFileCompleted: "smart_file_completed",
60
61
  SmartFileExpired: "smart_file_expired",
61
- FormSubmissionCompleted: "form_submission_completed",
62
62
  SubscriptionPaymentFailed: "subscription_payment_failed",
63
63
  PayoutPaid: "payout_paid",
64
64
  PayoutFailed: "payout_failed",
@@ -67,6 +67,19 @@ export const WebhookEvent = {
67
67
  EventDayArchived: "event_day_archived",
68
68
  TimelineItemCompleted: "timeline_item_completed",
69
69
  TimelineReminderSent: "timeline_reminder_sent",
70
+ InvoiceRefunded: "invoice_refunded",
71
+ ContractAmended: "contract_amended",
72
+ ReceiptViewed: "receipt_viewed",
73
+ FollowUpDue: "follow_up_due",
74
+ PaymentProcessing: "payment_processing",
75
+ ClientReply: "client_reply",
76
+ ClientRevisionRequested: "client_revision_requested",
77
+ EmailDeliveryFailed: "email_delivery_failed",
78
+ SaleCompleted: "sale_completed",
79
+ SaleRefunded: "sale_refunded",
80
+ SaleVoided: "sale_voided",
81
+ SaleReceiptSent: "sale_receipt_sent",
82
+ SaleViewed: "sale_viewed",
70
83
  } as const;
71
84
  export type WebhookEvent = OpenEnum<typeof WebhookEvent>;
72
85
 
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { salesGet } from "../funcs/sales-get.js";
6
+ import { salesList } from "../funcs/sales-list.js";
7
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
8
+ import * as models from "../models/index.js";
9
+ import * as operations from "../models/operations/index.js";
10
+ import { unwrapAsync } from "../types/fp.js";
11
+ import { PageIterator, unwrapResultIterator } from "../types/operations.js";
12
+
13
+ export class Sales extends ClientSDK {
14
+ /**
15
+ * List sales
16
+ */
17
+ async list(
18
+ security: operations.ListSalesSecurity,
19
+ request?: operations.ListSalesRequest | undefined,
20
+ options?: RequestOptions,
21
+ ): Promise<PageIterator<operations.ListSalesResponse, { page: number }>> {
22
+ return unwrapResultIterator(salesList(
23
+ this,
24
+ security,
25
+ request,
26
+ options,
27
+ ));
28
+ }
29
+
30
+ /**
31
+ * Get a sale
32
+ */
33
+ async get(
34
+ security: operations.GetSaleSecurity,
35
+ request: operations.GetSaleRequest,
36
+ options?: RequestOptions,
37
+ ): Promise<models.Sale> {
38
+ return unwrapAsync(salesGet(
39
+ this,
40
+ security,
41
+ request,
42
+ options,
43
+ ));
44
+ }
45
+ }
package/src/sdk/sdk.ts CHANGED
@@ -20,6 +20,7 @@ import { Milestones } from "./milestones.js";
20
20
  import { Payments } from "./payments.js";
21
21
  import { Payouts } from "./payouts.js";
22
22
  import { Projects } from "./projects.js";
23
+ import { Sales } from "./sales.js";
23
24
  import { TimeEntries } from "./time-entries.js";
24
25
  import { TimelineItems } from "./timeline-items.js";
25
26
  import { Transactions } from "./transactions.js";
@@ -88,6 +89,11 @@ export class ClientCasa extends ClientSDK {
88
89
  return (this._payouts ??= new Payouts(this._options));
89
90
  }
90
91
 
92
+ private _sales?: Sales;
93
+ get sales(): Sales {
94
+ return (this._sales ??= new Sales(this._options));
95
+ }
96
+
91
97
  private _timeEntries?: TimeEntries;
92
98
  get timeEntries(): TimeEntries {
93
99
  return (this._timeEntries ??= new TimeEntries(this._options));