|
| 1 | +import "../shared/index.tsp"; |
| 2 | + |
| 3 | +namespace Customers; |
| 4 | + |
| 5 | +/** |
| 6 | + * Customers can be individuals or organizations that can subscribe to plans and have access to features. |
| 7 | + */ |
| 8 | +@friendlyName("BillingCustomer") |
| 9 | +model Customer { |
| 10 | + ...Shared.Resource; |
| 11 | + |
| 12 | + #suppress "@openmeter/api-spec/doc-decorator" "shared model" |
| 13 | + @visibility(Lifecycle.Create, Lifecycle.Read) |
| 14 | + key: Shared.ExternalResourceKey; |
| 15 | + |
| 16 | + /** |
| 17 | + * Mapping to attribute metered usage to the customer by the event subject. |
| 18 | + */ |
| 19 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 20 | + @summary("Usage Attribution") |
| 21 | + usage_attribution?: CustomerUsageAttribution; |
| 22 | + |
| 23 | + /** |
| 24 | + * The primary email address of the customer. |
| 25 | + */ |
| 26 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 27 | + @summary("Primary Email") |
| 28 | + primary_email?: string; |
| 29 | + |
| 30 | + /** |
| 31 | + * Currency of the customer. |
| 32 | + * Used for billing, tax and invoicing. |
| 33 | + */ |
| 34 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 35 | + @summary("Currency") |
| 36 | + currency?: Shared.CurrencyCode; |
| 37 | + |
| 38 | + /** |
| 39 | + * The billing address of the customer. |
| 40 | + * Used for tax and invoicing. |
| 41 | + */ |
| 42 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 43 | + @summary("Billing Address") |
| 44 | + billing_address?: Address; |
| 45 | +} |
| 46 | + |
| 47 | +/** |
| 48 | + * Address |
| 49 | + */ |
| 50 | +@friendlyName("BillingAddress") |
| 51 | +model Address { |
| 52 | + /** |
| 53 | + * Country code in [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) alpha-2 format. |
| 54 | + */ |
| 55 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 56 | + @summary("Country") |
| 57 | + country?: Shared.CountryCode; |
| 58 | + |
| 59 | + /** |
| 60 | + * Postal code. |
| 61 | + */ |
| 62 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 63 | + @summary("Postal Code") |
| 64 | + postal_code?: string; |
| 65 | + |
| 66 | + /** |
| 67 | + * State or province. |
| 68 | + */ |
| 69 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 70 | + @summary("State") |
| 71 | + state?: string; |
| 72 | + |
| 73 | + /** |
| 74 | + * City. |
| 75 | + */ |
| 76 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 77 | + @summary("City") |
| 78 | + city?: string; |
| 79 | + |
| 80 | + /** |
| 81 | + * First line of the address. |
| 82 | + */ |
| 83 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 84 | + @summary("Line 1") |
| 85 | + line1?: string; |
| 86 | + |
| 87 | + /** |
| 88 | + * Second line of the address. |
| 89 | + */ |
| 90 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 91 | + @summary("Line 2") |
| 92 | + line2?: string; |
| 93 | + |
| 94 | + /** |
| 95 | + * Phone number. |
| 96 | + */ |
| 97 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 98 | + @summary("Phone Number") |
| 99 | + phone_number?: string; |
| 100 | +} |
| 101 | + |
| 102 | +/** |
| 103 | + * Mapping to attribute metered usage to the customer. |
| 104 | + * One customer can have zero or more subjects, |
| 105 | + * but one subject can only belong to one customer. |
| 106 | + */ |
| 107 | +@friendlyName("BillingCustomerUsageAttribution") |
| 108 | +model CustomerUsageAttribution { |
| 109 | + /** |
| 110 | + * The subjects that are attributed to the customer. |
| 111 | + * Can be empty when no usage event subjects are associated with the customer. |
| 112 | + */ |
| 113 | + @visibility(Lifecycle.Create, Lifecycle.Read, Lifecycle.Update) |
| 114 | + @summary("Subject Keys") |
| 115 | + @minItems(0) |
| 116 | + subject_keys: UsageAttributionSubjectKey[]; |
| 117 | +} |
| 118 | + |
| 119 | +/** |
| 120 | + * Subject key. |
| 121 | + */ |
| 122 | +@minLength(1) |
| 123 | +@friendlyName("UsageAttributionSubjectKey") |
| 124 | +scalar UsageAttributionSubjectKey extends string; |
0 commit comments