From 723121ce5ddf2b46f05fef5e30ea2c73db5e6b44 Mon Sep 17 00:00:00 2001 From: Maciej Nedza Date: Wed, 5 Jun 2024 09:22:14 +0200 Subject: [PATCH] [DE-801] Fix invoice events structure --- advance_invoice_controller.go | 2 +- doc/controllers/events.md | 12 +- doc/controllers/invoices.md | 2 +- doc/controllers/product-families.md | 2 +- doc/controllers/subscription-components.md | 6 +- doc/models/apply-credit-note-event-data.md | 2 +- doc/models/apply-credit-note-event.md | 62 +++ doc/models/apply-debit-note-event-data.md | 6 +- doc/models/apply-debit-note-event.md | 45 +++ doc/models/apply-payment-event-data.md | 4 +- doc/models/apply-payment-event.md | 52 +++ doc/models/backport-invoice-event.md | 47 +++ doc/models/billing-address.md | 30 -- .../change-chargeback-status-event-data.md | 23 ++ doc/models/change-chargeback-status-event.md | 40 ++ .../change-invoice-collection-method-event.md | 41 ++ .../change-invoice-status-event-data.md | 31 ++ doc/models/change-invoice-status-event.md | 44 +++ doc/models/chargeback-status.md | 18 + .../invoice-event-data-payment-method.md | 17 - .../containers/invoice-event-event-data.md | 21 -- ...-payment-2.md => invoice-event-payment.md} | 4 +- doc/models/containers/invoice-event.md | 27 ++ doc/models/containers/refund-segment-uids.md | 14 - doc/models/create-credit-note-event.md | 44 +++ doc/models/create-debit-note-event.md | 44 +++ doc/models/create-product-family-request.md | 1 + doc/models/create-product-family.md | 4 +- doc/models/create-subscription-request.md | 1 - doc/models/create-subscription.md | 3 +- doc/models/credit-note-1.md | 51 --- doc/models/customer-1.md | 31 -- doc/models/debit-note-role.md | 16 + doc/models/debit-note-status.md | 18 + doc/models/debit-note.md | 47 +++ doc/models/failed-payment-event-data.md | 31 ++ doc/models/failed-payment-event.md | 44 +++ doc/models/historic-usage.md | 2 +- doc/models/invoice-event-data.md | 58 --- doc/models/invoice-event-payment-1.md | 43 --- doc/models/invoice-event-payment.md | 37 -- doc/models/invoice-event-type.md | 1 + doc/models/invoice-event.md | 55 --- doc/models/invoice-response.md | 1 - doc/models/invoice-status.md | 2 +- doc/models/invoice.md | 5 +- doc/models/issue-invoice-event-data.md | 4 +- doc/models/issue-invoice-event.md | 44 +++ doc/models/list-invoice-events-response.md | 40 +- doc/models/list-invoices-response.md | 1 - doc/models/paid-invoice.md | 2 +- doc/models/payment-method-apple-pay.md | 2 +- doc/models/payment-method-bank-account.md | 2 +- doc/models/payment-method-credit-card.md | 6 +- doc/models/payment-method-external.md | 2 +- doc/models/payment-method-paypal.md | 2 +- doc/models/price-point.md | 43 --- doc/models/proforma-invoice.md | 3 +- doc/models/refund-invoice-event.md | 54 +++ doc/models/refund.md | 31 -- doc/models/remove-payment-event-data.md | 6 +- doc/models/remove-payment-event.md | 48 +++ doc/models/seller.md | 33 -- doc/models/shipping-address.md | 30 -- doc/models/subscription-group-response.md | 2 +- .../subscription-group-signup-request.md | 2 +- .../subscription-group-signup-response.md | 3 +- doc/models/subscription-group-signup.md | 4 +- doc/models/subscription-group.md | 4 +- doc/models/subscription.md | 3 +- doc/models/void-invoice-event.md | 51 +++ doc/models/void-remainder-event.md | 49 +++ events_controller.go | 12 +- go.mod | 2 +- invoices_controller.go | 2 +- models/apply_credit_note_event.go | 102 +++++ models/apply_credit_note_event_data.go | 12 +- models/apply_debit_note_event.go | 102 +++++ models/apply_debit_note_event_data.go | 56 ++- models/apply_payment_event.go | 102 +++++ models/apply_payment_event_data.go | 51 +-- models/backport_invoice_event.go | 102 +++++ models/billing_address.go | 106 ------ models/change_chargeback_status_event.go | 102 +++++ models/change_chargeback_status_event_data.go | 68 ++++ .../change_invoice_collection_method_event.go | 102 +++++ models/change_invoice_status_event.go | 102 +++++ models/change_invoice_status_event_data.go | 97 +++++ models/create_credit_note_event.go | 102 +++++ models/create_debit_note_event.go | 102 +++++ models/create_product_family.go | 37 +- models/credit_note_1.go | 245 ------------ models/customer_1.go | 104 ------ models/debit_note.go | 227 +++++++++++ models/enums.go | 147 +++++++- models/failed_payment_event.go | 102 +++++ models/failed_payment_event_data.go | 103 +++++ models/historic_usage.go | 2 +- models/invoice.go | 2 +- models/invoice_event.go | 352 +++++++++++++++--- models/invoice_event_data.go | 288 -------------- models/invoice_event_data_payment_method.go | 150 -------- models/invoice_event_event_data.go | 222 ----------- models/invoice_event_payment.go | 210 ++++++----- models/invoice_event_payment_1.go | 143 ------- models/invoice_event_payment_2.go | 150 -------- models/issue_invoice_event.go | 102 +++++ models/issue_invoice_event_data.go | 4 +- models/paid_invoice.go | 2 +- models/payment_method_apple_pay.go | 5 + models/price_point.go | 132 ------- models/refund.go | 95 ----- models/refund_invoice_event.go | 102 +++++ models/refund_segment_uids.go | 96 ----- models/remove_payment_event.go | 102 +++++ models/remove_payment_event_data.go | 30 +- models/seller.go | 74 ---- models/shipping_address.go | 106 ------ models/void_invoice_event.go | 102 +++++ models/void_remainder_event.go | 102 +++++ subscription_components_controller.go | 11 +- test/go.mod | 2 +- test/go.sum | 4 +- test/suite.go | 2 +- 124 files changed, 3739 insertions(+), 2704 deletions(-) create mode 100644 doc/models/apply-credit-note-event.md create mode 100644 doc/models/apply-debit-note-event.md create mode 100644 doc/models/apply-payment-event.md create mode 100644 doc/models/backport-invoice-event.md delete mode 100644 doc/models/billing-address.md create mode 100644 doc/models/change-chargeback-status-event-data.md create mode 100644 doc/models/change-chargeback-status-event.md create mode 100644 doc/models/change-invoice-collection-method-event.md create mode 100644 doc/models/change-invoice-status-event-data.md create mode 100644 doc/models/change-invoice-status-event.md create mode 100644 doc/models/chargeback-status.md delete mode 100644 doc/models/containers/invoice-event-data-payment-method.md delete mode 100644 doc/models/containers/invoice-event-event-data.md rename doc/models/containers/{invoice-event-payment-2.md => invoice-event-payment.md} (95%) create mode 100644 doc/models/containers/invoice-event.md delete mode 100644 doc/models/containers/refund-segment-uids.md create mode 100644 doc/models/create-credit-note-event.md create mode 100644 doc/models/create-debit-note-event.md delete mode 100644 doc/models/credit-note-1.md delete mode 100644 doc/models/customer-1.md create mode 100644 doc/models/debit-note-role.md create mode 100644 doc/models/debit-note-status.md create mode 100644 doc/models/debit-note.md create mode 100644 doc/models/failed-payment-event-data.md create mode 100644 doc/models/failed-payment-event.md delete mode 100644 doc/models/invoice-event-data.md delete mode 100644 doc/models/invoice-event-payment-1.md delete mode 100644 doc/models/invoice-event-payment.md delete mode 100644 doc/models/invoice-event.md create mode 100644 doc/models/issue-invoice-event.md delete mode 100644 doc/models/price-point.md create mode 100644 doc/models/refund-invoice-event.md delete mode 100644 doc/models/refund.md create mode 100644 doc/models/remove-payment-event.md delete mode 100644 doc/models/seller.md delete mode 100644 doc/models/shipping-address.md create mode 100644 doc/models/void-invoice-event.md create mode 100644 doc/models/void-remainder-event.md create mode 100644 models/apply_credit_note_event.go create mode 100644 models/apply_debit_note_event.go create mode 100644 models/apply_payment_event.go create mode 100644 models/backport_invoice_event.go delete mode 100644 models/billing_address.go create mode 100644 models/change_chargeback_status_event.go create mode 100644 models/change_chargeback_status_event_data.go create mode 100644 models/change_invoice_collection_method_event.go create mode 100644 models/change_invoice_status_event.go create mode 100644 models/change_invoice_status_event_data.go create mode 100644 models/create_credit_note_event.go create mode 100644 models/create_debit_note_event.go delete mode 100644 models/credit_note_1.go delete mode 100644 models/customer_1.go create mode 100644 models/debit_note.go create mode 100644 models/failed_payment_event.go create mode 100644 models/failed_payment_event_data.go delete mode 100644 models/invoice_event_data.go delete mode 100644 models/invoice_event_data_payment_method.go delete mode 100644 models/invoice_event_event_data.go delete mode 100644 models/invoice_event_payment_1.go delete mode 100644 models/invoice_event_payment_2.go create mode 100644 models/issue_invoice_event.go delete mode 100644 models/price_point.go delete mode 100644 models/refund.go create mode 100644 models/refund_invoice_event.go delete mode 100644 models/refund_segment_uids.go create mode 100644 models/remove_payment_event.go delete mode 100644 models/seller.go delete mode 100644 models/shipping_address.go create mode 100644 models/void_invoice_event.go create mode 100644 models/void_remainder_event.go diff --git a/advance_invoice_controller.go b/advance_invoice_controller.go index 256bc595..fe69ee12 100644 --- a/advance_invoice_controller.go +++ b/advance_invoice_controller.go @@ -24,7 +24,7 @@ func NewAdvanceInvoiceController(baseController baseController) *AdvanceInvoiceC // IssueAdvanceInvoice takes context, subscriptionId, body as parameters and // returns an models.ApiResponse with models.Invoice data and // an error if there was an issue with the request or response. -// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404811062541-Issue-Invoice-In-Advance ) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided. +// Generate an invoice in advance for a subscription's next renewal date. [Please see our docs](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404811062541-Issue-Invoice-In-Advance) for more information on advance invoices, including eligibility on generating one; for the most part, they function like any other invoice, except they are issued early and have special behavior upon being voided. // A subscription may only have one advance invoice per billing period. Attempting to issue an advance invoice when one already exists will return an error. // That said, regeneration of the invoice may be forced with the params `force: true`, which will void an advance invoice if one exists and generate a new one. If no advance invoice exists, a new one will be generated. // We recommend using either the create or preview endpoints for proforma invoices to preview this advance invoice before using this endpoint to generate it. diff --git a/doc/controllers/events.md b/doc/controllers/events.md index d2483307..81e70708 100644 --- a/doc/controllers/events.md +++ b/doc/controllers/events.md @@ -94,8 +94,8 @@ ListEvents( | --- | --- | --- | --- | | `page` | `*int` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`. | | `perPage` | `*int` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
Use in query `per_page=200`. | -| `sinceId` | `*int` | Query, Optional | Returns events with an id greater than or equal to the one specified | -| `maxId` | `*int` | Query, Optional | Returns events with an id less than or equal to the one specified | +| `sinceId` | `*int64` | Query, Optional | Returns events with an id greater than or equal to the one specified | +| `maxId` | `*int64` | Query, Optional | Returns events with an id less than or equal to the one specified | | `direction` | [`*models.Direction`](../../doc/models/direction.md) | Query, Optional | The sort direction of the returned events. | | `filter` | [`[]models.EventType`](../../doc/models/event-type.md) | Query, Optional | You can pass multiple event keys after comma.
Use in query `filter=signup_success,payment_success`. | | `dateField` | [`*models.ListEventsDateField`](../../doc/models/list-events-date-field.md) | Query, Optional | The type of filter you would like to apply to your search. | @@ -218,8 +218,8 @@ ListSubscriptionEvents( | `subscriptionId` | `int` | Template, Required | The Chargify id of the subscription | | `page` | `*int` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`. | | `perPage` | `*int` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
Use in query `per_page=200`. | -| `sinceId` | `*int` | Query, Optional | Returns events with an id greater than or equal to the one specified | -| `maxId` | `*int` | Query, Optional | Returns events with an id less than or equal to the one specified | +| `sinceId` | `*int64` | Query, Optional | Returns events with an id greater than or equal to the one specified | +| `maxId` | `*int64` | Query, Optional | Returns events with an id less than or equal to the one specified | | `direction` | [`*models.Direction`](../../doc/models/direction.md) | Query, Optional | The sort direction of the returned events. | | `filter` | [`[]models.EventType`](../../doc/models/event-type.md) | Query, Optional | You can pass multiple event keys after comma.
Use in query `filter=signup_success,payment_success`. | @@ -315,8 +315,8 @@ ReadEventsCount( | --- | --- | --- | --- | | `page` | `*int` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`. | | `perPage` | `*int` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200.
Use in query `per_page=200`. | -| `sinceId` | `*int` | Query, Optional | Returns events with an id greater than or equal to the one specified | -| `maxId` | `*int` | Query, Optional | Returns events with an id less than or equal to the one specified | +| `sinceId` | `*int64` | Query, Optional | Returns events with an id greater than or equal to the one specified | +| `maxId` | `*int64` | Query, Optional | Returns events with an id less than or equal to the one specified | | `direction` | [`*models.Direction`](../../doc/models/direction.md) | Query, Optional | The sort direction of the returned events. | | `filter` | [`[]models.EventType`](../../doc/models/event-type.md) | Query, Optional | You can pass multiple event keys after comma.
Use in query `filter=signup_success,payment_success`. | diff --git a/doc/controllers/invoices.md b/doc/controllers/invoices.md index 780ffa3c..99da25c4 100644 --- a/doc/controllers/invoices.md +++ b/doc/controllers/invoices.md @@ -655,7 +655,7 @@ ListInvoiceEvents( | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `sinceDate` | `*string` | Query, Optional | The timestamp in a format `YYYY-MM-DD T HH:MM:SS Z`, or `YYYY-MM-DD`(in this case, it returns data from the beginning of the day). of the event from which you want to start the search. All the events before the `since_date` timestamp are not returned in the response. | -| `sinceId` | `*int` | Query, Optional | The ID of the event from which you want to start the search(ID is not included. e.g. if ID is set to 2, then all events with ID 3 and more will be shown) This parameter is not used if since_date is defined. | +| `sinceId` | `*int64` | Query, Optional | The ID of the event from which you want to start the search(ID is not included. e.g. if ID is set to 2, then all events with ID 3 and more will be shown) This parameter is not used if since_date is defined. | | `page` | `*int` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`. | | `perPage` | `*int` | Query, Optional | This parameter indicates how many records to fetch in each request. Default value is 100. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. | | `invoiceUid` | `*string` | Query, Optional | Providing an invoice_uid allows for scoping of the invoice events to a single invoice or credit note. | diff --git a/doc/controllers/product-families.md b/doc/controllers/product-families.md index 1859273a..00dd7d17 100644 --- a/doc/controllers/product-families.md +++ b/doc/controllers/product-families.md @@ -208,7 +208,7 @@ ctx := context.Background() body := models.CreateProductFamilyRequest{ ProductFamily: models.CreateProductFamily{ - Name: models.ToPointer("Acme Projects"), + Name: "Acme Projects", Description: models.NewOptional(models.ToPointer("Amazing project management tool")), }, } diff --git a/doc/controllers/subscription-components.md b/doc/controllers/subscription-components.md index 2d424a62..80b28967 100644 --- a/doc/controllers/subscription-components.md +++ b/doc/controllers/subscription-components.md @@ -130,6 +130,7 @@ ListSubscriptionComponents( | `startDate` | `*string` | Query, Optional | The start date (format YYYY-MM-DD) with which to filter the date_field. Returns components with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. | | `startDatetime` | `*string` | Query, Optional | The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns components with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site''s time zone will be used. If provided, this parameter will be used instead of start_date. | | `include` | [`[]models.ListSubscriptionComponentsInclude`](../../doc/models/list-subscription-components-include.md) | Query, Optional | Allows including additional data in the response. Use in query `include=subscription,historic_usages`. | +| `inUse` | `*bool` | Query, Optional | If in_use is set to true, it returns only components that are currently in use. However, if it's set to false or not provided, it returns all components connected with the subscription. | ## Response Type @@ -160,6 +161,7 @@ collectedInput := advancedbilling.ListSubscriptionComponentsInput{ models.ListSubscriptionComponentsInclude("subscription"), models.ListSubscriptionComponentsInclude("historic_usages"), }, + InUse: models.ToPointer(true), } apiResponse, err := subscriptionComponentsController.ListSubscriptionComponents(ctx, collectedInput) @@ -1272,8 +1274,8 @@ ListUsages( | --- | --- | --- | --- | | `subscriptionId` | `int` | Template, Required | The Chargify id of the subscription | | `componentId` | [`models.ListUsagesInputComponentId`](../../doc/models/containers/list-usages-input-component-id.md) | Template, Required | This is a container for one-of cases. | -| `sinceId` | `*int` | Query, Optional | Returns usages with an id greater than or equal to the one specified | -| `maxId` | `*int` | Query, Optional | Returns usages with an id less than or equal to the one specified | +| `sinceId` | `*int64` | Query, Optional | Returns usages with an id greater than or equal to the one specified | +| `maxId` | `*int64` | Query, Optional | Returns usages with an id less than or equal to the one specified | | `sinceDate` | `*time.Time` | Query, Optional | Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the date specified. | | `untilDate` | `*time.Time` | Query, Optional | Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date specified. | | `page` | `*int` | Query, Optional | Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned.
Use in query `page=1`. | diff --git a/doc/models/apply-credit-note-event-data.md b/doc/models/apply-credit-note-event-data.md index 04fd1b45..b69c88c4 100644 --- a/doc/models/apply-credit-note-event-data.md +++ b/doc/models/apply-credit-note-event-data.md @@ -17,7 +17,7 @@ Example schema for an `apply_credit_note` event | `OriginalAmount` | `string` | Required | The full, original amount of the credit note. | | `AppliedAmount` | `string` | Required | The amount of the credit note applied to invoice. | | `TransactionTime` | `*time.Time` | Optional | The time the credit note was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" | -| `Memo` | `*string` | Optional | The credit note memo. | +| `Memo` | `models.Optional[string]` | Optional | The credit note memo. | | `Role` | `*string` | Optional | The role of the credit note (e.g. 'general') | | `ConsolidatedInvoice` | `*bool` | Optional | Shows whether it was applied to consolidated invoice or not | | `AppliedCreditNotes` | [`[]models.AppliedCreditNoteData`](../../doc/models/applied-credit-note-data.md) | Optional | List of credit notes applied to children invoices (if consolidated invoice) | diff --git a/doc/models/apply-credit-note-event.md b/doc/models/apply-credit-note-event.md new file mode 100644 index 00000000..5db71200 --- /dev/null +++ b/doc/models/apply-credit-note-event.md @@ -0,0 +1,62 @@ + +# Apply Credit Note Event + +## Structure + +`ApplyCreditNoteEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"apply_credit_note"` | +| `EventData` | [`models.ApplyCreditNoteEventData`](../../doc/models/apply-credit-note-event-data.md) | Required | Example schema for an `apply_credit_note` event | + +## Example (as JSON) + +```json +{ + "id": 214, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "apply_credit_note", + "event_data": { + "uid": "uid6", + "credit_note_number": "credit_note_number0", + "credit_note_uid": "credit_note_uid0", + "original_amount": "original_amount0", + "applied_amount": "applied_amount2", + "transaction_time": "2016-03-13T12:52:32.123Z", + "memo": "memo0", + "role": "role0", + "consolidated_invoice": false, + "applied_credit_notes": [ + { + "uid": "uid4", + "number": "number8" + }, + { + "uid": "uid4", + "number": "number8" + }, + { + "uid": "uid4", + "number": "number8" + } + ] + } +} +``` + diff --git a/doc/models/apply-debit-note-event-data.md b/doc/models/apply-debit-note-event-data.md index 24cdbbd0..d50c1d55 100644 --- a/doc/models/apply-debit-note-event-data.md +++ b/doc/models/apply-debit-note-event-data.md @@ -15,6 +15,8 @@ Example schema for an `apply_debit_note` event | `DebitNoteUid` | `string` | Required | Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix "db_" followed by alphanumeric characters. | | `OriginalAmount` | `string` | Required | The full, original amount of the debit note. | | `AppliedAmount` | `string` | Required | The amount of the debit note applied to invoice. | +| `Memo` | `models.Optional[string]` | Optional | The debit note memo. | +| `TransactionTime` | `models.Optional[time.Time]` | Optional | The time the debit note was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" | ## Example (as JSON) @@ -23,7 +25,9 @@ Example schema for an `apply_debit_note` event "debit_note_number": "debit_note_number0", "debit_note_uid": "debit_note_uid6", "original_amount": "original_amount4", - "applied_amount": "applied_amount8" + "applied_amount": "applied_amount8", + "memo": "memo4", + "transaction_time": "2016-03-13T12:52:32.123Z" } ``` diff --git a/doc/models/apply-debit-note-event.md b/doc/models/apply-debit-note-event.md new file mode 100644 index 00000000..f7892def --- /dev/null +++ b/doc/models/apply-debit-note-event.md @@ -0,0 +1,45 @@ + +# Apply Debit Note Event + +## Structure + +`ApplyDebitNoteEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"apply_debit_note"` | +| `EventData` | [`models.ApplyDebitNoteEventData`](../../doc/models/apply-debit-note-event-data.md) | Required | Example schema for an `apply_debit_note` event | + +## Example (as JSON) + +```json +{ + "id": 164, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "apply_debit_note", + "event_data": { + "debit_note_number": "debit_note_number6", + "debit_note_uid": "debit_note_uid2", + "original_amount": "original_amount0", + "applied_amount": "applied_amount2", + "memo": "memo0", + "transaction_time": "2016-03-13T12:52:32.123Z" + } +} +``` + diff --git a/doc/models/apply-payment-event-data.md b/doc/models/apply-payment-event-data.md index ebda7c34..5e5b6687 100644 --- a/doc/models/apply-payment-event-data.md +++ b/doc/models/apply-payment-event-data.md @@ -11,11 +11,12 @@ Example schema for an `apply_payment` event | Name | Type | Tags | Description | | --- | --- | --- | --- | +| `ConsolidationLevel` | [`models.InvoiceConsolidationLevel`](../../doc/models/invoice-consolidation-level.md) | Required | - | | `Memo` | `string` | Required | The payment memo | | `OriginalAmount` | `string` | Required | The full, original amount of the payment transaction as a string in full units. Incoming payments can be split amongst several invoices, which will result in a `applied_amount` less than the `original_amount`. Example: A $100.99 payment, of which $40.11 is applied to this invoice, will have an `original_amount` of `"100.99"`. | | `AppliedAmount` | `string` | Required | The amount of the payment applied to this invoice. Incoming payments can be split amongst several invoices, which will result in a `applied_amount` less than the `original_amount`. Example: A $100.99 payment, of which $40.11 is applied to this invoice, will have an `applied_amount` of `"40.11"`. | | `TransactionTime` | `time.Time` | Required | The time the payment was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" | -| `PaymentMethod` | [`models.InvoiceEventPayment2`](../../doc/models/containers/invoice-event-payment-2.md) | Required | A nested data structure detailing the method of payment | +| `PaymentMethod` | [`models.InvoiceEventPayment`](../../doc/models/containers/invoice-event-payment.md) | Required | A nested data structure detailing the method of payment | | `TransactionId` | `*int` | Optional | The Chargify id of the original payment | | `ParentInvoiceNumber` | `models.Optional[int]` | Optional | - | | `RemainingPrepaymentAmount` | `models.Optional[string]` | Optional | - | @@ -26,6 +27,7 @@ Example schema for an `apply_payment` event ```json { + "consolidation_level": "child", "memo": "memo8", "original_amount": "original_amount8", "applied_amount": "applied_amount4", diff --git a/doc/models/apply-payment-event.md b/doc/models/apply-payment-event.md new file mode 100644 index 00000000..f9722584 --- /dev/null +++ b/doc/models/apply-payment-event.md @@ -0,0 +1,52 @@ + +# Apply Payment Event + +## Structure + +`ApplyPaymentEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"apply_payment"` | +| `EventData` | [`models.ApplyPaymentEventData`](../../doc/models/apply-payment-event-data.md) | Required | Example schema for an `apply_payment` event | + +## Example (as JSON) + +```json +{ + "id": 234, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "apply_payment", + "event_data": { + "consolidation_level": "child", + "memo": "memo0", + "original_amount": "original_amount0", + "applied_amount": "applied_amount2", + "transaction_time": "2016-03-13T12:52:32.123Z", + "payment_method": { + "type": "apple_pay" + }, + "transaction_id": 78, + "parent_invoice_number": 36, + "remaining_prepayment_amount": "remaining_prepayment_amount6", + "prepayment": false, + "external": false + } +} +``` + diff --git a/doc/models/backport-invoice-event.md b/doc/models/backport-invoice-event.md new file mode 100644 index 00000000..bc4c232c --- /dev/null +++ b/doc/models/backport-invoice-event.md @@ -0,0 +1,47 @@ + +# Backport Invoice Event + +## Structure + +`BackportInvoiceEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"backport_invoice"` | +| `EventData` | [`models.Invoice`](../../doc/models/invoice.md) | Required | Example schema for an `backport_invoice` event | + +## Example (as JSON) + +```json +{ + "id": 78, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "backport_invoice", + "event_data": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 206, + "uid": "uid6", + "site_id": 132, + "customer_id": 244, + "subscription_id": 60 + } +} +``` + diff --git a/doc/models/billing-address.md b/doc/models/billing-address.md deleted file mode 100644 index a3a53b7d..00000000 --- a/doc/models/billing-address.md +++ /dev/null @@ -1,30 +0,0 @@ - -# Billing Address - -## Structure - -`BillingAddress` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Street` | `models.Optional[string]` | Optional | - | -| `Line2` | `models.Optional[string]` | Optional | - | -| `City` | `models.Optional[string]` | Optional | - | -| `State` | `models.Optional[string]` | Optional | - | -| `Zip` | `models.Optional[string]` | Optional | - | -| `Country` | `models.Optional[string]` | Optional | - | - -## Example (as JSON) - -```json -{ - "street": "street6", - "line2": "line20", - "city": "city6", - "state": "state2", - "zip": "zip0" -} -``` - diff --git a/doc/models/change-chargeback-status-event-data.md b/doc/models/change-chargeback-status-event-data.md new file mode 100644 index 00000000..760d8894 --- /dev/null +++ b/doc/models/change-chargeback-status-event-data.md @@ -0,0 +1,23 @@ + +# Change Chargeback Status Event Data + +Example schema for an `change_chargeback_status` event + +## Structure + +`ChangeChargebackStatusEventData` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `ChargebackStatus` | [`models.ChargebackStatus`](../../doc/models/chargeback-status.md) | Required | - | + +## Example (as JSON) + +```json +{ + "chargeback_status": "open" +} +``` + diff --git a/doc/models/change-chargeback-status-event.md b/doc/models/change-chargeback-status-event.md new file mode 100644 index 00000000..4a067d53 --- /dev/null +++ b/doc/models/change-chargeback-status-event.md @@ -0,0 +1,40 @@ + +# Change Chargeback Status Event + +## Structure + +`ChangeChargebackStatusEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"change_chargeback_status"` | +| `EventData` | [`models.ChangeChargebackStatusEventData`](../../doc/models/change-chargeback-status-event-data.md) | Required | Example schema for an `change_chargeback_status` event | + +## Example (as JSON) + +```json +{ + "id": 214, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "change_chargeback_status", + "event_data": { + "chargeback_status": "won" + } +} +``` + diff --git a/doc/models/change-invoice-collection-method-event.md b/doc/models/change-invoice-collection-method-event.md new file mode 100644 index 00000000..5a3da867 --- /dev/null +++ b/doc/models/change-invoice-collection-method-event.md @@ -0,0 +1,41 @@ + +# Change Invoice Collection Method Event + +## Structure + +`ChangeInvoiceCollectionMethodEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"change_invoice_collection_method"` | +| `EventData` | [`models.ChangeInvoiceCollectionMethodEventData`](../../doc/models/change-invoice-collection-method-event-data.md) | Required | Example schema for an `change_invoice_collection_method` event | + +## Example (as JSON) + +```json +{ + "id": 246, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "change_invoice_collection_method", + "event_data": { + "from_collection_method": "from_collection_method4", + "to_collection_method": "to_collection_method8" + } +} +``` + diff --git a/doc/models/change-invoice-status-event-data.md b/doc/models/change-invoice-status-event-data.md new file mode 100644 index 00000000..1fac98ee --- /dev/null +++ b/doc/models/change-invoice-status-event-data.md @@ -0,0 +1,31 @@ + +# Change Invoice Status Event Data + +Example schema for an `change_invoice_status` event + +## Structure + +`ChangeInvoiceStatusEventData` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `GatewayTransId` | `*string` | Optional | Identifier for the transaction within the payment gateway. | +| `Amount` | `*string` | Optional | The monetary value associated with the linked payment, expressed in dollars. | +| `FromStatus` | [`models.InvoiceStatus`](../../doc/models/invoice-status.md) | Required | The status of the invoice before any changes occurred. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. | +| `ToStatus` | [`models.InvoiceStatus`](../../doc/models/invoice-status.md) | Required | The updated status of the invoice after changes have been made. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. | +| `ConsolidationLevel` | [`*models.InvoiceConsolidationLevel`](../../doc/models/invoice-consolidation-level.md) | Optional | - | + +## Example (as JSON) + +```json +{ + "gateway_trans_id": "gateway_trans_id2", + "amount": "amount2", + "from_status": "draft", + "to_status": "paid", + "consolidation_level": "none" +} +``` + diff --git a/doc/models/change-invoice-status-event.md b/doc/models/change-invoice-status-event.md new file mode 100644 index 00000000..aca89745 --- /dev/null +++ b/doc/models/change-invoice-status-event.md @@ -0,0 +1,44 @@ + +# Change Invoice Status Event + +## Structure + +`ChangeInvoiceStatusEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"change_invoice_status"` | +| `EventData` | [`models.ChangeInvoiceStatusEventData`](../../doc/models/change-invoice-status-event-data.md) | Required | Example schema for an `change_invoice_status` event | + +## Example (as JSON) + +```json +{ + "id": 92, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "change_invoice_status", + "event_data": { + "gateway_trans_id": "gateway_trans_id2", + "amount": "amount8", + "from_status": "paid", + "to_status": "paid", + "consolidation_level": "child" + } +} +``` + diff --git a/doc/models/chargeback-status.md b/doc/models/chargeback-status.md new file mode 100644 index 00000000..5541f264 --- /dev/null +++ b/doc/models/chargeback-status.md @@ -0,0 +1,18 @@ + +# Chargeback Status + +The current chargeback status. + +## Enumeration + +`ChargebackStatus` + +## Fields + +| Name | +| --- | +| `OPEN` | +| `LOST` | +| `WON` | +| `CLOSED` | + diff --git a/doc/models/containers/invoice-event-data-payment-method.md b/doc/models/containers/invoice-event-data-payment-method.md deleted file mode 100644 index b876e922..00000000 --- a/doc/models/containers/invoice-event-data-payment-method.md +++ /dev/null @@ -1,17 +0,0 @@ - -# Invoice Event Data Payment Method - -## Class Name - -`InvoiceEventDataPaymentMethod` - -## Cases - -| Type | Factory Method | -| --- | --- | -| [`models.PaymentMethodApplePay`](../../../doc/models/payment-method-apple-pay.md) | models.InvoiceEventDataPaymentMethodContainer.FromPaymentMethodApplePay(models.PaymentMethodApplePay paymentMethodApplePay) | -| [`models.PaymentMethodBankAccount`](../../../doc/models/payment-method-bank-account.md) | models.InvoiceEventDataPaymentMethodContainer.FromPaymentMethodBankAccount(models.PaymentMethodBankAccount paymentMethodBankAccount) | -| [`models.PaymentMethodCreditCard`](../../../doc/models/payment-method-credit-card.md) | models.InvoiceEventDataPaymentMethodContainer.FromPaymentMethodCreditCard(models.PaymentMethodCreditCard paymentMethodCreditCard) | -| [`models.PaymentMethodExternal`](../../../doc/models/payment-method-external.md) | models.InvoiceEventDataPaymentMethodContainer.FromPaymentMethodExternal(models.PaymentMethodExternal paymentMethodExternal) | -| [`models.PaymentMethodPaypal`](../../../doc/models/payment-method-paypal.md) | models.InvoiceEventDataPaymentMethodContainer.FromPaymentMethodPaypal(models.PaymentMethodPaypal paymentMethodPaypal) | - diff --git a/doc/models/containers/invoice-event-event-data.md b/doc/models/containers/invoice-event-event-data.md deleted file mode 100644 index 897ee977..00000000 --- a/doc/models/containers/invoice-event-event-data.md +++ /dev/null @@ -1,21 +0,0 @@ - -# Invoice Event Event Data - -## Class Name - -`InvoiceEventEventData` - -## Cases - -| Type | Factory Method | -| --- | --- | -| [`models.ApplyCreditNoteEventData`](../../../doc/models/apply-credit-note-event-data.md) | models.InvoiceEventEventDataContainer.FromApplyCreditNoteEventData(models.ApplyCreditNoteEventData applyCreditNoteEventData) | -| [`models.ApplyDebitNoteEventData`](../../../doc/models/apply-debit-note-event-data.md) | models.InvoiceEventEventDataContainer.FromApplyDebitNoteEventData(models.ApplyDebitNoteEventData applyDebitNoteEventData) | -| [`models.ApplyPaymentEventData`](../../../doc/models/apply-payment-event-data.md) | models.InvoiceEventEventDataContainer.FromApplyPaymentEventData(models.ApplyPaymentEventData applyPaymentEventData) | -| [`models.ChangeInvoiceCollectionMethodEventData`](../../../doc/models/change-invoice-collection-method-event-data.md) | models.InvoiceEventEventDataContainer.FromChangeInvoiceCollectionMethodEventData(models.ChangeInvoiceCollectionMethodEventData changeInvoiceCollectionMethodEventData) | -| [`models.IssueInvoiceEventData`](../../../doc/models/issue-invoice-event-data.md) | models.InvoiceEventEventDataContainer.FromIssueInvoiceEventData(models.IssueInvoiceEventData issueInvoiceEventData) | -| [`models.RefundInvoiceEventData`](../../../doc/models/refund-invoice-event-data.md) | models.InvoiceEventEventDataContainer.FromRefundInvoiceEventData(models.RefundInvoiceEventData refundInvoiceEventData) | -| [`models.RemovePaymentEventData`](../../../doc/models/remove-payment-event-data.md) | models.InvoiceEventEventDataContainer.FromRemovePaymentEventData(models.RemovePaymentEventData removePaymentEventData) | -| [`models.VoidInvoiceEventData`](../../../doc/models/void-invoice-event-data.md) | models.InvoiceEventEventDataContainer.FromVoidInvoiceEventData(models.VoidInvoiceEventData voidInvoiceEventData) | -| [`models.VoidRemainderEventData`](../../../doc/models/void-remainder-event-data.md) | models.InvoiceEventEventDataContainer.FromVoidRemainderEventData(models.VoidRemainderEventData voidRemainderEventData) | - diff --git a/doc/models/containers/invoice-event-payment-2.md b/doc/models/containers/invoice-event-payment.md similarity index 95% rename from doc/models/containers/invoice-event-payment-2.md rename to doc/models/containers/invoice-event-payment.md index c9f007d8..c8244138 100644 --- a/doc/models/containers/invoice-event-payment-2.md +++ b/doc/models/containers/invoice-event-payment.md @@ -1,9 +1,9 @@ -# Invoice Event Payment 2 +# Invoice Event Payment ## Class Name -`InvoiceEventPayment2` +`InvoiceEventPayment` ## Cases diff --git a/doc/models/containers/invoice-event.md b/doc/models/containers/invoice-event.md new file mode 100644 index 00000000..82dd3812 --- /dev/null +++ b/doc/models/containers/invoice-event.md @@ -0,0 +1,27 @@ + +# Invoice Event + +## Class Name + +`InvoiceEvent` + +## Cases + +| Type | Factory Method | +| --- | --- | +| [`models.ApplyCreditNoteEvent`](../../../doc/models/apply-credit-note-event.md) | models.InvoiceEventContainer.FromApplyCreditNoteEvent(models.ApplyCreditNoteEvent applyCreditNoteEvent) | +| [`models.ApplyDebitNoteEvent`](../../../doc/models/apply-debit-note-event.md) | models.InvoiceEventContainer.FromApplyDebitNoteEvent(models.ApplyDebitNoteEvent applyDebitNoteEvent) | +| [`models.ApplyPaymentEvent`](../../../doc/models/apply-payment-event.md) | models.InvoiceEventContainer.FromApplyPaymentEvent(models.ApplyPaymentEvent applyPaymentEvent) | +| [`models.BackportInvoiceEvent`](../../../doc/models/backport-invoice-event.md) | models.InvoiceEventContainer.FromBackportInvoiceEvent(models.BackportInvoiceEvent backportInvoiceEvent) | +| [`models.ChangeChargebackStatusEvent`](../../../doc/models/change-chargeback-status-event.md) | models.InvoiceEventContainer.FromChangeChargebackStatusEvent(models.ChangeChargebackStatusEvent changeChargebackStatusEvent) | +| [`models.ChangeInvoiceCollectionMethodEvent`](../../../doc/models/change-invoice-collection-method-event.md) | models.InvoiceEventContainer.FromChangeInvoiceCollectionMethodEvent(models.ChangeInvoiceCollectionMethodEvent changeInvoiceCollectionMethodEvent) | +| [`models.ChangeInvoiceStatusEvent`](../../../doc/models/change-invoice-status-event.md) | models.InvoiceEventContainer.FromChangeInvoiceStatusEvent(models.ChangeInvoiceStatusEvent changeInvoiceStatusEvent) | +| [`models.CreateCreditNoteEvent`](../../../doc/models/create-credit-note-event.md) | models.InvoiceEventContainer.FromCreateCreditNoteEvent(models.CreateCreditNoteEvent createCreditNoteEvent) | +| [`models.CreateDebitNoteEvent`](../../../doc/models/create-debit-note-event.md) | models.InvoiceEventContainer.FromCreateDebitNoteEvent(models.CreateDebitNoteEvent createDebitNoteEvent) | +| [`models.FailedPaymentEvent`](../../../doc/models/failed-payment-event.md) | models.InvoiceEventContainer.FromFailedPaymentEvent(models.FailedPaymentEvent failedPaymentEvent) | +| [`models.IssueInvoiceEvent`](../../../doc/models/issue-invoice-event.md) | models.InvoiceEventContainer.FromIssueInvoiceEvent(models.IssueInvoiceEvent issueInvoiceEvent) | +| [`models.RefundInvoiceEvent`](../../../doc/models/refund-invoice-event.md) | models.InvoiceEventContainer.FromRefundInvoiceEvent(models.RefundInvoiceEvent refundInvoiceEvent) | +| [`models.RemovePaymentEvent`](../../../doc/models/remove-payment-event.md) | models.InvoiceEventContainer.FromRemovePaymentEvent(models.RemovePaymentEvent removePaymentEvent) | +| [`models.VoidInvoiceEvent`](../../../doc/models/void-invoice-event.md) | models.InvoiceEventContainer.FromVoidInvoiceEvent(models.VoidInvoiceEvent voidInvoiceEvent) | +| [`models.VoidRemainderEvent`](../../../doc/models/void-remainder-event.md) | models.InvoiceEventContainer.FromVoidRemainderEvent(models.VoidRemainderEvent voidRemainderEvent) | + diff --git a/doc/models/containers/refund-segment-uids.md b/doc/models/containers/refund-segment-uids.md deleted file mode 100644 index af6a673c..00000000 --- a/doc/models/containers/refund-segment-uids.md +++ /dev/null @@ -1,14 +0,0 @@ - -# Refund Segment Uids - -## Class Name - -`RefundSegmentUids` - -## Cases - -| Type | Factory Method | -| --- | --- | -| `[]string` | models.RefundSegmentUidsContainer.FromArrayOfString([]string arrayOfString) | -| `string` | models.RefundSegmentUidsContainer.FromString(string mString) | - diff --git a/doc/models/create-credit-note-event.md b/doc/models/create-credit-note-event.md new file mode 100644 index 00000000..0f4f259d --- /dev/null +++ b/doc/models/create-credit-note-event.md @@ -0,0 +1,44 @@ + +# Create Credit Note Event + +## Structure + +`CreateCreditNoteEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"create_credit_note"` | +| `EventData` | [`models.CreditNote`](../../doc/models/credit-note.md) | Required | Example schema for an `create_credit_note` event | + +## Example (as JSON) + +```json +{ + "id": 28, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "create_credit_note", + "event_data": { + "uid": "uid6", + "site_id": 132, + "customer_id": 244, + "subscription_id": 60, + "number": "number6" + } +} +``` + diff --git a/doc/models/create-debit-note-event.md b/doc/models/create-debit-note-event.md new file mode 100644 index 00000000..211270f4 --- /dev/null +++ b/doc/models/create-debit-note-event.md @@ -0,0 +1,44 @@ + +# Create Debit Note Event + +## Structure + +`CreateDebitNoteEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"create_debit_note"` | +| `EventData` | [`models.DebitNote`](../../doc/models/debit-note.md) | Required | Example schema for an `create_debit_note` event | + +## Example (as JSON) + +```json +{ + "id": 98, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "create_debit_note", + "event_data": { + "uid": "uid6", + "site_id": 132, + "customer_id": 244, + "subscription_id": 60, + "number": 64 + } +} +``` + diff --git a/doc/models/create-product-family-request.md b/doc/models/create-product-family-request.md index ce26c455..b06d3101 100644 --- a/doc/models/create-product-family-request.md +++ b/doc/models/create-product-family-request.md @@ -17,6 +17,7 @@ { "product_family": { "name": "name0", + "handle": "handle6", "description": "description0" } } diff --git a/doc/models/create-product-family.md b/doc/models/create-product-family.md index c2397892..4da117b3 100644 --- a/doc/models/create-product-family.md +++ b/doc/models/create-product-family.md @@ -9,7 +9,8 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `Name` | `*string` | Optional | - | +| `Name` | `string` | Required | - | +| `Handle` | `models.Optional[string]` | Optional | - | | `Description` | `models.Optional[string]` | Optional | - | ## Example (as JSON) @@ -17,6 +18,7 @@ ```json { "name": "name6", + "handle": "handle2", "description": "description6" } ``` diff --git a/doc/models/create-subscription-request.md b/doc/models/create-subscription-request.md index ef2372cb..bd16c986 100644 --- a/doc/models/create-subscription-request.md +++ b/doc/models/create-subscription-request.md @@ -16,7 +16,6 @@ ```json { "subscription": { - "payment_collection_method": "automatic", "metafields": { "custom_field_name_1": "custom_field_value_1", "custom_field_name_2": "custom_field_value_2" diff --git a/doc/models/create-subscription.md b/doc/models/create-subscription.md index 7aa91419..8be23832 100644 --- a/doc/models/create-subscription.md +++ b/doc/models/create-subscription.md @@ -16,7 +16,7 @@ | `CustomPrice` | [`*models.SubscriptionCustomPrice`](../../doc/models/subscription-custom-price.md) | Optional | (Optional) Used in place of `product_price_point_id` to define a custom price point unique to the subscription | | `CouponCode` | `*string` | Optional | (deprecated) The coupon code of the single coupon currently applied to the subscription. See coupon_codes instead as subscriptions can now have more than one coupon. | | `CouponCodes` | `[]string` | Optional | An array for all the coupons attached to the subscription. | -| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `ReceivesInvoiceEmails` | `*string` | Optional | (Optional) Default: True - Whether or not this subscription is set to receive emails related to this subscription. | | `NetTerms` | `*string` | Optional | (Optional) Default: null The number of days after renewal (on invoice billing) that a subscription is due. A value between 0 (due immediately) and 180. | | `CustomerId` | `*int` | Optional | The ID of an existing customer within Chargify. Required, unless a `customer_reference` or a set of `customer_attributes` is given. | @@ -63,7 +63,6 @@ ```json { - "payment_collection_method": "automatic", "metafields": { "custom_field_name_1": "custom_field_value_1", "custom_field_name_2": "custom_field_value_2" diff --git a/doc/models/credit-note-1.md b/doc/models/credit-note-1.md deleted file mode 100644 index 707c73dc..00000000 --- a/doc/models/credit-note-1.md +++ /dev/null @@ -1,51 +0,0 @@ - -# Credit Note 1 - -## Structure - -`CreditNote1` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Uid` | `*string` | Optional | Unique identifier for the credit note. It is generated automatically by Chargify and has the prefix "cn_" followed by alphanumeric characters. | -| `SiteId` | `*int` | Optional | ID of the site to which the credit note belongs. | -| `CustomerId` | `*int` | Optional | ID of the customer to which the credit note belongs. | -| `SubscriptionId` | `*int` | Optional | ID of the subscription that generated the credit note. | -| `Number` | `*string` | Optional | A unique, identifying string that appears on the credit note and in places it is referenced.

While the UID is long and not appropriate to show to customers, the number is usually shorter and consumable by the customer and the merchant alike. | -| `SequenceNumber` | `*int` | Optional | A monotonically increasing number assigned to credit notes as they are created. This number is unique within a site and can be used to sort and order credit notes. | -| `IssueDate` | `*time.Time` | Optional | Date the credit note was issued to the customer. This is the date that the credit was made available for application, and may come before it is fully applied.

The format is `"YYYY-MM-DD"`. | -| `AppliedDate` | `*time.Time` | Optional | Credit notes are applied to invoices to offset invoiced amounts - they reduce the amount due. This field is the date the credit note became fully applied to invoices.

If the credit note has been partially applied, this field will not have a value until it has been fully applied.

The format is `"YYYY-MM-DD"`. | -| `Status` | [`*models.CreditNoteStatus`](../../doc/models/credit-note-status.md) | Optional | Current status of the credit note. | -| `Currency` | `*string` | Optional | The ISO 4217 currency code (3 character string) representing the currency of the credit note amount fields. | -| `Memo` | `*string` | Optional | The memo printed on credit note, which is a description of the reason for the credit. | -| `Seller` | [`*models.Seller`](../../doc/models/seller.md) | Optional | - | -| `Customer` | [`*models.Customer1`](../../doc/models/customer-1.md) | Optional | - | -| `BillingAddress` | [`*models.BillingAddress`](../../doc/models/billing-address.md) | Optional | - | -| `ShippingAddress` | [`*models.ShippingAddress`](../../doc/models/shipping-address.md) | Optional | - | -| `SubtotalAmount` | `*string` | Optional | Subtotal of the credit note, which is the sum of all line items before discounts or taxes. Note that this is a positive amount representing the credit back to the customer. | -| `DiscountAmount` | `*string` | Optional | Total discount applied to the credit note. Note that this is a positive amount representing the discount amount being credited back to the customer (i.e. a credit on an earlier discount). For example, if the original purchase was $1.00 and the original discount was $0.10, a credit of $0.50 of the original purchase (half) would have a discount credit of $0.05 (also half). | -| `TaxAmount` | `*string` | Optional | Total tax of the credit note. Note that this is a positive amount representing a previously taxex amount being credited back to the customer (i.e. a credit of an earlier tax). For example, if the original purchase was $1.00 and the original tax was $0.10, a credit of $0.50 of the original purchase (half) would also have a tax credit of $0.05 (also half). | -| `TotalAmount` | `*string` | Optional | The credit note total, which is `subtotal_amount - discount_amount + tax_amount`.' | -| `AppliedAmount` | `*string` | Optional | The amount of the credit note that has already been applied to invoices. | -| `RemainingAmount` | `*string` | Optional | The amount of the credit note remaining to be applied to invoices, which is `total_amount - applied_amount`. | -| `LineItems` | [`[]models.CreditNoteLineItem`](../../doc/models/credit-note-line-item.md) | Optional | Line items on the credit note. | -| `Discounts` | [`[]models.InvoiceDiscount`](../../doc/models/invoice-discount.md) | Optional | - | -| `Taxes` | [`[]models.InvoiceTax`](../../doc/models/invoice-tax.md) | Optional | - | -| `Applications` | [`[]models.CreditNoteApplication`](../../doc/models/credit-note-application.md) | Optional | - | -| `Refunds` | [`[]models.InvoiceRefund`](../../doc/models/invoice-refund.md) | Optional | - | -| `OriginInvoices` | [`[]models.OriginInvoice`](../../doc/models/origin-invoice.md) | Optional | An array of origin invoices for the credit note. Learn more about [Origin Invoice from our docs](https://chargify.zendesk.com/hc/en-us/articles/4407753036699#origin-invoices) | - -## Example (as JSON) - -```json -{ - "uid": "uid8", - "site_id": 120, - "customer_id": 232, - "subscription_id": 48, - "number": "number6" -} -``` - diff --git a/doc/models/customer-1.md b/doc/models/customer-1.md deleted file mode 100644 index a29a77dc..00000000 --- a/doc/models/customer-1.md +++ /dev/null @@ -1,31 +0,0 @@ - -# Customer 1 - -## Structure - -`Customer1` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `ChargifyId` | `models.Optional[int]` | Optional | - | -| `FirstName` | `*string` | Optional | - | -| `LastName` | `*string` | Optional | - | -| `Organization` | `models.Optional[string]` | Optional | - | -| `Email` | `*string` | Optional | - | -| `VatNumber` | `models.Optional[string]` | Optional | - | -| `Reference` | `models.Optional[string]` | Optional | - | - -## Example (as JSON) - -```json -{ - "chargify_id": 126, - "first_name": "first_name8", - "last_name": "last_name6", - "organization": "organization8", - "email": "email8" -} -``` - diff --git a/doc/models/debit-note-role.md b/doc/models/debit-note-role.md new file mode 100644 index 00000000..9c261a9f --- /dev/null +++ b/doc/models/debit-note-role.md @@ -0,0 +1,16 @@ + +# Debit Note Role + +The role of the debit note. + +## Enumeration + +`DebitNoteRole` + +## Fields + +| Name | +| --- | +| `CHARGEBACK` | +| `REFUND` | + diff --git a/doc/models/debit-note-status.md b/doc/models/debit-note-status.md new file mode 100644 index 00000000..48eb3cb1 --- /dev/null +++ b/doc/models/debit-note-status.md @@ -0,0 +1,18 @@ + +# Debit Note Status + +Current status of the debit note. + +## Enumeration + +`DebitNoteStatus` + +## Fields + +| Name | +| --- | +| `OPEN` | +| `APPLIED` | +| `BANISHED` | +| `PAID` | + diff --git a/doc/models/debit-note.md b/doc/models/debit-note.md new file mode 100644 index 00000000..92bb8167 --- /dev/null +++ b/doc/models/debit-note.md @@ -0,0 +1,47 @@ + +# Debit Note + +## Structure + +`DebitNote` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Uid` | `*string` | Optional | Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix "db_" followed by alphanumeric characters. | +| `SiteId` | `*int` | Optional | ID of the site to which the debit note belongs. | +| `CustomerId` | `*int` | Optional | ID of the customer to which the debit note belongs. | +| `SubscriptionId` | `*int` | Optional | ID of the subscription that generated the debit note. | +| `Number` | `*int` | Optional | A unique, identifier that appears on the debit note and in places it is referenced. | +| `SequenceNumber` | `*int` | Optional | A monotonically increasing number assigned to debit notes as they are created. | +| `OriginCreditNoteUid` | `*string` | Optional | Unique identifier for the connected credit note. It is generated automatically by Chargify and has the prefix "cn_" followed by alphanumeric characters.

While the UID is long and not appropriate to show to customers, the number is usually shorter and consumable by the customer and the merchant alike. | +| `OriginCreditNoteNumber` | `*string` | Optional | A unique, identifying string of the connected credit note. | +| `IssueDate` | `*time.Time` | Optional | Date the document was issued to the customer. This is the date that the document was made available for payment.

The format is "YYYY-MM-DD". | +| `AppliedDate` | `*time.Time` | Optional | Debit notes are applied to invoices to offset invoiced amounts - they adjust the amount due. This field is the date the debit note document became fully applied to the invoice.

The format is "YYYY-MM-DD". | +| `DueDate` | `*time.Time` | Optional | Date the document is due for payment. The format is "YYYY-MM-DD". | +| `Status` | [`*models.DebitNoteStatus`](../../doc/models/debit-note-status.md) | Optional | Current status of the debit note. | +| `Memo` | `*string` | Optional | The memo printed on debit note, which is a description of the reason for the debit. | +| `Role` | [`*models.DebitNoteRole`](../../doc/models/debit-note-role.md) | Optional | The role of the debit note. | +| `Currency` | `*string` | Optional | The ISO 4217 currency code (3 character string) representing the currency of the credit note amount fields. | +| `Seller` | [`*models.InvoiceSeller`](../../doc/models/invoice-seller.md) | Optional | Information about the seller (merchant) listed on the masthead of the debit note. | +| `Customer` | [`*models.InvoiceCustomer`](../../doc/models/invoice-customer.md) | Optional | Information about the customer who is owner or recipient the debited subscription. | +| `BillingAddress` | [`*models.InvoiceAddress`](../../doc/models/invoice-address.md) | Optional | The billing address of the debited subscription. | +| `ShippingAddress` | [`*models.InvoiceAddress`](../../doc/models/invoice-address.md) | Optional | The shipping address of the debited subscription. | +| `LineItems` | [`[]models.CreditNoteLineItem`](../../doc/models/credit-note-line-item.md) | Optional | Line items on the debit note. | +| `Discounts` | [`[]models.InvoiceDiscount`](../../doc/models/invoice-discount.md) | Optional | - | +| `Taxes` | [`[]models.InvoiceTax`](../../doc/models/invoice-tax.md) | Optional | - | +| `Refunds` | [`[]models.InvoiceRefund`](../../doc/models/invoice-refund.md) | Optional | - | + +## Example (as JSON) + +```json +{ + "uid": "uid2", + "site_id": 112, + "customer_id": 224, + "subscription_id": 40, + "number": 172 +} +``` + diff --git a/doc/models/failed-payment-event-data.md b/doc/models/failed-payment-event-data.md new file mode 100644 index 00000000..5c6815a3 --- /dev/null +++ b/doc/models/failed-payment-event-data.md @@ -0,0 +1,31 @@ + +# Failed Payment Event Data + +Example schema for an `failed_payment` event + +## Structure + +`FailedPaymentEventData` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `AmountInCents` | `int` | Required | The monetary value of the payment, expressed in cents. | +| `AppliedAmount` | `int` | Required | The monetary value of the payment, expressed in dollars. | +| `Memo` | `models.Optional[string]` | Optional | The memo passed when the payment was created. | +| `PaymentMethod` | [`models.InvoicePaymentMethodType`](../../doc/models/invoice-payment-method-type.md) | Required | - | +| `TransactionId` | `int` | Required | The transaction ID of the failed payment. | + +## Example (as JSON) + +```json +{ + "amount_in_cents": 128, + "applied_amount": 154, + "memo": "memo2", + "payment_method": "credit_card", + "transaction_id": 170 +} +``` + diff --git a/doc/models/failed-payment-event.md b/doc/models/failed-payment-event.md new file mode 100644 index 00000000..8d410b26 --- /dev/null +++ b/doc/models/failed-payment-event.md @@ -0,0 +1,44 @@ + +# Failed Payment Event + +## Structure + +`FailedPaymentEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"failed_payment"` | +| `EventData` | [`models.FailedPaymentEventData`](../../doc/models/failed-payment-event-data.md) | Required | Example schema for an `failed_payment` event | + +## Example (as JSON) + +```json +{ + "id": 120, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "failed_payment", + "event_data": { + "amount_in_cents": 220, + "applied_amount": 194, + "memo": "memo0", + "payment_method": "cash", + "transaction_id": 78 + } +} +``` + diff --git a/doc/models/historic-usage.md b/doc/models/historic-usage.md index ea6f64d9..f8c1b459 100644 --- a/doc/models/historic-usage.md +++ b/doc/models/historic-usage.md @@ -1,7 +1,7 @@ # Historic Usage -An optional object for Event Based Components, will be returned if provided `include=historic_usages` query param. +Optional for Event Based Components. If the `include=historic_usages` query param is provided, the last ten billing periods will be returned. ## Structure diff --git a/doc/models/invoice-event-data.md b/doc/models/invoice-event-data.md deleted file mode 100644 index 70a69a01..00000000 --- a/doc/models/invoice-event-data.md +++ /dev/null @@ -1,58 +0,0 @@ - -# Invoice Event Data - -The event data is the data that, when combined with the command, results in the output invoice found in the invoice field. - -## Structure - -`InvoiceEventData` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Uid` | `*string` | Optional | Unique identifier for the credit note application. It is generated automatically by Chargify and has the prefix "cdt_" followed by alphanumeric characters. | -| `CreditNoteNumber` | `*string` | Optional | A unique, identifying string that appears on the credit note and in places it is referenced. | -| `CreditNoteUid` | `*string` | Optional | Unique identifier for the credit note. It is generated automatically by Chargify and has the prefix "cn_" followed by alphanumeric characters. | -| `OriginalAmount` | `*string` | Optional | The full, original amount of the credit note. | -| `AppliedAmount` | `*string` | Optional | The amount of the credit note applied to invoice. | -| `TransactionTime` | `*time.Time` | Optional | The time the credit note was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" | -| `Memo` | `*string` | Optional | The credit note memo. | -| `Role` | `*string` | Optional | The role of the credit note (e.g. 'general') | -| `ConsolidatedInvoice` | `*bool` | Optional | Shows whether it was applied to consolidated invoice or not | -| `AppliedCreditNotes` | [`[]models.AppliedCreditNoteData`](../../doc/models/applied-credit-note-data.md) | Optional | List of credit notes applied to children invoices (if consolidated invoice) | -| `DebitNoteNumber` | `*string` | Optional | A unique, identifying string that appears on the debit note and in places it is referenced. | -| `DebitNoteUid` | `*string` | Optional | Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix "db_" followed by alphanumeric characters. | -| `PaymentMethod` | [`*models.InvoiceEventDataPaymentMethod`](../../doc/models/containers/invoice-event-data-payment-method.md) | Optional | This is a container for any-of cases. | -| `TransactionId` | `*int` | Optional | The Chargify id of the original payment | -| `ParentInvoiceNumber` | `models.Optional[int]` | Optional | - | -| `RemainingPrepaymentAmount` | `models.Optional[string]` | Optional | - | -| `Prepayment` | `*bool` | Optional | The flag that shows whether the original payment was a prepayment or not | -| `External` | `*bool` | Optional | - | -| `FromCollectionMethod` | `*string` | Optional | The previous collection method of the invoice. | -| `ToCollectionMethod` | `*string` | Optional | The new collection method of the invoice. | -| `ConsolidationLevel` | [`*models.InvoiceConsolidationLevel`](../../doc/models/invoice-consolidation-level.md) | Optional | Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

* "none": A normal invoice with no consolidation.
* "child": An invoice segment which has been combined into a consolidated invoice.
* "parent": A consolidated invoice, whose contents are composed of invoice segments.

"Parent" invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments.

See also the [invoice consolidation documentation](https://chargify.zendesk.com/hc/en-us/articles/4407746391835). | -| `FromStatus` | [`*models.InvoiceStatus`](../../doc/models/invoice-status.md) | Optional | The status of the invoice before event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. | -| `ToStatus` | [`*models.InvoiceStatus`](../../doc/models/invoice-status.md) | Optional | The status of the invoice after event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. | -| `DueAmount` | `*string` | Optional | Amount due on the invoice, which is `total_amount - credit_amount - paid_amount`. | -| `TotalAmount` | `*string` | Optional | The invoice total, which is `subtotal_amount - discount_amount + tax_amount`.' | -| `ApplyCredit` | `*bool` | Optional | If true, credit was created and applied it to the invoice. | -| `CreditNoteAttributes` | [`*models.CreditNote1`](../../doc/models/credit-note-1.md) | Optional | - | -| `PaymentId` | `*int` | Optional | The ID of the payment transaction to be refunded. | -| `RefundAmount` | `*string` | Optional | The amount of the refund. | -| `RefundId` | `*int` | Optional | The ID of the refund transaction. | -| `IsAdvanceInvoice` | `*bool` | Optional | If true, the invoice is an advance invoice. | -| `Reason` | `*string` | Optional | The reason for the void. | - -## Example (as JSON) - -```json -{ - "uid": "uid0", - "credit_note_number": "credit_note_number6", - "credit_note_uid": "credit_note_uid6", - "original_amount": "original_amount4", - "applied_amount": "applied_amount8" -} -``` - diff --git a/doc/models/invoice-event-payment-1.md b/doc/models/invoice-event-payment-1.md deleted file mode 100644 index 0d06a670..00000000 --- a/doc/models/invoice-event-payment-1.md +++ /dev/null @@ -1,43 +0,0 @@ - -# Invoice Event Payment 1 - -A nested data structure detailing the method of payment - -## Structure - -`InvoiceEventPayment1` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Type` | `*string` | Optional | - | -| `MaskedAccountNumber` | `string` | Required | - | -| `MaskedRoutingNumber` | `string` | Required | - | -| `CardBrand` | `string` | Required | - | -| `CardExpiration` | `*string` | Optional | - | -| `LastFour` | `models.Optional[string]` | Optional | - | -| `MaskedCardNumber` | `string` | Required | - | -| `Details` | `*string` | Required | - | -| `Kind` | `string` | Required | - | -| `Memo` | `*string` | Required | - | -| `Email` | `string` | Required | - | - -## Example (as JSON) - -```json -{ - "type": "Invoice Event Payment1", - "masked_account_number": "masked_account_number4", - "masked_routing_number": "masked_routing_number4", - "card_brand": "card_brand8", - "card_expiration": "card_expiration4", - "last_four": "last_four2", - "masked_card_number": "masked_card_number6", - "details": "details8", - "kind": "kind6", - "memo": "memo2", - "email": "email8" -} -``` - diff --git a/doc/models/invoice-event-payment.md b/doc/models/invoice-event-payment.md deleted file mode 100644 index d9c09e97..00000000 --- a/doc/models/invoice-event-payment.md +++ /dev/null @@ -1,37 +0,0 @@ - -# Invoice Event Payment - -A nested data structure detailing the method of payment - -## Structure - -`InvoiceEventPayment` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Type` | `*string` | Optional | - | -| `MaskedAccountNumber` | `*string` | Optional | - | -| `MaskedRoutingNumber` | `*string` | Optional | - | -| `CardBrand` | `*string` | Optional | - | -| `CardExpiration` | `*string` | Optional | - | -| `LastFour` | `models.Optional[string]` | Optional | - | -| `MaskedCardNumber` | `*string` | Optional | - | -| `Details` | `models.Optional[string]` | Optional | - | -| `Kind` | `*string` | Optional | - | -| `Memo` | `models.Optional[string]` | Optional | - | -| `Email` | `*string` | Optional | - | - -## Example (as JSON) - -```json -{ - "type": "Invoice Event Payment", - "masked_account_number": "masked_account_number8", - "masked_routing_number": "masked_routing_number8", - "card_brand": "card_brand4", - "card_expiration": "card_expiration2" -} -``` - diff --git a/doc/models/invoice-event-type.md b/doc/models/invoice-event-type.md index fea1486a..dfde97e2 100644 --- a/doc/models/invoice-event-type.md +++ b/doc/models/invoice-event-type.md @@ -16,6 +16,7 @@ Invoice Event Type | `CREATECREDITNOTE` | | `APPLYPAYMENT` | | `APPLYDEBITNOTE` | +| `CREATEDEBITNOTE` | | `REFUNDINVOICE` | | `VOIDINVOICE` | | `VOIDREMAINDER` | diff --git a/doc/models/invoice-event.md b/doc/models/invoice-event.md deleted file mode 100644 index 839b2790..00000000 --- a/doc/models/invoice-event.md +++ /dev/null @@ -1,55 +0,0 @@ - -# Invoice Event - -## Structure - -`InvoiceEvent` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Id` | `*int` | Optional | - | -| `EventType` | [`*models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Optional | Invoice Event Type | -| `EventData` | [`*models.InvoiceEventEventData`](../../doc/models/containers/invoice-event-event-data.md) | Optional | This is a container for any-of cases. | -| `Timestamp` | `*time.Time` | Optional | - | -| `Invoice` | [`*models.Invoice`](../../doc/models/invoice.md) | Optional | - | - -## Example (as JSON) - -```json -{ - "id": 78, - "event_type": "void_invoice", - "event_data": { - "uid": "uid2", - "credit_note_number": "credit_note_number4", - "credit_note_uid": "credit_note_uid4", - "original_amount": "original_amount6", - "applied_amount": "applied_amount6", - "transaction_time": "2016-03-13T12:52:32.123Z", - "memo": "memo6", - "role": "role4", - "consolidated_invoice": false, - "applied_credit_notes": [ - { - "uid": "uid4", - "number": "number8" - }, - { - "uid": "uid4", - "number": "number8" - } - ] - }, - "timestamp": "2016-03-13T12:52:32.123Z", - "invoice": { - "id": 166, - "uid": "uid6", - "site_id": 92, - "customer_id": 204, - "subscription_id": 20 - } -} -``` - diff --git a/doc/models/invoice-response.md b/doc/models/invoice-response.md index 44aad1f9..9f537353 100644 --- a/doc/models/invoice-response.md +++ b/doc/models/invoice-response.md @@ -19,7 +19,6 @@ "issue_date": "2024-01-01", "due_date": "2024-01-01", "paid_date": "2024-01-01", - "collection_method": "automatic", "id": 166, "uid": "uid6", "site_id": 92, diff --git a/doc/models/invoice-status.md b/doc/models/invoice-status.md index 4e690dea..c23f7016 100644 --- a/doc/models/invoice-status.md +++ b/doc/models/invoice-status.md @@ -1,7 +1,7 @@ # Invoice Status -The current status of the invoice. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. +The current status of the invoice. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. ## Enumeration diff --git a/doc/models/invoice.md b/doc/models/invoice.md index 8e21ddc0..31a32adf 100644 --- a/doc/models/invoice.md +++ b/doc/models/invoice.md @@ -22,10 +22,10 @@ | `IssueDate` | `*time.Time` | Optional | Date the invoice was issued to the customer. This is the date that the invoice was made available for payment.

The format is `"YYYY-MM-DD"`. | | `DueDate` | `*time.Time` | Optional | Date the invoice is due.

The format is `"YYYY-MM-DD"`. | | `PaidDate` | `models.Optional[time.Time]` | Optional | Date the invoice became fully paid.

If partial payments are applied to the invoice, this date will not be present until payment has been made in full.

The format is `"YYYY-MM-DD"`. | -| `Status` | [`*models.InvoiceStatus`](../../doc/models/invoice-status.md) | Optional | The current status of the invoice. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. | +| `Status` | [`*models.InvoiceStatus`](../../doc/models/invoice-status.md) | Optional | The current status of the invoice. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. | | `Role` | [`*models.InvoiceRole`](../../doc/models/invoice-role.md) | Optional | - | | `ParentInvoiceId` | `models.Optional[int]` | Optional | - | -| `CollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `CollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `PaymentInstructions` | `*string` | Optional | A message that is printed on the invoice when it is marked for remittance collection. It is intended to describe to the customer how they may make payment, and is configured by the merchant. | | `Currency` | `*string` | Optional | The ISO 4217 currency code (3 character string) representing the currency of invoice transaction. | | `ConsolidationLevel` | [`*models.InvoiceConsolidationLevel`](../../doc/models/invoice-consolidation-level.md) | Optional | Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

* "none": A normal invoice with no consolidation.
* "child": An invoice segment which has been combined into a consolidated invoice.
* "parent": A consolidated invoice, whose contents are composed of invoice segments.

"Parent" invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments.

See also the [invoice consolidation documentation](https://chargify.zendesk.com/hc/en-us/articles/4407746391835). | @@ -69,7 +69,6 @@ "issue_date": "2024-01-01", "due_date": "2024-01-01", "paid_date": "2024-01-01", - "collection_method": "automatic", "id": 252, "uid": "uid0", "site_id": 178, diff --git a/doc/models/issue-invoice-event-data.md b/doc/models/issue-invoice-event-data.md index 2cf70727..5506b561 100644 --- a/doc/models/issue-invoice-event-data.md +++ b/doc/models/issue-invoice-event-data.md @@ -12,8 +12,8 @@ Example schema for an `issue_invoice` event | Name | Type | Tags | Description | | --- | --- | --- | --- | | `ConsolidationLevel` | [`models.InvoiceConsolidationLevel`](../../doc/models/invoice-consolidation-level.md) | Required | Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

* "none": A normal invoice with no consolidation.
* "child": An invoice segment which has been combined into a consolidated invoice.
* "parent": A consolidated invoice, whose contents are composed of invoice segments.

"Parent" invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments.

See also the [invoice consolidation documentation](https://chargify.zendesk.com/hc/en-us/articles/4407746391835). | -| `FromStatus` | [`models.InvoiceStatus`](../../doc/models/invoice-status.md) | Required | The status of the invoice before event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. | -| `ToStatus` | [`models.InvoiceStatus`](../../doc/models/invoice-status.md) | Required | The status of the invoice after event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. | +| `FromStatus` | [`models.InvoiceStatus`](../../doc/models/invoice-status.md) | Required | The status of the invoice before event occurrence. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statusess) for more. | +| `ToStatus` | [`models.InvoiceStatus`](../../doc/models/invoice-status.md) | Required | The status of the invoice after event occurrence. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statusess) for more. | | `DueAmount` | `string` | Required | Amount due on the invoice, which is `total_amount - credit_amount - paid_amount`. | | `TotalAmount` | `string` | Required | The invoice total, which is `subtotal_amount - discount_amount + tax_amount`.' | diff --git a/doc/models/issue-invoice-event.md b/doc/models/issue-invoice-event.md new file mode 100644 index 00000000..37c62270 --- /dev/null +++ b/doc/models/issue-invoice-event.md @@ -0,0 +1,44 @@ + +# Issue Invoice Event + +## Structure + +`IssueInvoiceEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"issue_invoice"` | +| `EventData` | [`models.IssueInvoiceEventData`](../../doc/models/issue-invoice-event-data.md) | Required | Example schema for an `issue_invoice` event | + +## Example (as JSON) + +```json +{ + "id": 130, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "issue_invoice", + "event_data": { + "consolidation_level": "child", + "from_status": "paid", + "to_status": "paid", + "due_amount": "due_amount8", + "total_amount": "total_amount2" + } +} +``` + diff --git a/doc/models/list-invoice-events-response.md b/doc/models/list-invoice-events-response.md index 5080e57d..d1a33ec9 100644 --- a/doc/models/list-invoice-events-response.md +++ b/doc/models/list-invoice-events-response.md @@ -9,7 +9,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | -| `Events` | [`[]models.InvoiceEvent`](../../doc/models/invoice-event.md) | Optional | - | +| `Events` | [`[]models.InvoiceEvent`](../../doc/models/containers/invoice-event.md) | Optional | - | | `Page` | `*int` | Optional | - | | `PerPage` | `*int` | Optional | - | | `TotalPages` | `*int` | Optional | - | @@ -20,36 +20,40 @@ { "events": [ { - "id": 68, - "event_type": "void_invoice", + "event_type": "apply_credit_note", + "id": 214, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, "event_data": { - "uid": "uid2", - "credit_note_number": "credit_note_number4", - "credit_note_uid": "credit_note_uid4", - "original_amount": "original_amount6", - "applied_amount": "applied_amount6", + "uid": "uid6", + "credit_note_number": "credit_note_number0", + "credit_note_uid": "credit_note_uid0", + "original_amount": "original_amount0", + "applied_amount": "applied_amount2", "transaction_time": "2016-03-13T12:52:32.123Z", - "memo": "memo6", - "role": "role4", + "memo": "memo0", + "role": "role0", "consolidated_invoice": false, "applied_credit_notes": [ { "uid": "uid4", "number": "number8" }, + { + "uid": "uid4", + "number": "number8" + }, { "uid": "uid4", "number": "number8" } ] - }, - "timestamp": "2016-03-13T12:52:32.123Z", - "invoice": { - "id": 166, - "uid": "uid6", - "site_id": 92, - "customer_id": 204, - "subscription_id": 20 } } ], diff --git a/doc/models/list-invoices-response.md b/doc/models/list-invoices-response.md index 5604b3d6..eb538a21 100644 --- a/doc/models/list-invoices-response.md +++ b/doc/models/list-invoices-response.md @@ -20,7 +20,6 @@ "issue_date": "2024-01-01", "due_date": "2024-01-01", "paid_date": "2024-01-01", - "collection_method": "automatic", "id": 196, "uid": "uid6", "site_id": 122, diff --git a/doc/models/paid-invoice.md b/doc/models/paid-invoice.md index fe00e4e3..812ff437 100644 --- a/doc/models/paid-invoice.md +++ b/doc/models/paid-invoice.md @@ -10,7 +10,7 @@ | Name | Type | Tags | Description | | --- | --- | --- | --- | | `InvoiceId` | `*string` | Optional | The uid of the paid invoice | -| `Status` | [`*models.InvoiceStatus`](../../doc/models/invoice-status.md) | Optional | The current status of the invoice. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. | +| `Status` | [`*models.InvoiceStatus`](../../doc/models/invoice-status.md) | Optional | The current status of the invoice. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. | | `DueAmount` | `*string` | Optional | The remaining due amount on the invoice | | `PaidAmount` | `*string` | Optional | The total amount paid on this invoice (including any prior payments) | diff --git a/doc/models/payment-method-apple-pay.md b/doc/models/payment-method-apple-pay.md index 239351e9..aa1c7eba 100644 --- a/doc/models/payment-method-apple-pay.md +++ b/doc/models/payment-method-apple-pay.md @@ -15,7 +15,7 @@ ```json { - "type": "credit_card" + "type": "apple_pay" } ``` diff --git a/doc/models/payment-method-bank-account.md b/doc/models/payment-method-bank-account.md index 986381b7..3154a72a 100644 --- a/doc/models/payment-method-bank-account.md +++ b/doc/models/payment-method-bank-account.md @@ -19,7 +19,7 @@ { "masked_account_number": "masked_account_number2", "masked_routing_number": "masked_routing_number2", - "type": "paypal_account" + "type": "bank_account" } ``` diff --git a/doc/models/payment-method-credit-card.md b/doc/models/payment-method-credit-card.md index c6255690..eee2b81f 100644 --- a/doc/models/payment-method-credit-card.md +++ b/doc/models/payment-method-credit-card.md @@ -20,10 +20,10 @@ ```json { "card_brand": "card_brand4", - "card_expiration": "card_expiration2", - "last_four": "last_four4", "masked_card_number": "masked_card_number0", - "type": "external" + "type": "credit_card", + "card_expiration": "card_expiration2", + "last_four": "last_four4" } ``` diff --git a/doc/models/payment-method-external.md b/doc/models/payment-method-external.md index 63478975..d5e0a7c2 100644 --- a/doc/models/payment-method-external.md +++ b/doc/models/payment-method-external.md @@ -21,7 +21,7 @@ "details": "details4", "kind": "kind2", "memo": "memo8", - "type": "bank_account" + "type": "external" } ``` diff --git a/doc/models/payment-method-paypal.md b/doc/models/payment-method-paypal.md index 55f33b5c..a39fb721 100644 --- a/doc/models/payment-method-paypal.md +++ b/doc/models/payment-method-paypal.md @@ -17,7 +17,7 @@ ```json { "email": "email2", - "type": "bank_account" + "type": "paypal_account" } ``` diff --git a/doc/models/price-point.md b/doc/models/price-point.md deleted file mode 100644 index b0c52126..00000000 --- a/doc/models/price-point.md +++ /dev/null @@ -1,43 +0,0 @@ - -# Price Point - -## Structure - -`PricePoint` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Name` | `*string` | Optional | - | -| `Handle` | `*string` | Optional | - | -| `PricingScheme` | [`*models.PricingScheme`](../../doc/models/pricing-scheme.md) | Optional | The identifier for the pricing scheme. See [Product Components](https://help.chargify.com/products/product-components.html) for an overview of pricing schemes. | -| `Prices` | [`[]models.Price`](../../doc/models/price.md) | Optional | - | -| `UseSiteExchangeRate` | `*bool` | Optional | Whether to use the site level exchange rate or define your own prices for each currency if you have multiple currencies defined on the site.
**Default**: `true` | -| `TaxIncluded` | `*bool` | Optional | Whether or not the price point includes tax | -| `Interval` | `*int` | Optional | The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this price point would renew every 30 days. This property is only available for sites with Multifrequency enabled. | -| `IntervalUnit` | [`*models.IntervalUnit`](../../doc/models/interval-unit.md) | Optional | A string representing the interval unit for this price point, either month or day. This property is only available for sites with Multifrequency enabled. | -| `OveragePricing` | [`*models.OveragePricing`](../../doc/models/overage-pricing.md) | Optional | - | -| `RolloverPrepaidRemainder` | `*bool` | Optional | Boolean which controls whether or not remaining units should be rolled over to the next period | -| `RenewPrepaidAllocation` | `*bool` | Optional | Boolean which controls whether or not the allocated quantity should be renewed at the beginning of each period | -| `ExpirationInterval` | `*float64` | Optional | (only for prepaid usage components where rollover_prepaid_remainder is true) The number of `expiration_interval_unit`s after which rollover amounts should expire | -| `ExpirationIntervalUnit` | [`*models.IntervalUnit`](../../doc/models/interval-unit.md) | Optional | - | - -## Example (as JSON) - -```json -{ - "use_site_exchange_rate": true, - "name": "name0", - "handle": "handle6", - "pricing_scheme": "per_unit", - "prices": [ - { - "starting_quantity": 242, - "ending_quantity": 40, - "unit_price": 23.26 - } - ] -} -``` - diff --git a/doc/models/proforma-invoice.md b/doc/models/proforma-invoice.md index 8e247a8e..9abe5710 100644 --- a/doc/models/proforma-invoice.md +++ b/doc/models/proforma-invoice.md @@ -18,7 +18,7 @@ | `CreatedAt` | `*time.Time` | Optional | - | | `DeliveryDate` | `*time.Time` | Optional | - | | `Status` | [`*models.ProformaInvoiceStatus`](../../doc/models/proforma-invoice-status.md) | Optional | - | -| `CollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `CollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `PaymentInstructions` | `*string` | Optional | - | | `Currency` | `*string` | Optional | - | | `ConsolidationLevel` | [`*models.InvoiceConsolidationLevel`](../../doc/models/invoice-consolidation-level.md) | Optional | Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values:

* "none": A normal invoice with no consolidation.
* "child": An invoice segment which has been combined into a consolidated invoice.
* "parent": A consolidated invoice, whose contents are composed of invoice segments.

"Parent" invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments.

See also the [invoice consolidation documentation](https://chargify.zendesk.com/hc/en-us/articles/4407746391835). | @@ -50,7 +50,6 @@ ```json { - "collection_method": "automatic", "uid": "uid6", "site_id": 196, "customer_id": 52, diff --git a/doc/models/refund-invoice-event.md b/doc/models/refund-invoice-event.md new file mode 100644 index 00000000..57647957 --- /dev/null +++ b/doc/models/refund-invoice-event.md @@ -0,0 +1,54 @@ + +# Refund Invoice Event + +## Structure + +`RefundInvoiceEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"refund_invoice"` | +| `EventData` | [`models.RefundInvoiceEventData`](../../doc/models/refund-invoice-event-data.md) | Required | Example schema for an `refund_invoice` event | + +## Example (as JSON) + +```json +{ + "id": 54, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "refund_invoice", + "event_data": { + "apply_credit": false, + "consolidation_level": "child", + "credit_note_attributes": { + "uid": "uid2", + "site_id": 72, + "customer_id": 184, + "subscription_id": 0, + "number": "number0" + }, + "memo": "memo0", + "original_amount": "original_amount0", + "payment_id": 204, + "refund_amount": "refund_amount8", + "refund_id": 248, + "transaction_time": "2016-03-13T12:52:32.123Z" + } +} +``` + diff --git a/doc/models/refund.md b/doc/models/refund.md deleted file mode 100644 index bdbb0928..00000000 --- a/doc/models/refund.md +++ /dev/null @@ -1,31 +0,0 @@ - -# Refund - -## Structure - -`Refund` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Amount` | `*string` | Optional | The amount to be refunded in decimal format as a string. Example: "10.50". Must not exceed the remaining refundable balance of the payment. | -| `Memo` | `*string` | Optional | A description that will be attached to the refund | -| `PaymentId` | `*int` | Optional | The ID of the payment to be refunded | -| `External` | `*bool` | Optional | Flag that marks refund as external (no money is returned to the customer). Defaults to `false`. | -| `ApplyCredit` | `*bool` | Optional | If set to true, creates credit and applies it to an invoice. Defaults to `false`. | -| `VoidInvoice` | `*bool` | Optional | If `apply_credit` set to false and refunding full amount, if `void_invoice` set to true, invoice will be voided after refund. Defaults to `false`. | -| `SegmentUids` | [`*models.RefundSegmentUids`](../../doc/models/containers/refund-segment-uids.md) | Optional | This is a container for one-of cases. | - -## Example (as JSON) - -```json -{ - "amount": "amount8", - "memo": "memo0", - "payment_id": 130, - "external": false, - "apply_credit": false -} -``` - diff --git a/doc/models/remove-payment-event-data.md b/doc/models/remove-payment-event-data.md index 7a100fb0..c20b9329 100644 --- a/doc/models/remove-payment-event-data.md +++ b/doc/models/remove-payment-event-data.md @@ -16,7 +16,7 @@ Example schema for an `remove_payment` event | `OriginalAmount` | `*string` | Optional | Full amount of the original payment | | `AppliedAmount` | `string` | Required | Applied amount of the original payment | | `TransactionTime` | `time.Time` | Required | Transaction time of the original payment, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" | -| `PaymentMethod` | [`models.InvoiceEventPayment2`](../../doc/models/containers/invoice-event-payment-2.md) | Required | A nested data structure detailing the method of payment | +| `PaymentMethod` | [`models.InvoiceEventPayment`](../../doc/models/containers/invoice-event-payment.md) | Required | A nested data structure detailing the method of payment | | `Prepayment` | `bool` | Required | The flag that shows whether the original payment was a prepayment or not | ## Example (as JSON) @@ -25,13 +25,13 @@ Example schema for an `remove_payment` event { "transaction_id": 180, "memo": "memo0", - "original_amount": "original_amount0", "applied_amount": "applied_amount2", "transaction_time": "2016-03-13T12:52:32.123Z", "payment_method": { "type": "apple_pay" }, - "prepayment": false + "prepayment": false, + "original_amount": "original_amount0" } ``` diff --git a/doc/models/remove-payment-event.md b/doc/models/remove-payment-event.md new file mode 100644 index 00000000..ba8954f9 --- /dev/null +++ b/doc/models/remove-payment-event.md @@ -0,0 +1,48 @@ + +# Remove Payment Event + +## Structure + +`RemovePaymentEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"remove_payment"` | +| `EventData` | [`models.RemovePaymentEventData`](../../doc/models/remove-payment-event-data.md) | Required | Example schema for an `remove_payment` event | + +## Example (as JSON) + +```json +{ + "id": 236, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "remove_payment", + "event_data": { + "transaction_id": 78, + "memo": "memo0", + "applied_amount": "applied_amount2", + "transaction_time": "2016-03-13T12:52:32.123Z", + "payment_method": { + "type": "apple_pay" + }, + "prepayment": false, + "original_amount": "original_amount0" + } +} +``` + diff --git a/doc/models/seller.md b/doc/models/seller.md deleted file mode 100644 index 2cfc1298..00000000 --- a/doc/models/seller.md +++ /dev/null @@ -1,33 +0,0 @@ - -# Seller - -## Structure - -`Seller` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Name` | `*string` | Optional | - | -| `Address` | [`*models.InvoiceAddress`](../../doc/models/invoice-address.md) | Optional | - | -| `Phone` | `*string` | Optional | - | -| `LogoUrl` | `models.Optional[string]` | Optional | - | - -## Example (as JSON) - -```json -{ - "name": "name6", - "address": { - "street": "street6", - "line2": "line20", - "city": "city6", - "state": "state2", - "zip": "zip0" - }, - "phone": "phone6", - "logo_url": "logo_url4" -} -``` - diff --git a/doc/models/shipping-address.md b/doc/models/shipping-address.md deleted file mode 100644 index d67ee75f..00000000 --- a/doc/models/shipping-address.md +++ /dev/null @@ -1,30 +0,0 @@ - -# Shipping Address - -## Structure - -`ShippingAddress` - -## Fields - -| Name | Type | Tags | Description | -| --- | --- | --- | --- | -| `Street` | `models.Optional[string]` | Optional | - | -| `Line2` | `models.Optional[string]` | Optional | - | -| `City` | `models.Optional[string]` | Optional | - | -| `State` | `models.Optional[string]` | Optional | - | -| `Zip` | `models.Optional[string]` | Optional | - | -| `Country` | `models.Optional[string]` | Optional | - | - -## Example (as JSON) - -```json -{ - "street": "street0", - "line2": "line24", - "city": "city0", - "state": "state4", - "zip": "zip6" -} -``` - diff --git a/doc/models/subscription-group-response.md b/doc/models/subscription-group-response.md index af74ab8a..c52dd3dd 100644 --- a/doc/models/subscription-group-response.md +++ b/doc/models/subscription-group-response.md @@ -16,7 +16,6 @@ ```json { "subscription_group": { - "payment_collection_method": "automatic", "customer_id": 220, "payment_profile": { "id": 44, @@ -24,6 +23,7 @@ "last_name": "last_name2", "masked_card_number": "masked_card_number2" }, + "payment_collection_method": "prepaid", "subscription_ids": [ 74, 75 diff --git a/doc/models/subscription-group-signup-request.md b/doc/models/subscription-group-signup-request.md index c0001241..d67c16f1 100644 --- a/doc/models/subscription-group-signup-request.md +++ b/doc/models/subscription-group-signup-request.md @@ -16,7 +16,6 @@ ```json { "subscription_group": { - "payment_collection_method": "automatic", "subscriptions": [ { "metafields": { @@ -33,6 +32,7 @@ "payment_profile_id": 128, "payer_id": 150, "payer_reference": "payer_reference6", + "payment_collection_method": "prepaid", "payer_attributes": { "first_name": "first_name2", "last_name": "last_name0", diff --git a/doc/models/subscription-group-signup-response.md b/doc/models/subscription-group-signup-response.md index 222f3f2a..1a7f54a0 100644 --- a/doc/models/subscription-group-signup-response.md +++ b/doc/models/subscription-group-signup-response.md @@ -19,13 +19,12 @@ | `State` | [`*models.SubscriptionState`](../../doc/models/subscription-state.md) | Optional | The state of a subscription.

* **Live States**
* `active` - A normal, active subscription. It is not in a trial and is paid and up to date.
* `assessing` - An internal (transient) state that indicates a subscription is in the middle of periodic assessment. Do not base any access decisions in your app on this state, as it may not always be exposed.
* `pending` - An internal (transient) state that indicates a subscription is in the creation process. Do not base any access decisions in your app on this state, as it may not always be exposed.
* `trialing` - A subscription in trialing state has a valid trial subscription. This type of subscription may transition to active once payment is received when the trial has ended. Otherwise, it may go to a Problem or End of Life state.
* `paused` - An internal state that indicates that your account with Advanced Billing is in arrears.
* **Problem States**
* `past_due` - Indicates that the most recent payment has failed, and payment is past due for this subscription. If you have enabled our automated dunning, this subscription will be in the dunning process (additional status and callbacks from the dunning process will be available in the future). If you are handling dunning and payment updates yourself, you will want to use this state to initiate a payment update from your customers.
* `soft_failure` - Indicates that normal assessment/processing of the subscription has failed for a reason that cannot be fixed by the Customer. For example, a Soft Fail may result from a timeout at the gateway or incorrect credentials on your part. The subscriptions should be retried automatically. An interface is being built for you to review problems resulting from these events to take manual action when needed.
* `unpaid` - Indicates an unpaid subscription. A subscription is marked unpaid if the retry period expires and you have configured your [Dunning](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405505141005) settings to have a Final Action of `mark the subscription unpaid`.
* **End of Life States**
* `canceled` - Indicates a canceled subscription. This may happen at your request (via the API or the web interface) or due to the expiration of the [Dunning](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405505141005) process without payment. See the [Reactivation](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404559291021) documentation for info on how to restart a canceled subscription.
While a subscription is canceled, its period will not advance, it will not accrue any new charges, and Advanced Billing will not attempt to collect the overdue balance.
* `expired` - Indicates a subscription that has expired due to running its normal life cycle. Some products may be configured to have an expiration period. An expired subscription then is one that stayed active until it fulfilled its full period.
* `failed_to_create` - Indicates that signup has failed. (You may see this state in a signup_failure webhook.)
* `on_hold` - Indicates that a subscription’s billing has been temporarily stopped. While it is expected that the subscription will resume and return to active status, this is still treated as an “End of Life” state because the customer is not paying for services during this time.
* `suspended` - Indicates that a prepaid subscription has used up all their prepayment balance. If a prepayment is applied, it will return to an active state.
* `trial_ended` - A subscription in a trial_ended state is a subscription that completed a no-obligation trial and did not have a card on file at the expiration of the trial period. See [Product Pricing – No Obligation Trials](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405246782221) for more details.

See [Subscription States](https://maxio-chargify.zendesk.com/hc/en-us/articles/5404222005773) for more info about subscription states and state transitions. | | `CancelAtEndOfPeriod` | `*bool` | Optional | - | | `Subscriptions` | [`[]models.SubscriptionGroupItem`](../../doc/models/subscription-group-item.md) | Optional | - | -| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | ## Example (as JSON) ```json { - "payment_collection_method": "automatic", "uid": "uid8", "scheme": 28, "customer_id": 48, diff --git a/doc/models/subscription-group-signup.md b/doc/models/subscription-group-signup.md index d28ab58d..90df1b34 100644 --- a/doc/models/subscription-group-signup.md +++ b/doc/models/subscription-group-signup.md @@ -12,7 +12,7 @@ | `PaymentProfileId` | `*int` | Optional | - | | `PayerId` | `*int` | Optional | - | | `PayerReference` | `*string` | Optional | - | -| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `PayerAttributes` | [`*models.PayerAttributes`](../../doc/models/payer-attributes.md) | Optional | - | | `CreditCardAttributes` | [`*models.SubscriptionGroupCreditCard`](../../doc/models/subscription-group-credit-card.md) | Optional | - | | `BankAccountAttributes` | [`*models.SubscriptionGroupBankAccount`](../../doc/models/subscription-group-bank-account.md) | Optional | - | @@ -22,7 +22,6 @@ ```json { - "payment_collection_method": "automatic", "subscriptions": [ { "metafields": { @@ -39,6 +38,7 @@ "payment_profile_id": 42, "payer_id": 64, "payer_reference": "payer_reference8", + "payment_collection_method": "automatic", "payer_attributes": { "first_name": "first_name2", "last_name": "last_name0", diff --git a/doc/models/subscription-group.md b/doc/models/subscription-group.md index 0a19af41..fe9110ce 100644 --- a/doc/models/subscription-group.md +++ b/doc/models/subscription-group.md @@ -11,7 +11,7 @@ | --- | --- | --- | --- | | `CustomerId` | `*int` | Optional | - | | `PaymentProfile` | [`*models.SubscriptionGroupPaymentProfile`](../../doc/models/subscription-group-payment-profile.md) | Optional | - | -| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `SubscriptionIds` | `[]int` | Optional | - | | `CreatedAt` | `*time.Time` | Optional | - | @@ -19,7 +19,6 @@ ```json { - "payment_collection_method": "automatic", "customer_id": 36, "payment_profile": { "id": 44, @@ -27,6 +26,7 @@ "last_name": "last_name2", "masked_card_number": "masked_card_number2" }, + "payment_collection_method": "prepaid", "subscription_ids": [ 146, 147, diff --git a/doc/models/subscription.md b/doc/models/subscription.md index 30e78809..50274e0f 100644 --- a/doc/models/subscription.md +++ b/doc/models/subscription.md @@ -34,7 +34,7 @@ | `DelayedCancelAt` | `models.Optional[time.Time]` | Optional | Timestamp for when the subscription is currently set to cancel. | | `CouponCode` | `models.Optional[string]` | Optional | (deprecated) The coupon code of the single coupon currently applied to the subscription. See coupon_codes instead as subscriptions can now have more than one coupon. | | `SnapDay` | `models.Optional[string]` | Optional | The day of the month that the subscription will charge according to calendar billing rules, if used. | -| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.
**Default**: `"automatic"` | +| `PaymentCollectionMethod` | [`*models.CollectionMethod`](../../doc/models/collection-method.md) | Optional | The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - `invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`. | | `Customer` | [`*models.Customer`](../../doc/models/customer.md) | Optional | - | | `Product` | [`*models.Product`](../../doc/models/product.md) | Optional | - | | `CreditCard` | [`*models.CreditCardPaymentProfile`](../../doc/models/credit-card-payment-profile.md) | Optional | - | @@ -76,7 +76,6 @@ ```json { - "payment_collection_method": "automatic", "credit_card": { "id": 10088716, "first_name": "Test", diff --git a/doc/models/void-invoice-event.md b/doc/models/void-invoice-event.md new file mode 100644 index 00000000..748debe6 --- /dev/null +++ b/doc/models/void-invoice-event.md @@ -0,0 +1,51 @@ + +# Void Invoice Event + +## Structure + +`VoidInvoiceEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"void_invoice"` | +| `EventData` | [`models.VoidInvoiceEventData`](../../doc/models/void-invoice-event-data.md) | Required | Example schema for an `void_invoice` event | + +## Example (as JSON) + +```json +{ + "id": 16, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "void_invoice", + "event_data": { + "credit_note_attributes": { + "uid": "uid2", + "site_id": 72, + "customer_id": 184, + "subscription_id": 0, + "number": "number0" + }, + "memo": "memo0", + "applied_amount": "applied_amount2", + "transaction_time": "2016-03-13T12:52:32.123Z", + "is_advance_invoice": false, + "reason": "reason2" + } +} +``` + diff --git a/doc/models/void-remainder-event.md b/doc/models/void-remainder-event.md new file mode 100644 index 00000000..46f4c614 --- /dev/null +++ b/doc/models/void-remainder-event.md @@ -0,0 +1,49 @@ + +# Void Remainder Event + +## Structure + +`VoidRemainderEvent` + +## Fields + +| Name | Type | Tags | Description | +| --- | --- | --- | --- | +| `Id` | `int64` | Required | - | +| `Timestamp` | `time.Time` | Required | - | +| `Invoice` | [`models.Invoice`](../../doc/models/invoice.md) | Required | - | +| `EventType` | [`models.InvoiceEventType`](../../doc/models/invoice-event-type.md) | Required | **Default**: `"void_remainder"` | +| `EventData` | [`models.VoidRemainderEventData`](../../doc/models/void-remainder-event-data.md) | Required | Example schema for an `void_remainder` event | + +## Example (as JSON) + +```json +{ + "id": 128, + "timestamp": "2016-03-13T12:52:32.123Z", + "invoice": { + "issue_date": "2024-01-01", + "due_date": "2024-01-01", + "paid_date": "2024-01-01", + "id": 166, + "uid": "uid6", + "site_id": 92, + "customer_id": 204, + "subscription_id": 20 + }, + "event_type": "void_remainder", + "event_data": { + "credit_note_attributes": { + "uid": "uid2", + "site_id": 72, + "customer_id": 184, + "subscription_id": 0, + "number": "number0" + }, + "memo": "memo0", + "applied_amount": "applied_amount2", + "transaction_time": "2016-03-13T12:52:32.123Z" + } +} +``` + diff --git a/events_controller.go b/events_controller.go index f69447e5..0320a22c 100644 --- a/events_controller.go +++ b/events_controller.go @@ -28,9 +28,9 @@ type ListEventsInput struct { // Use in query `per_page=200`. PerPage *int // Returns events with an id greater than or equal to the one specified - SinceId *int + SinceId *int64 // Returns events with an id less than or equal to the one specified - MaxId *int + MaxId *int64 // The sort direction of the returned events. Direction *models.Direction // You can pass multiple event keys after comma. @@ -160,9 +160,9 @@ type ListSubscriptionEventsInput struct { // Use in query `per_page=200`. PerPage *int // Returns events with an id greater than or equal to the one specified - SinceId *int + SinceId *int64 // Returns events with an id less than or equal to the one specified - MaxId *int + MaxId *int64 // The sort direction of the returned events. Direction *models.Direction // You can pass multiple event keys after comma. @@ -224,9 +224,9 @@ type ReadEventsCountInput struct { // Use in query `per_page=200`. PerPage *int // Returns events with an id greater than or equal to the one specified - SinceId *int + SinceId *int64 // Returns events with an id less than or equal to the one specified - MaxId *int + MaxId *int64 // The sort direction of the returned events. Direction *models.Direction // You can pass multiple event keys after comma. diff --git a/go.mod b/go.mod index a915b465..3241cf15 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/maxio-com/ab-golang-sdk go 1.18 -require github.com/apimatic/go-core-runtime v0.0.20 +require github.com/apimatic/go-core-runtime v0.0.21 diff --git a/invoices_controller.go b/invoices_controller.go index 43654648..94272e07 100644 --- a/invoices_controller.go +++ b/invoices_controller.go @@ -233,7 +233,7 @@ type ListInvoiceEventsInput struct { // The timestamp in a format `YYYY-MM-DD T HH:MM:SS Z`, or `YYYY-MM-DD`(in this case, it returns data from the beginning of the day). of the event from which you want to start the search. All the events before the `since_date` timestamp are not returned in the response. SinceDate *string // The ID of the event from which you want to start the search(ID is not included. e.g. if ID is set to 2, then all events with ID 3 and more will be shown) This parameter is not used if since_date is defined. - SinceId *int + SinceId *int64 // Result records are organized in pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. // Use in query `page=1`. Page *int diff --git a/models/apply_credit_note_event.go b/models/apply_credit_note_event.go new file mode 100644 index 00000000..678a1738 --- /dev/null +++ b/models/apply_credit_note_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// ApplyCreditNoteEvent represents a ApplyCreditNoteEvent struct. +type ApplyCreditNoteEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `apply_credit_note` event + EventData ApplyCreditNoteEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ApplyCreditNoteEvent. +// It customizes the JSON marshaling process for ApplyCreditNoteEvent objects. +func (a ApplyCreditNoteEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(a.toMap()) +} + +// toMap converts the ApplyCreditNoteEvent object to a map representation for JSON marshaling. +func (a ApplyCreditNoteEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, a.AdditionalProperties) + structMap["id"] = a.Id + structMap["timestamp"] = a.Timestamp.Format(time.RFC3339) + structMap["invoice"] = a.Invoice.toMap() + structMap["event_type"] = a.EventType + structMap["event_data"] = a.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ApplyCreditNoteEvent. +// It customizes the JSON unmarshaling process for ApplyCreditNoteEvent objects. +func (a *ApplyCreditNoteEvent) UnmarshalJSON(input []byte) error { + var temp applyCreditNoteEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + a.AdditionalProperties = additionalProperties + a.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + a.Timestamp = TimestampVal + a.Invoice = *temp.Invoice + a.EventType = *temp.EventType + a.EventData = *temp.EventData + return nil +} + +// applyCreditNoteEvent is a temporary struct used for validating the fields of ApplyCreditNoteEvent. +type applyCreditNoteEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *ApplyCreditNoteEventData `json:"event_data"` +} + +func (a *applyCreditNoteEvent) validate() error { + var errs []string + if a.Id == nil { + errs = append(errs, "required field `id` is missing for type `Apply Credit Note Event`") + } + if a.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Apply Credit Note Event`") + } + if a.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Apply Credit Note Event`") + } + if a.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Apply Credit Note Event`") + } + if a.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Apply Credit Note Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/apply_credit_note_event_data.go b/models/apply_credit_note_event_data.go index 30eb6850..acbb1826 100644 --- a/models/apply_credit_note_event_data.go +++ b/models/apply_credit_note_event_data.go @@ -24,7 +24,7 @@ type ApplyCreditNoteEventData struct { // The time the credit note was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" TransactionTime *time.Time `json:"transaction_time,omitempty"` // The credit note memo. - Memo *string `json:"memo,omitempty"` + Memo Optional[string] `json:"memo"` // The role of the credit note (e.g. 'general') Role *string `json:"role,omitempty"` // Shows whether it was applied to consolidated invoice or not @@ -54,8 +54,12 @@ func (a ApplyCreditNoteEventData) toMap() map[string]any { if a.TransactionTime != nil { structMap["transaction_time"] = a.TransactionTime.Format(time.RFC3339) } - if a.Memo != nil { - structMap["memo"] = a.Memo + if a.Memo.IsValueSet() { + if a.Memo.Value() != nil { + structMap["memo"] = a.Memo.Value() + } else { + structMap["memo"] = nil + } } if a.Role != nil { structMap["role"] = a.Role @@ -114,7 +118,7 @@ type applyCreditNoteEventData struct { OriginalAmount *string `json:"original_amount"` AppliedAmount *string `json:"applied_amount"` TransactionTime *string `json:"transaction_time,omitempty"` - Memo *string `json:"memo,omitempty"` + Memo Optional[string] `json:"memo"` Role *string `json:"role,omitempty"` ConsolidatedInvoice *bool `json:"consolidated_invoice,omitempty"` AppliedCreditNotes []AppliedCreditNoteData `json:"applied_credit_notes,omitempty"` diff --git a/models/apply_debit_note_event.go b/models/apply_debit_note_event.go new file mode 100644 index 00000000..73182951 --- /dev/null +++ b/models/apply_debit_note_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// ApplyDebitNoteEvent represents a ApplyDebitNoteEvent struct. +type ApplyDebitNoteEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `apply_debit_note` event + EventData ApplyDebitNoteEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ApplyDebitNoteEvent. +// It customizes the JSON marshaling process for ApplyDebitNoteEvent objects. +func (a ApplyDebitNoteEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(a.toMap()) +} + +// toMap converts the ApplyDebitNoteEvent object to a map representation for JSON marshaling. +func (a ApplyDebitNoteEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, a.AdditionalProperties) + structMap["id"] = a.Id + structMap["timestamp"] = a.Timestamp.Format(time.RFC3339) + structMap["invoice"] = a.Invoice.toMap() + structMap["event_type"] = a.EventType + structMap["event_data"] = a.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ApplyDebitNoteEvent. +// It customizes the JSON unmarshaling process for ApplyDebitNoteEvent objects. +func (a *ApplyDebitNoteEvent) UnmarshalJSON(input []byte) error { + var temp applyDebitNoteEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + a.AdditionalProperties = additionalProperties + a.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + a.Timestamp = TimestampVal + a.Invoice = *temp.Invoice + a.EventType = *temp.EventType + a.EventData = *temp.EventData + return nil +} + +// applyDebitNoteEvent is a temporary struct used for validating the fields of ApplyDebitNoteEvent. +type applyDebitNoteEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *ApplyDebitNoteEventData `json:"event_data"` +} + +func (a *applyDebitNoteEvent) validate() error { + var errs []string + if a.Id == nil { + errs = append(errs, "required field `id` is missing for type `Apply Debit Note Event`") + } + if a.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Apply Debit Note Event`") + } + if a.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Apply Debit Note Event`") + } + if a.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Apply Debit Note Event`") + } + if a.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Apply Debit Note Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/apply_debit_note_event_data.go b/models/apply_debit_note_event_data.go index 8837794a..df932d3a 100644 --- a/models/apply_debit_note_event_data.go +++ b/models/apply_debit_note_event_data.go @@ -3,21 +3,27 @@ package models import ( "encoding/json" "errors" + "log" "strings" + "time" ) // ApplyDebitNoteEventData represents a ApplyDebitNoteEventData struct. // Example schema for an `apply_debit_note` event type ApplyDebitNoteEventData struct { // A unique, identifying string that appears on the debit note and in places it is referenced. - DebitNoteNumber string `json:"debit_note_number"` + DebitNoteNumber string `json:"debit_note_number"` // Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix "db_" followed by alphanumeric characters. - DebitNoteUid string `json:"debit_note_uid"` + DebitNoteUid string `json:"debit_note_uid"` // The full, original amount of the debit note. - OriginalAmount string `json:"original_amount"` + OriginalAmount string `json:"original_amount"` // The amount of the debit note applied to invoice. - AppliedAmount string `json:"applied_amount"` - AdditionalProperties map[string]any `json:"_"` + AppliedAmount string `json:"applied_amount"` + // The debit note memo. + Memo Optional[string] `json:"memo"` + // The time the debit note was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" + TransactionTime Optional[time.Time] `json:"transaction_time"` + AdditionalProperties map[string]any `json:"_"` } // MarshalJSON implements the json.Marshaler interface for ApplyDebitNoteEventData. @@ -36,6 +42,25 @@ func (a ApplyDebitNoteEventData) toMap() map[string]any { structMap["debit_note_uid"] = a.DebitNoteUid structMap["original_amount"] = a.OriginalAmount structMap["applied_amount"] = a.AppliedAmount + if a.Memo.IsValueSet() { + if a.Memo.Value() != nil { + structMap["memo"] = a.Memo.Value() + } else { + structMap["memo"] = nil + } + } + if a.TransactionTime.IsValueSet() { + var TransactionTimeVal *string = nil + if a.TransactionTime.Value() != nil { + val := a.TransactionTime.Value().Format(time.RFC3339) + TransactionTimeVal = &val + } + if a.TransactionTime.Value() != nil { + structMap["transaction_time"] = TransactionTimeVal + } else { + structMap["transaction_time"] = nil + } + } return structMap } @@ -51,7 +76,7 @@ func (a *ApplyDebitNoteEventData) UnmarshalJSON(input []byte) error { if err != nil { return err } - additionalProperties, err := UnmarshalAdditionalProperties(input, "debit_note_number", "debit_note_uid", "original_amount", "applied_amount") + additionalProperties, err := UnmarshalAdditionalProperties(input, "debit_note_number", "debit_note_uid", "original_amount", "applied_amount", "memo", "transaction_time") if err != nil { return err } @@ -61,15 +86,26 @@ func (a *ApplyDebitNoteEventData) UnmarshalJSON(input []byte) error { a.DebitNoteUid = *temp.DebitNoteUid a.OriginalAmount = *temp.OriginalAmount a.AppliedAmount = *temp.AppliedAmount + a.Memo = temp.Memo + a.TransactionTime.ShouldSetValue(temp.TransactionTime.IsValueSet()) + if temp.TransactionTime.Value() != nil { + TransactionTimeVal, err := time.Parse(time.RFC3339, (*temp.TransactionTime.Value())) + if err != nil { + log.Fatalf("Cannot Parse transaction_time as % s format.", time.RFC3339) + } + a.TransactionTime.SetValue(&TransactionTimeVal) + } return nil } // applyDebitNoteEventData is a temporary struct used for validating the fields of ApplyDebitNoteEventData. type applyDebitNoteEventData struct { - DebitNoteNumber *string `json:"debit_note_number"` - DebitNoteUid *string `json:"debit_note_uid"` - OriginalAmount *string `json:"original_amount"` - AppliedAmount *string `json:"applied_amount"` + DebitNoteNumber *string `json:"debit_note_number"` + DebitNoteUid *string `json:"debit_note_uid"` + OriginalAmount *string `json:"original_amount"` + AppliedAmount *string `json:"applied_amount"` + Memo Optional[string] `json:"memo"` + TransactionTime Optional[string] `json:"transaction_time"` } func (a *applyDebitNoteEventData) validate() error { diff --git a/models/apply_payment_event.go b/models/apply_payment_event.go new file mode 100644 index 00000000..1b622911 --- /dev/null +++ b/models/apply_payment_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// ApplyPaymentEvent represents a ApplyPaymentEvent struct. +type ApplyPaymentEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `apply_payment` event + EventData ApplyPaymentEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ApplyPaymentEvent. +// It customizes the JSON marshaling process for ApplyPaymentEvent objects. +func (a ApplyPaymentEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(a.toMap()) +} + +// toMap converts the ApplyPaymentEvent object to a map representation for JSON marshaling. +func (a ApplyPaymentEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, a.AdditionalProperties) + structMap["id"] = a.Id + structMap["timestamp"] = a.Timestamp.Format(time.RFC3339) + structMap["invoice"] = a.Invoice.toMap() + structMap["event_type"] = a.EventType + structMap["event_data"] = a.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ApplyPaymentEvent. +// It customizes the JSON unmarshaling process for ApplyPaymentEvent objects. +func (a *ApplyPaymentEvent) UnmarshalJSON(input []byte) error { + var temp applyPaymentEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + a.AdditionalProperties = additionalProperties + a.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + a.Timestamp = TimestampVal + a.Invoice = *temp.Invoice + a.EventType = *temp.EventType + a.EventData = *temp.EventData + return nil +} + +// applyPaymentEvent is a temporary struct used for validating the fields of ApplyPaymentEvent. +type applyPaymentEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *ApplyPaymentEventData `json:"event_data"` +} + +func (a *applyPaymentEvent) validate() error { + var errs []string + if a.Id == nil { + errs = append(errs, "required field `id` is missing for type `Apply Payment Event`") + } + if a.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Apply Payment Event`") + } + if a.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Apply Payment Event`") + } + if a.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Apply Payment Event`") + } + if a.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Apply Payment Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/apply_payment_event_data.go b/models/apply_payment_event_data.go index 99665b0b..22b8856f 100644 --- a/models/apply_payment_event_data.go +++ b/models/apply_payment_event_data.go @@ -11,23 +11,24 @@ import ( // ApplyPaymentEventData represents a ApplyPaymentEventData struct. // Example schema for an `apply_payment` event type ApplyPaymentEventData struct { + ConsolidationLevel InvoiceConsolidationLevel `json:"consolidation_level"` // The payment memo - Memo string `json:"memo"` + Memo string `json:"memo"` // The full, original amount of the payment transaction as a string in full units. Incoming payments can be split amongst several invoices, which will result in a `applied_amount` less than the `original_amount`. Example: A $100.99 payment, of which $40.11 is applied to this invoice, will have an `original_amount` of `"100.99"`. - OriginalAmount string `json:"original_amount"` + OriginalAmount string `json:"original_amount"` // The amount of the payment applied to this invoice. Incoming payments can be split amongst several invoices, which will result in a `applied_amount` less than the `original_amount`. Example: A $100.99 payment, of which $40.11 is applied to this invoice, will have an `applied_amount` of `"40.11"`. - AppliedAmount string `json:"applied_amount"` + AppliedAmount string `json:"applied_amount"` // The time the payment was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" - TransactionTime time.Time `json:"transaction_time"` + TransactionTime time.Time `json:"transaction_time"` // A nested data structure detailing the method of payment - PaymentMethod InvoiceEventPayment2 `json:"payment_method"` + PaymentMethod InvoiceEventPayment `json:"payment_method"` // The Chargify id of the original payment - TransactionId *int `json:"transaction_id,omitempty"` - ParentInvoiceNumber Optional[int] `json:"parent_invoice_number"` - RemainingPrepaymentAmount Optional[string] `json:"remaining_prepayment_amount"` - Prepayment *bool `json:"prepayment,omitempty"` - External *bool `json:"external,omitempty"` - AdditionalProperties map[string]any `json:"_"` + TransactionId *int `json:"transaction_id,omitempty"` + ParentInvoiceNumber Optional[int] `json:"parent_invoice_number"` + RemainingPrepaymentAmount Optional[string] `json:"remaining_prepayment_amount"` + Prepayment *bool `json:"prepayment,omitempty"` + External *bool `json:"external,omitempty"` + AdditionalProperties map[string]any `json:"_"` } // MarshalJSON implements the json.Marshaler interface for ApplyPaymentEventData. @@ -42,6 +43,7 @@ func (a ApplyPaymentEventData) MarshalJSON() ( func (a ApplyPaymentEventData) toMap() map[string]any { structMap := make(map[string]any) MapAdditionalProperties(structMap, a.AdditionalProperties) + structMap["consolidation_level"] = a.ConsolidationLevel structMap["memo"] = a.Memo structMap["original_amount"] = a.OriginalAmount structMap["applied_amount"] = a.AppliedAmount @@ -85,12 +87,13 @@ func (a *ApplyPaymentEventData) UnmarshalJSON(input []byte) error { if err != nil { return err } - additionalProperties, err := UnmarshalAdditionalProperties(input, "memo", "original_amount", "applied_amount", "transaction_time", "payment_method", "transaction_id", "parent_invoice_number", "remaining_prepayment_amount", "prepayment", "external") + additionalProperties, err := UnmarshalAdditionalProperties(input, "consolidation_level", "memo", "original_amount", "applied_amount", "transaction_time", "payment_method", "transaction_id", "parent_invoice_number", "remaining_prepayment_amount", "prepayment", "external") if err != nil { return err } a.AdditionalProperties = additionalProperties + a.ConsolidationLevel = *temp.ConsolidationLevel a.Memo = *temp.Memo a.OriginalAmount = *temp.OriginalAmount a.AppliedAmount = *temp.AppliedAmount @@ -110,20 +113,24 @@ func (a *ApplyPaymentEventData) UnmarshalJSON(input []byte) error { // applyPaymentEventData is a temporary struct used for validating the fields of ApplyPaymentEventData. type applyPaymentEventData struct { - Memo *string `json:"memo"` - OriginalAmount *string `json:"original_amount"` - AppliedAmount *string `json:"applied_amount"` - TransactionTime *string `json:"transaction_time"` - PaymentMethod *InvoiceEventPayment2 `json:"payment_method"` - TransactionId *int `json:"transaction_id,omitempty"` - ParentInvoiceNumber Optional[int] `json:"parent_invoice_number"` - RemainingPrepaymentAmount Optional[string] `json:"remaining_prepayment_amount"` - Prepayment *bool `json:"prepayment,omitempty"` - External *bool `json:"external,omitempty"` + ConsolidationLevel *InvoiceConsolidationLevel `json:"consolidation_level"` + Memo *string `json:"memo"` + OriginalAmount *string `json:"original_amount"` + AppliedAmount *string `json:"applied_amount"` + TransactionTime *string `json:"transaction_time"` + PaymentMethod *InvoiceEventPayment `json:"payment_method"` + TransactionId *int `json:"transaction_id,omitempty"` + ParentInvoiceNumber Optional[int] `json:"parent_invoice_number"` + RemainingPrepaymentAmount Optional[string] `json:"remaining_prepayment_amount"` + Prepayment *bool `json:"prepayment,omitempty"` + External *bool `json:"external,omitempty"` } func (a *applyPaymentEventData) validate() error { var errs []string + if a.ConsolidationLevel == nil { + errs = append(errs, "required field `consolidation_level` is missing for type `Apply Payment Event Data`") + } if a.Memo == nil { errs = append(errs, "required field `memo` is missing for type `Apply Payment Event Data`") } diff --git a/models/backport_invoice_event.go b/models/backport_invoice_event.go new file mode 100644 index 00000000..c865872b --- /dev/null +++ b/models/backport_invoice_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// BackportInvoiceEvent represents a BackportInvoiceEvent struct. +type BackportInvoiceEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `backport_invoice` event + EventData Invoice `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for BackportInvoiceEvent. +// It customizes the JSON marshaling process for BackportInvoiceEvent objects. +func (b BackportInvoiceEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(b.toMap()) +} + +// toMap converts the BackportInvoiceEvent object to a map representation for JSON marshaling. +func (b BackportInvoiceEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, b.AdditionalProperties) + structMap["id"] = b.Id + structMap["timestamp"] = b.Timestamp.Format(time.RFC3339) + structMap["invoice"] = b.Invoice.toMap() + structMap["event_type"] = b.EventType + structMap["event_data"] = b.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for BackportInvoiceEvent. +// It customizes the JSON unmarshaling process for BackportInvoiceEvent objects. +func (b *BackportInvoiceEvent) UnmarshalJSON(input []byte) error { + var temp backportInvoiceEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + b.AdditionalProperties = additionalProperties + b.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + b.Timestamp = TimestampVal + b.Invoice = *temp.Invoice + b.EventType = *temp.EventType + b.EventData = *temp.EventData + return nil +} + +// backportInvoiceEvent is a temporary struct used for validating the fields of BackportInvoiceEvent. +type backportInvoiceEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *Invoice `json:"event_data"` +} + +func (b *backportInvoiceEvent) validate() error { + var errs []string + if b.Id == nil { + errs = append(errs, "required field `id` is missing for type `Backport Invoice Event`") + } + if b.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Backport Invoice Event`") + } + if b.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Backport Invoice Event`") + } + if b.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Backport Invoice Event`") + } + if b.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Backport Invoice Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/billing_address.go b/models/billing_address.go deleted file mode 100644 index 6ab7fdbf..00000000 --- a/models/billing_address.go +++ /dev/null @@ -1,106 +0,0 @@ -package models - -import ( - "encoding/json" -) - -// BillingAddress represents a BillingAddress struct. -type BillingAddress struct { - Street Optional[string] `json:"street"` - Line2 Optional[string] `json:"line2"` - City Optional[string] `json:"city"` - State Optional[string] `json:"state"` - Zip Optional[string] `json:"zip"` - Country Optional[string] `json:"country"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for BillingAddress. -// It customizes the JSON marshaling process for BillingAddress objects. -func (b BillingAddress) MarshalJSON() ( - []byte, - error) { - return json.Marshal(b.toMap()) -} - -// toMap converts the BillingAddress object to a map representation for JSON marshaling. -func (b BillingAddress) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, b.AdditionalProperties) - if b.Street.IsValueSet() { - if b.Street.Value() != nil { - structMap["street"] = b.Street.Value() - } else { - structMap["street"] = nil - } - } - if b.Line2.IsValueSet() { - if b.Line2.Value() != nil { - structMap["line2"] = b.Line2.Value() - } else { - structMap["line2"] = nil - } - } - if b.City.IsValueSet() { - if b.City.Value() != nil { - structMap["city"] = b.City.Value() - } else { - structMap["city"] = nil - } - } - if b.State.IsValueSet() { - if b.State.Value() != nil { - structMap["state"] = b.State.Value() - } else { - structMap["state"] = nil - } - } - if b.Zip.IsValueSet() { - if b.Zip.Value() != nil { - structMap["zip"] = b.Zip.Value() - } else { - structMap["zip"] = nil - } - } - if b.Country.IsValueSet() { - if b.Country.Value() != nil { - structMap["country"] = b.Country.Value() - } else { - structMap["country"] = nil - } - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for BillingAddress. -// It customizes the JSON unmarshaling process for BillingAddress objects. -func (b *BillingAddress) UnmarshalJSON(input []byte) error { - var temp billingAddress - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "street", "line2", "city", "state", "zip", "country") - if err != nil { - return err - } - - b.AdditionalProperties = additionalProperties - b.Street = temp.Street - b.Line2 = temp.Line2 - b.City = temp.City - b.State = temp.State - b.Zip = temp.Zip - b.Country = temp.Country - return nil -} - -// billingAddress is a temporary struct used for validating the fields of BillingAddress. -type billingAddress struct { - Street Optional[string] `json:"street"` - Line2 Optional[string] `json:"line2"` - City Optional[string] `json:"city"` - State Optional[string] `json:"state"` - Zip Optional[string] `json:"zip"` - Country Optional[string] `json:"country"` -} diff --git a/models/change_chargeback_status_event.go b/models/change_chargeback_status_event.go new file mode 100644 index 00000000..5dadc702 --- /dev/null +++ b/models/change_chargeback_status_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// ChangeChargebackStatusEvent represents a ChangeChargebackStatusEvent struct. +type ChangeChargebackStatusEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `change_chargeback_status` event + EventData ChangeChargebackStatusEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ChangeChargebackStatusEvent. +// It customizes the JSON marshaling process for ChangeChargebackStatusEvent objects. +func (c ChangeChargebackStatusEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the ChangeChargebackStatusEvent object to a map representation for JSON marshaling. +func (c ChangeChargebackStatusEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + structMap["id"] = c.Id + structMap["timestamp"] = c.Timestamp.Format(time.RFC3339) + structMap["invoice"] = c.Invoice.toMap() + structMap["event_type"] = c.EventType + structMap["event_data"] = c.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ChangeChargebackStatusEvent. +// It customizes the JSON unmarshaling process for ChangeChargebackStatusEvent objects. +func (c *ChangeChargebackStatusEvent) UnmarshalJSON(input []byte) error { + var temp changeChargebackStatusEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + c.Timestamp = TimestampVal + c.Invoice = *temp.Invoice + c.EventType = *temp.EventType + c.EventData = *temp.EventData + return nil +} + +// changeChargebackStatusEvent is a temporary struct used for validating the fields of ChangeChargebackStatusEvent. +type changeChargebackStatusEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *ChangeChargebackStatusEventData `json:"event_data"` +} + +func (c *changeChargebackStatusEvent) validate() error { + var errs []string + if c.Id == nil { + errs = append(errs, "required field `id` is missing for type `Change Chargeback Status Event`") + } + if c.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Change Chargeback Status Event`") + } + if c.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Change Chargeback Status Event`") + } + if c.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Change Chargeback Status Event`") + } + if c.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Change Chargeback Status Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/change_chargeback_status_event_data.go b/models/change_chargeback_status_event_data.go new file mode 100644 index 00000000..c5aab009 --- /dev/null +++ b/models/change_chargeback_status_event_data.go @@ -0,0 +1,68 @@ +package models + +import ( + "encoding/json" + "errors" + "strings" +) + +// ChangeChargebackStatusEventData represents a ChangeChargebackStatusEventData struct. +// Example schema for an `change_chargeback_status` event +type ChangeChargebackStatusEventData struct { + ChargebackStatus ChargebackStatus `json:"chargeback_status"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ChangeChargebackStatusEventData. +// It customizes the JSON marshaling process for ChangeChargebackStatusEventData objects. +func (c ChangeChargebackStatusEventData) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the ChangeChargebackStatusEventData object to a map representation for JSON marshaling. +func (c ChangeChargebackStatusEventData) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + structMap["chargeback_status"] = c.ChargebackStatus + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ChangeChargebackStatusEventData. +// It customizes the JSON unmarshaling process for ChangeChargebackStatusEventData objects. +func (c *ChangeChargebackStatusEventData) UnmarshalJSON(input []byte) error { + var temp changeChargebackStatusEventData + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "chargeback_status") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.ChargebackStatus = *temp.ChargebackStatus + return nil +} + +// changeChargebackStatusEventData is a temporary struct used for validating the fields of ChangeChargebackStatusEventData. +type changeChargebackStatusEventData struct { + ChargebackStatus *ChargebackStatus `json:"chargeback_status"` +} + +func (c *changeChargebackStatusEventData) validate() error { + var errs []string + if c.ChargebackStatus == nil { + errs = append(errs, "required field `chargeback_status` is missing for type `Change Chargeback Status Event Data`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/change_invoice_collection_method_event.go b/models/change_invoice_collection_method_event.go new file mode 100644 index 00000000..060443f1 --- /dev/null +++ b/models/change_invoice_collection_method_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// ChangeInvoiceCollectionMethodEvent represents a ChangeInvoiceCollectionMethodEvent struct. +type ChangeInvoiceCollectionMethodEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `change_invoice_collection_method` event + EventData ChangeInvoiceCollectionMethodEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ChangeInvoiceCollectionMethodEvent. +// It customizes the JSON marshaling process for ChangeInvoiceCollectionMethodEvent objects. +func (c ChangeInvoiceCollectionMethodEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the ChangeInvoiceCollectionMethodEvent object to a map representation for JSON marshaling. +func (c ChangeInvoiceCollectionMethodEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + structMap["id"] = c.Id + structMap["timestamp"] = c.Timestamp.Format(time.RFC3339) + structMap["invoice"] = c.Invoice.toMap() + structMap["event_type"] = c.EventType + structMap["event_data"] = c.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ChangeInvoiceCollectionMethodEvent. +// It customizes the JSON unmarshaling process for ChangeInvoiceCollectionMethodEvent objects. +func (c *ChangeInvoiceCollectionMethodEvent) UnmarshalJSON(input []byte) error { + var temp changeInvoiceCollectionMethodEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + c.Timestamp = TimestampVal + c.Invoice = *temp.Invoice + c.EventType = *temp.EventType + c.EventData = *temp.EventData + return nil +} + +// changeInvoiceCollectionMethodEvent is a temporary struct used for validating the fields of ChangeInvoiceCollectionMethodEvent. +type changeInvoiceCollectionMethodEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *ChangeInvoiceCollectionMethodEventData `json:"event_data"` +} + +func (c *changeInvoiceCollectionMethodEvent) validate() error { + var errs []string + if c.Id == nil { + errs = append(errs, "required field `id` is missing for type `Change Invoice Collection Method Event`") + } + if c.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Change Invoice Collection Method Event`") + } + if c.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Change Invoice Collection Method Event`") + } + if c.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Change Invoice Collection Method Event`") + } + if c.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Change Invoice Collection Method Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/change_invoice_status_event.go b/models/change_invoice_status_event.go new file mode 100644 index 00000000..7ca81928 --- /dev/null +++ b/models/change_invoice_status_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// ChangeInvoiceStatusEvent represents a ChangeInvoiceStatusEvent struct. +type ChangeInvoiceStatusEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `change_invoice_status` event + EventData ChangeInvoiceStatusEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ChangeInvoiceStatusEvent. +// It customizes the JSON marshaling process for ChangeInvoiceStatusEvent objects. +func (c ChangeInvoiceStatusEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the ChangeInvoiceStatusEvent object to a map representation for JSON marshaling. +func (c ChangeInvoiceStatusEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + structMap["id"] = c.Id + structMap["timestamp"] = c.Timestamp.Format(time.RFC3339) + structMap["invoice"] = c.Invoice.toMap() + structMap["event_type"] = c.EventType + structMap["event_data"] = c.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ChangeInvoiceStatusEvent. +// It customizes the JSON unmarshaling process for ChangeInvoiceStatusEvent objects. +func (c *ChangeInvoiceStatusEvent) UnmarshalJSON(input []byte) error { + var temp changeInvoiceStatusEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + c.Timestamp = TimestampVal + c.Invoice = *temp.Invoice + c.EventType = *temp.EventType + c.EventData = *temp.EventData + return nil +} + +// changeInvoiceStatusEvent is a temporary struct used for validating the fields of ChangeInvoiceStatusEvent. +type changeInvoiceStatusEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *ChangeInvoiceStatusEventData `json:"event_data"` +} + +func (c *changeInvoiceStatusEvent) validate() error { + var errs []string + if c.Id == nil { + errs = append(errs, "required field `id` is missing for type `Change Invoice Status Event`") + } + if c.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Change Invoice Status Event`") + } + if c.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Change Invoice Status Event`") + } + if c.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Change Invoice Status Event`") + } + if c.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Change Invoice Status Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/change_invoice_status_event_data.go b/models/change_invoice_status_event_data.go new file mode 100644 index 00000000..68027e9e --- /dev/null +++ b/models/change_invoice_status_event_data.go @@ -0,0 +1,97 @@ +package models + +import ( + "encoding/json" + "errors" + "strings" +) + +// ChangeInvoiceStatusEventData represents a ChangeInvoiceStatusEventData struct. +// Example schema for an `change_invoice_status` event +type ChangeInvoiceStatusEventData struct { + // Identifier for the transaction within the payment gateway. + GatewayTransId *string `json:"gateway_trans_id,omitempty"` + // The monetary value associated with the linked payment, expressed in dollars. + Amount *string `json:"amount,omitempty"` + // The status of the invoice before any changes occurred. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. + FromStatus InvoiceStatus `json:"from_status"` + // The updated status of the invoice after changes have been made. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. + ToStatus InvoiceStatus `json:"to_status"` + ConsolidationLevel *InvoiceConsolidationLevel `json:"consolidation_level,omitempty"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for ChangeInvoiceStatusEventData. +// It customizes the JSON marshaling process for ChangeInvoiceStatusEventData objects. +func (c ChangeInvoiceStatusEventData) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the ChangeInvoiceStatusEventData object to a map representation for JSON marshaling. +func (c ChangeInvoiceStatusEventData) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + if c.GatewayTransId != nil { + structMap["gateway_trans_id"] = c.GatewayTransId + } + if c.Amount != nil { + structMap["amount"] = c.Amount + } + structMap["from_status"] = c.FromStatus + structMap["to_status"] = c.ToStatus + if c.ConsolidationLevel != nil { + structMap["consolidation_level"] = c.ConsolidationLevel + } + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ChangeInvoiceStatusEventData. +// It customizes the JSON unmarshaling process for ChangeInvoiceStatusEventData objects. +func (c *ChangeInvoiceStatusEventData) UnmarshalJSON(input []byte) error { + var temp changeInvoiceStatusEventData + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "gateway_trans_id", "amount", "from_status", "to_status", "consolidation_level") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.GatewayTransId = temp.GatewayTransId + c.Amount = temp.Amount + c.FromStatus = *temp.FromStatus + c.ToStatus = *temp.ToStatus + c.ConsolidationLevel = temp.ConsolidationLevel + return nil +} + +// changeInvoiceStatusEventData is a temporary struct used for validating the fields of ChangeInvoiceStatusEventData. +type changeInvoiceStatusEventData struct { + GatewayTransId *string `json:"gateway_trans_id,omitempty"` + Amount *string `json:"amount,omitempty"` + FromStatus *InvoiceStatus `json:"from_status"` + ToStatus *InvoiceStatus `json:"to_status"` + ConsolidationLevel *InvoiceConsolidationLevel `json:"consolidation_level,omitempty"` +} + +func (c *changeInvoiceStatusEventData) validate() error { + var errs []string + if c.FromStatus == nil { + errs = append(errs, "required field `from_status` is missing for type `Change Invoice Status Event Data`") + } + if c.ToStatus == nil { + errs = append(errs, "required field `to_status` is missing for type `Change Invoice Status Event Data`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/create_credit_note_event.go b/models/create_credit_note_event.go new file mode 100644 index 00000000..79f3b91f --- /dev/null +++ b/models/create_credit_note_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// CreateCreditNoteEvent represents a CreateCreditNoteEvent struct. +type CreateCreditNoteEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `create_credit_note` event + EventData CreditNote `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for CreateCreditNoteEvent. +// It customizes the JSON marshaling process for CreateCreditNoteEvent objects. +func (c CreateCreditNoteEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the CreateCreditNoteEvent object to a map representation for JSON marshaling. +func (c CreateCreditNoteEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + structMap["id"] = c.Id + structMap["timestamp"] = c.Timestamp.Format(time.RFC3339) + structMap["invoice"] = c.Invoice.toMap() + structMap["event_type"] = c.EventType + structMap["event_data"] = c.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for CreateCreditNoteEvent. +// It customizes the JSON unmarshaling process for CreateCreditNoteEvent objects. +func (c *CreateCreditNoteEvent) UnmarshalJSON(input []byte) error { + var temp createCreditNoteEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + c.Timestamp = TimestampVal + c.Invoice = *temp.Invoice + c.EventType = *temp.EventType + c.EventData = *temp.EventData + return nil +} + +// createCreditNoteEvent is a temporary struct used for validating the fields of CreateCreditNoteEvent. +type createCreditNoteEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *CreditNote `json:"event_data"` +} + +func (c *createCreditNoteEvent) validate() error { + var errs []string + if c.Id == nil { + errs = append(errs, "required field `id` is missing for type `Create Credit Note Event`") + } + if c.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Create Credit Note Event`") + } + if c.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Create Credit Note Event`") + } + if c.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Create Credit Note Event`") + } + if c.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Create Credit Note Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/create_debit_note_event.go b/models/create_debit_note_event.go new file mode 100644 index 00000000..79db26ef --- /dev/null +++ b/models/create_debit_note_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// CreateDebitNoteEvent represents a CreateDebitNoteEvent struct. +type CreateDebitNoteEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `create_debit_note` event + EventData DebitNote `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for CreateDebitNoteEvent. +// It customizes the JSON marshaling process for CreateDebitNoteEvent objects. +func (c CreateDebitNoteEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(c.toMap()) +} + +// toMap converts the CreateDebitNoteEvent object to a map representation for JSON marshaling. +func (c CreateDebitNoteEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, c.AdditionalProperties) + structMap["id"] = c.Id + structMap["timestamp"] = c.Timestamp.Format(time.RFC3339) + structMap["invoice"] = c.Invoice.toMap() + structMap["event_type"] = c.EventType + structMap["event_data"] = c.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for CreateDebitNoteEvent. +// It customizes the JSON unmarshaling process for CreateDebitNoteEvent objects. +func (c *CreateDebitNoteEvent) UnmarshalJSON(input []byte) error { + var temp createDebitNoteEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + c.AdditionalProperties = additionalProperties + c.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + c.Timestamp = TimestampVal + c.Invoice = *temp.Invoice + c.EventType = *temp.EventType + c.EventData = *temp.EventData + return nil +} + +// createDebitNoteEvent is a temporary struct used for validating the fields of CreateDebitNoteEvent. +type createDebitNoteEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *DebitNote `json:"event_data"` +} + +func (c *createDebitNoteEvent) validate() error { + var errs []string + if c.Id == nil { + errs = append(errs, "required field `id` is missing for type `Create Debit Note Event`") + } + if c.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Create Debit Note Event`") + } + if c.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Create Debit Note Event`") + } + if c.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Create Debit Note Event`") + } + if c.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Create Debit Note Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/create_product_family.go b/models/create_product_family.go index eff176fd..0a939d70 100644 --- a/models/create_product_family.go +++ b/models/create_product_family.go @@ -2,11 +2,14 @@ package models import ( "encoding/json" + "errors" + "strings" ) // CreateProductFamily represents a CreateProductFamily struct. type CreateProductFamily struct { - Name *string `json:"name,omitempty"` + Name string `json:"name"` + Handle Optional[string] `json:"handle"` Description Optional[string] `json:"description"` AdditionalProperties map[string]any `json:"_"` } @@ -23,8 +26,13 @@ func (c CreateProductFamily) MarshalJSON() ( func (c CreateProductFamily) toMap() map[string]any { structMap := make(map[string]any) MapAdditionalProperties(structMap, c.AdditionalProperties) - if c.Name != nil { - structMap["name"] = c.Name + structMap["name"] = c.Name + if c.Handle.IsValueSet() { + if c.Handle.Value() != nil { + structMap["handle"] = c.Handle.Value() + } else { + structMap["handle"] = nil + } } if c.Description.IsValueSet() { if c.Description.Value() != nil { @@ -44,19 +52,36 @@ func (c *CreateProductFamily) UnmarshalJSON(input []byte) error { if err != nil { return err } - additionalProperties, err := UnmarshalAdditionalProperties(input, "name", "description") + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "name", "handle", "description") if err != nil { return err } c.AdditionalProperties = additionalProperties - c.Name = temp.Name + c.Name = *temp.Name + c.Handle = temp.Handle c.Description = temp.Description return nil } // createProductFamily is a temporary struct used for validating the fields of CreateProductFamily. type createProductFamily struct { - Name *string `json:"name,omitempty"` + Name *string `json:"name"` + Handle Optional[string] `json:"handle"` Description Optional[string] `json:"description"` } + +func (c *createProductFamily) validate() error { + var errs []string + if c.Name == nil { + errs = append(errs, "required field `name` is missing for type `Create Product Family`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/credit_note_1.go b/models/credit_note_1.go deleted file mode 100644 index fd40efad..00000000 --- a/models/credit_note_1.go +++ /dev/null @@ -1,245 +0,0 @@ -package models - -import ( - "encoding/json" - "log" - "time" -) - -// CreditNote1 represents a CreditNote1 struct. -type CreditNote1 struct { - // Unique identifier for the credit note. It is generated automatically by Chargify and has the prefix "cn_" followed by alphanumeric characters. - Uid *string `json:"uid,omitempty"` - // ID of the site to which the credit note belongs. - SiteId *int `json:"site_id,omitempty"` - // ID of the customer to which the credit note belongs. - CustomerId *int `json:"customer_id,omitempty"` - // ID of the subscription that generated the credit note. - SubscriptionId *int `json:"subscription_id,omitempty"` - // A unique, identifying string that appears on the credit note and in places it is referenced. - // While the UID is long and not appropriate to show to customers, the number is usually shorter and consumable by the customer and the merchant alike. - Number *string `json:"number,omitempty"` - // A monotonically increasing number assigned to credit notes as they are created. This number is unique within a site and can be used to sort and order credit notes. - SequenceNumber *int `json:"sequence_number,omitempty"` - // Date the credit note was issued to the customer. This is the date that the credit was made available for application, and may come before it is fully applied. - // The format is `"YYYY-MM-DD"`. - IssueDate *time.Time `json:"issue_date,omitempty"` - // Credit notes are applied to invoices to offset invoiced amounts - they reduce the amount due. This field is the date the credit note became fully applied to invoices. - // If the credit note has been partially applied, this field will not have a value until it has been fully applied. - // The format is `"YYYY-MM-DD"`. - AppliedDate *time.Time `json:"applied_date,omitempty"` - // Current status of the credit note. - Status *CreditNoteStatus `json:"status,omitempty"` - // The ISO 4217 currency code (3 character string) representing the currency of the credit note amount fields. - Currency *string `json:"currency,omitempty"` - // The memo printed on credit note, which is a description of the reason for the credit. - Memo *string `json:"memo,omitempty"` - Seller *Seller `json:"seller,omitempty"` - Customer *Customer1 `json:"customer,omitempty"` - BillingAddress *BillingAddress `json:"billing_address,omitempty"` - ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` - // Subtotal of the credit note, which is the sum of all line items before discounts or taxes. Note that this is a positive amount representing the credit back to the customer. - SubtotalAmount *string `json:"subtotal_amount,omitempty"` - // Total discount applied to the credit note. Note that this is a positive amount representing the discount amount being credited back to the customer (i.e. a credit on an earlier discount). For example, if the original purchase was $1.00 and the original discount was $0.10, a credit of $0.50 of the original purchase (half) would have a discount credit of $0.05 (also half). - DiscountAmount *string `json:"discount_amount,omitempty"` - // Total tax of the credit note. Note that this is a positive amount representing a previously taxex amount being credited back to the customer (i.e. a credit of an earlier tax). For example, if the original purchase was $1.00 and the original tax was $0.10, a credit of $0.50 of the original purchase (half) would also have a tax credit of $0.05 (also half). - TaxAmount *string `json:"tax_amount,omitempty"` - // The credit note total, which is `subtotal_amount - discount_amount + tax_amount`.' - TotalAmount *string `json:"total_amount,omitempty"` - // The amount of the credit note that has already been applied to invoices. - AppliedAmount *string `json:"applied_amount,omitempty"` - // The amount of the credit note remaining to be applied to invoices, which is `total_amount - applied_amount`. - RemainingAmount *string `json:"remaining_amount,omitempty"` - // Line items on the credit note. - LineItems []CreditNoteLineItem `json:"line_items,omitempty"` - Discounts []InvoiceDiscount `json:"discounts,omitempty"` - Taxes []InvoiceTax `json:"taxes,omitempty"` - Applications []CreditNoteApplication `json:"applications,omitempty"` - Refunds []InvoiceRefund `json:"refunds,omitempty"` - // An array of origin invoices for the credit note. Learn more about [Origin Invoice from our docs](https://chargify.zendesk.com/hc/en-us/articles/4407753036699#origin-invoices) - OriginInvoices []OriginInvoice `json:"origin_invoices,omitempty"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for CreditNote1. -// It customizes the JSON marshaling process for CreditNote1 objects. -func (c CreditNote1) MarshalJSON() ( - []byte, - error) { - return json.Marshal(c.toMap()) -} - -// toMap converts the CreditNote1 object to a map representation for JSON marshaling. -func (c CreditNote1) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, c.AdditionalProperties) - if c.Uid != nil { - structMap["uid"] = c.Uid - } - if c.SiteId != nil { - structMap["site_id"] = c.SiteId - } - if c.CustomerId != nil { - structMap["customer_id"] = c.CustomerId - } - if c.SubscriptionId != nil { - structMap["subscription_id"] = c.SubscriptionId - } - if c.Number != nil { - structMap["number"] = c.Number - } - if c.SequenceNumber != nil { - structMap["sequence_number"] = c.SequenceNumber - } - if c.IssueDate != nil { - structMap["issue_date"] = c.IssueDate.Format(DEFAULT_DATE) - } - if c.AppliedDate != nil { - structMap["applied_date"] = c.AppliedDate.Format(DEFAULT_DATE) - } - if c.Status != nil { - structMap["status"] = c.Status - } - if c.Currency != nil { - structMap["currency"] = c.Currency - } - if c.Memo != nil { - structMap["memo"] = c.Memo - } - if c.Seller != nil { - structMap["seller"] = c.Seller.toMap() - } - if c.Customer != nil { - structMap["customer"] = c.Customer.toMap() - } - if c.BillingAddress != nil { - structMap["billing_address"] = c.BillingAddress.toMap() - } - if c.ShippingAddress != nil { - structMap["shipping_address"] = c.ShippingAddress.toMap() - } - if c.SubtotalAmount != nil { - structMap["subtotal_amount"] = c.SubtotalAmount - } - if c.DiscountAmount != nil { - structMap["discount_amount"] = c.DiscountAmount - } - if c.TaxAmount != nil { - structMap["tax_amount"] = c.TaxAmount - } - if c.TotalAmount != nil { - structMap["total_amount"] = c.TotalAmount - } - if c.AppliedAmount != nil { - structMap["applied_amount"] = c.AppliedAmount - } - if c.RemainingAmount != nil { - structMap["remaining_amount"] = c.RemainingAmount - } - if c.LineItems != nil { - structMap["line_items"] = c.LineItems - } - if c.Discounts != nil { - structMap["discounts"] = c.Discounts - } - if c.Taxes != nil { - structMap["taxes"] = c.Taxes - } - if c.Applications != nil { - structMap["applications"] = c.Applications - } - if c.Refunds != nil { - structMap["refunds"] = c.Refunds - } - if c.OriginInvoices != nil { - structMap["origin_invoices"] = c.OriginInvoices - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for CreditNote1. -// It customizes the JSON unmarshaling process for CreditNote1 objects. -func (c *CreditNote1) UnmarshalJSON(input []byte) error { - var temp creditNote1 - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "uid", "site_id", "customer_id", "subscription_id", "number", "sequence_number", "issue_date", "applied_date", "status", "currency", "memo", "seller", "customer", "billing_address", "shipping_address", "subtotal_amount", "discount_amount", "tax_amount", "total_amount", "applied_amount", "remaining_amount", "line_items", "discounts", "taxes", "applications", "refunds", "origin_invoices") - if err != nil { - return err - } - - c.AdditionalProperties = additionalProperties - c.Uid = temp.Uid - c.SiteId = temp.SiteId - c.CustomerId = temp.CustomerId - c.SubscriptionId = temp.SubscriptionId - c.Number = temp.Number - c.SequenceNumber = temp.SequenceNumber - if temp.IssueDate != nil { - IssueDateVal, err := time.Parse(DEFAULT_DATE, *temp.IssueDate) - if err != nil { - log.Fatalf("Cannot Parse issue_date as % s format.", DEFAULT_DATE) - } - c.IssueDate = &IssueDateVal - } - if temp.AppliedDate != nil { - AppliedDateVal, err := time.Parse(DEFAULT_DATE, *temp.AppliedDate) - if err != nil { - log.Fatalf("Cannot Parse applied_date as % s format.", DEFAULT_DATE) - } - c.AppliedDate = &AppliedDateVal - } - c.Status = temp.Status - c.Currency = temp.Currency - c.Memo = temp.Memo - c.Seller = temp.Seller - c.Customer = temp.Customer - c.BillingAddress = temp.BillingAddress - c.ShippingAddress = temp.ShippingAddress - c.SubtotalAmount = temp.SubtotalAmount - c.DiscountAmount = temp.DiscountAmount - c.TaxAmount = temp.TaxAmount - c.TotalAmount = temp.TotalAmount - c.AppliedAmount = temp.AppliedAmount - c.RemainingAmount = temp.RemainingAmount - c.LineItems = temp.LineItems - c.Discounts = temp.Discounts - c.Taxes = temp.Taxes - c.Applications = temp.Applications - c.Refunds = temp.Refunds - c.OriginInvoices = temp.OriginInvoices - return nil -} - -// creditNote1 is a temporary struct used for validating the fields of CreditNote1. -type creditNote1 struct { - Uid *string `json:"uid,omitempty"` - SiteId *int `json:"site_id,omitempty"` - CustomerId *int `json:"customer_id,omitempty"` - SubscriptionId *int `json:"subscription_id,omitempty"` - Number *string `json:"number,omitempty"` - SequenceNumber *int `json:"sequence_number,omitempty"` - IssueDate *string `json:"issue_date,omitempty"` - AppliedDate *string `json:"applied_date,omitempty"` - Status *CreditNoteStatus `json:"status,omitempty"` - Currency *string `json:"currency,omitempty"` - Memo *string `json:"memo,omitempty"` - Seller *Seller `json:"seller,omitempty"` - Customer *Customer1 `json:"customer,omitempty"` - BillingAddress *BillingAddress `json:"billing_address,omitempty"` - ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` - SubtotalAmount *string `json:"subtotal_amount,omitempty"` - DiscountAmount *string `json:"discount_amount,omitempty"` - TaxAmount *string `json:"tax_amount,omitempty"` - TotalAmount *string `json:"total_amount,omitempty"` - AppliedAmount *string `json:"applied_amount,omitempty"` - RemainingAmount *string `json:"remaining_amount,omitempty"` - LineItems []CreditNoteLineItem `json:"line_items,omitempty"` - Discounts []InvoiceDiscount `json:"discounts,omitempty"` - Taxes []InvoiceTax `json:"taxes,omitempty"` - Applications []CreditNoteApplication `json:"applications,omitempty"` - Refunds []InvoiceRefund `json:"refunds,omitempty"` - OriginInvoices []OriginInvoice `json:"origin_invoices,omitempty"` -} diff --git a/models/customer_1.go b/models/customer_1.go deleted file mode 100644 index e6c8397c..00000000 --- a/models/customer_1.go +++ /dev/null @@ -1,104 +0,0 @@ -package models - -import ( - "encoding/json" -) - -// Customer1 represents a Customer1 struct. -type Customer1 struct { - ChargifyId Optional[int] `json:"chargify_id"` - FirstName *string `json:"first_name,omitempty"` - LastName *string `json:"last_name,omitempty"` - Organization Optional[string] `json:"organization"` - Email *string `json:"email,omitempty"` - VatNumber Optional[string] `json:"vat_number"` - Reference Optional[string] `json:"reference"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for Customer1. -// It customizes the JSON marshaling process for Customer1 objects. -func (c Customer1) MarshalJSON() ( - []byte, - error) { - return json.Marshal(c.toMap()) -} - -// toMap converts the Customer1 object to a map representation for JSON marshaling. -func (c Customer1) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, c.AdditionalProperties) - if c.ChargifyId.IsValueSet() { - if c.ChargifyId.Value() != nil { - structMap["chargify_id"] = c.ChargifyId.Value() - } else { - structMap["chargify_id"] = nil - } - } - if c.FirstName != nil { - structMap["first_name"] = c.FirstName - } - if c.LastName != nil { - structMap["last_name"] = c.LastName - } - if c.Organization.IsValueSet() { - if c.Organization.Value() != nil { - structMap["organization"] = c.Organization.Value() - } else { - structMap["organization"] = nil - } - } - if c.Email != nil { - structMap["email"] = c.Email - } - if c.VatNumber.IsValueSet() { - if c.VatNumber.Value() != nil { - structMap["vat_number"] = c.VatNumber.Value() - } else { - structMap["vat_number"] = nil - } - } - if c.Reference.IsValueSet() { - if c.Reference.Value() != nil { - structMap["reference"] = c.Reference.Value() - } else { - structMap["reference"] = nil - } - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for Customer1. -// It customizes the JSON unmarshaling process for Customer1 objects. -func (c *Customer1) UnmarshalJSON(input []byte) error { - var temp customer1 - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "chargify_id", "first_name", "last_name", "organization", "email", "vat_number", "reference") - if err != nil { - return err - } - - c.AdditionalProperties = additionalProperties - c.ChargifyId = temp.ChargifyId - c.FirstName = temp.FirstName - c.LastName = temp.LastName - c.Organization = temp.Organization - c.Email = temp.Email - c.VatNumber = temp.VatNumber - c.Reference = temp.Reference - return nil -} - -// customer1 is a temporary struct used for validating the fields of Customer1. -type customer1 struct { - ChargifyId Optional[int] `json:"chargify_id"` - FirstName *string `json:"first_name,omitempty"` - LastName *string `json:"last_name,omitempty"` - Organization Optional[string] `json:"organization"` - Email *string `json:"email,omitempty"` - VatNumber Optional[string] `json:"vat_number"` - Reference Optional[string] `json:"reference"` -} diff --git a/models/debit_note.go b/models/debit_note.go new file mode 100644 index 00000000..eae24c2e --- /dev/null +++ b/models/debit_note.go @@ -0,0 +1,227 @@ +package models + +import ( + "encoding/json" + "log" + "time" +) + +// DebitNote represents a DebitNote struct. +type DebitNote struct { + // Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix "db_" followed by alphanumeric characters. + Uid *string `json:"uid,omitempty"` + // ID of the site to which the debit note belongs. + SiteId *int `json:"site_id,omitempty"` + // ID of the customer to which the debit note belongs. + CustomerId *int `json:"customer_id,omitempty"` + // ID of the subscription that generated the debit note. + SubscriptionId *int `json:"subscription_id,omitempty"` + // A unique, identifier that appears on the debit note and in places it is referenced. + Number *int `json:"number,omitempty"` + // A monotonically increasing number assigned to debit notes as they are created. + SequenceNumber *int `json:"sequence_number,omitempty"` + // Unique identifier for the connected credit note. It is generated automatically by Chargify and has the prefix "cn_" followed by alphanumeric characters. + // While the UID is long and not appropriate to show to customers, the number is usually shorter and consumable by the customer and the merchant alike. + OriginCreditNoteUid *string `json:"origin_credit_note_uid,omitempty"` + // A unique, identifying string of the connected credit note. + OriginCreditNoteNumber *string `json:"origin_credit_note_number,omitempty"` + // Date the document was issued to the customer. This is the date that the document was made available for payment. + // The format is "YYYY-MM-DD". + IssueDate *time.Time `json:"issue_date,omitempty"` + // Debit notes are applied to invoices to offset invoiced amounts - they adjust the amount due. This field is the date the debit note document became fully applied to the invoice. + // The format is "YYYY-MM-DD". + AppliedDate *time.Time `json:"applied_date,omitempty"` + // Date the document is due for payment. The format is "YYYY-MM-DD". + DueDate *time.Time `json:"due_date,omitempty"` + // Current status of the debit note. + Status *DebitNoteStatus `json:"status,omitempty"` + // The memo printed on debit note, which is a description of the reason for the debit. + Memo *string `json:"memo,omitempty"` + // The role of the debit note. + Role *DebitNoteRole `json:"role,omitempty"` + // The ISO 4217 currency code (3 character string) representing the currency of the credit note amount fields. + Currency *string `json:"currency,omitempty"` + // Information about the seller (merchant) listed on the masthead of the debit note. + Seller *InvoiceSeller `json:"seller,omitempty"` + // Information about the customer who is owner or recipient the debited subscription. + Customer *InvoiceCustomer `json:"customer,omitempty"` + // The billing address of the debited subscription. + BillingAddress *InvoiceAddress `json:"billing_address,omitempty"` + // The shipping address of the debited subscription. + ShippingAddress *InvoiceAddress `json:"shipping_address,omitempty"` + // Line items on the debit note. + LineItems []CreditNoteLineItem `json:"line_items,omitempty"` + Discounts []InvoiceDiscount `json:"discounts,omitempty"` + Taxes []InvoiceTax `json:"taxes,omitempty"` + Refunds []InvoiceRefund `json:"refunds,omitempty"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for DebitNote. +// It customizes the JSON marshaling process for DebitNote objects. +func (d DebitNote) MarshalJSON() ( + []byte, + error) { + return json.Marshal(d.toMap()) +} + +// toMap converts the DebitNote object to a map representation for JSON marshaling. +func (d DebitNote) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, d.AdditionalProperties) + if d.Uid != nil { + structMap["uid"] = d.Uid + } + if d.SiteId != nil { + structMap["site_id"] = d.SiteId + } + if d.CustomerId != nil { + structMap["customer_id"] = d.CustomerId + } + if d.SubscriptionId != nil { + structMap["subscription_id"] = d.SubscriptionId + } + if d.Number != nil { + structMap["number"] = d.Number + } + if d.SequenceNumber != nil { + structMap["sequence_number"] = d.SequenceNumber + } + if d.OriginCreditNoteUid != nil { + structMap["origin_credit_note_uid"] = d.OriginCreditNoteUid + } + if d.OriginCreditNoteNumber != nil { + structMap["origin_credit_note_number"] = d.OriginCreditNoteNumber + } + if d.IssueDate != nil { + structMap["issue_date"] = d.IssueDate.Format(DEFAULT_DATE) + } + if d.AppliedDate != nil { + structMap["applied_date"] = d.AppliedDate.Format(DEFAULT_DATE) + } + if d.DueDate != nil { + structMap["due_date"] = d.DueDate.Format(DEFAULT_DATE) + } + if d.Status != nil { + structMap["status"] = d.Status + } + if d.Memo != nil { + structMap["memo"] = d.Memo + } + if d.Role != nil { + structMap["role"] = d.Role + } + if d.Currency != nil { + structMap["currency"] = d.Currency + } + if d.Seller != nil { + structMap["seller"] = d.Seller.toMap() + } + if d.Customer != nil { + structMap["customer"] = d.Customer.toMap() + } + if d.BillingAddress != nil { + structMap["billing_address"] = d.BillingAddress.toMap() + } + if d.ShippingAddress != nil { + structMap["shipping_address"] = d.ShippingAddress.toMap() + } + if d.LineItems != nil { + structMap["line_items"] = d.LineItems + } + if d.Discounts != nil { + structMap["discounts"] = d.Discounts + } + if d.Taxes != nil { + structMap["taxes"] = d.Taxes + } + if d.Refunds != nil { + structMap["refunds"] = d.Refunds + } + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for DebitNote. +// It customizes the JSON unmarshaling process for DebitNote objects. +func (d *DebitNote) UnmarshalJSON(input []byte) error { + var temp debitNote + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "uid", "site_id", "customer_id", "subscription_id", "number", "sequence_number", "origin_credit_note_uid", "origin_credit_note_number", "issue_date", "applied_date", "due_date", "status", "memo", "role", "currency", "seller", "customer", "billing_address", "shipping_address", "line_items", "discounts", "taxes", "refunds") + if err != nil { + return err + } + + d.AdditionalProperties = additionalProperties + d.Uid = temp.Uid + d.SiteId = temp.SiteId + d.CustomerId = temp.CustomerId + d.SubscriptionId = temp.SubscriptionId + d.Number = temp.Number + d.SequenceNumber = temp.SequenceNumber + d.OriginCreditNoteUid = temp.OriginCreditNoteUid + d.OriginCreditNoteNumber = temp.OriginCreditNoteNumber + if temp.IssueDate != nil { + IssueDateVal, err := time.Parse(DEFAULT_DATE, *temp.IssueDate) + if err != nil { + log.Fatalf("Cannot Parse issue_date as % s format.", DEFAULT_DATE) + } + d.IssueDate = &IssueDateVal + } + if temp.AppliedDate != nil { + AppliedDateVal, err := time.Parse(DEFAULT_DATE, *temp.AppliedDate) + if err != nil { + log.Fatalf("Cannot Parse applied_date as % s format.", DEFAULT_DATE) + } + d.AppliedDate = &AppliedDateVal + } + if temp.DueDate != nil { + DueDateVal, err := time.Parse(DEFAULT_DATE, *temp.DueDate) + if err != nil { + log.Fatalf("Cannot Parse due_date as % s format.", DEFAULT_DATE) + } + d.DueDate = &DueDateVal + } + d.Status = temp.Status + d.Memo = temp.Memo + d.Role = temp.Role + d.Currency = temp.Currency + d.Seller = temp.Seller + d.Customer = temp.Customer + d.BillingAddress = temp.BillingAddress + d.ShippingAddress = temp.ShippingAddress + d.LineItems = temp.LineItems + d.Discounts = temp.Discounts + d.Taxes = temp.Taxes + d.Refunds = temp.Refunds + return nil +} + +// debitNote is a temporary struct used for validating the fields of DebitNote. +type debitNote struct { + Uid *string `json:"uid,omitempty"` + SiteId *int `json:"site_id,omitempty"` + CustomerId *int `json:"customer_id,omitempty"` + SubscriptionId *int `json:"subscription_id,omitempty"` + Number *int `json:"number,omitempty"` + SequenceNumber *int `json:"sequence_number,omitempty"` + OriginCreditNoteUid *string `json:"origin_credit_note_uid,omitempty"` + OriginCreditNoteNumber *string `json:"origin_credit_note_number,omitempty"` + IssueDate *string `json:"issue_date,omitempty"` + AppliedDate *string `json:"applied_date,omitempty"` + DueDate *string `json:"due_date,omitempty"` + Status *DebitNoteStatus `json:"status,omitempty"` + Memo *string `json:"memo,omitempty"` + Role *DebitNoteRole `json:"role,omitempty"` + Currency *string `json:"currency,omitempty"` + Seller *InvoiceSeller `json:"seller,omitempty"` + Customer *InvoiceCustomer `json:"customer,omitempty"` + BillingAddress *InvoiceAddress `json:"billing_address,omitempty"` + ShippingAddress *InvoiceAddress `json:"shipping_address,omitempty"` + LineItems []CreditNoteLineItem `json:"line_items,omitempty"` + Discounts []InvoiceDiscount `json:"discounts,omitempty"` + Taxes []InvoiceTax `json:"taxes,omitempty"` + Refunds []InvoiceRefund `json:"refunds,omitempty"` +} diff --git a/models/enums.go b/models/enums.go index 139a583d..1d8a003c 100644 --- a/models/enums.go +++ b/models/enums.go @@ -551,6 +551,55 @@ const ( CardType_LASER CardType = "laser" ) +// ChargebackStatus is a string enum. +// The current chargeback status. +type ChargebackStatus string + +// MarshalJSON implements the json.Marshaler interface for ChargebackStatus. +// It customizes the JSON marshaling process for ChargebackStatus objects. +func (e ChargebackStatus) MarshalJSON() ( + []byte, + error) { + if e.isValid() { + return []byte(fmt.Sprintf("\"%v\"", e)), nil + } + return nil, errors.New("the provided enum value is not allowed for ChargebackStatus") +} + +// UnmarshalJSON implements the json.Unmarshaler interface for ChargebackStatus. +// It customizes the JSON unmarshaling process for ChargebackStatus objects. +func (e *ChargebackStatus) UnmarshalJSON(input []byte) error { + var enumValue string + err := json.Unmarshal(input, &enumValue) + if err != nil { + return err + } + *e = ChargebackStatus(enumValue) + if !e.isValid() { + return errors.New("the value " + string(input) + " cannot be unmarshalled to ChargebackStatus") + } + return nil +} + +// Checks whether the value is actually a member of ChargebackStatus. +func (e ChargebackStatus) isValid() bool { + switch e { + case ChargebackStatus_OPEN, + ChargebackStatus_LOST, + ChargebackStatus_WON, + ChargebackStatus_CLOSED: + return true + } + return false +} + +const ( + ChargebackStatus_OPEN ChargebackStatus = "open" + ChargebackStatus_LOST ChargebackStatus = "lost" + ChargebackStatus_WON ChargebackStatus = "won" + ChargebackStatus_CLOSED ChargebackStatus = "closed" +) + // CleanupScope is a string enum. // all: Will clear all products, customers, and related subscriptions from the site. customers: Will clear only customers and related subscriptions (leaving the products untouched) for the site. Revenue will also be reset to 0. type CleanupScope string @@ -1208,6 +1257,100 @@ const ( CustomFieldOwner_SUBSCRIPTION CustomFieldOwner = "Subscription" ) +// DebitNoteRole is a string enum. +// The role of the debit note. +type DebitNoteRole string + +// MarshalJSON implements the json.Marshaler interface for DebitNoteRole. +// It customizes the JSON marshaling process for DebitNoteRole objects. +func (e DebitNoteRole) MarshalJSON() ( + []byte, + error) { + if e.isValid() { + return []byte(fmt.Sprintf("\"%v\"", e)), nil + } + return nil, errors.New("the provided enum value is not allowed for DebitNoteRole") +} + +// UnmarshalJSON implements the json.Unmarshaler interface for DebitNoteRole. +// It customizes the JSON unmarshaling process for DebitNoteRole objects. +func (e *DebitNoteRole) UnmarshalJSON(input []byte) error { + var enumValue string + err := json.Unmarshal(input, &enumValue) + if err != nil { + return err + } + *e = DebitNoteRole(enumValue) + if !e.isValid() { + return errors.New("the value " + string(input) + " cannot be unmarshalled to DebitNoteRole") + } + return nil +} + +// Checks whether the value is actually a member of DebitNoteRole. +func (e DebitNoteRole) isValid() bool { + switch e { + case DebitNoteRole_CHARGEBACK, + DebitNoteRole_REFUND: + return true + } + return false +} + +const ( + DebitNoteRole_CHARGEBACK DebitNoteRole = "chargeback" + DebitNoteRole_REFUND DebitNoteRole = "refund" +) + +// DebitNoteStatus is a string enum. +// Current status of the debit note. +type DebitNoteStatus string + +// MarshalJSON implements the json.Marshaler interface for DebitNoteStatus. +// It customizes the JSON marshaling process for DebitNoteStatus objects. +func (e DebitNoteStatus) MarshalJSON() ( + []byte, + error) { + if e.isValid() { + return []byte(fmt.Sprintf("\"%v\"", e)), nil + } + return nil, errors.New("the provided enum value is not allowed for DebitNoteStatus") +} + +// UnmarshalJSON implements the json.Unmarshaler interface for DebitNoteStatus. +// It customizes the JSON unmarshaling process for DebitNoteStatus objects. +func (e *DebitNoteStatus) UnmarshalJSON(input []byte) error { + var enumValue string + err := json.Unmarshal(input, &enumValue) + if err != nil { + return err + } + *e = DebitNoteStatus(enumValue) + if !e.isValid() { + return errors.New("the value " + string(input) + " cannot be unmarshalled to DebitNoteStatus") + } + return nil +} + +// Checks whether the value is actually a member of DebitNoteStatus. +func (e DebitNoteStatus) isValid() bool { + switch e { + case DebitNoteStatus_OPEN, + DebitNoteStatus_APPLIED, + DebitNoteStatus_BANISHED, + DebitNoteStatus_PAID: + return true + } + return false +} + +const ( + DebitNoteStatus_OPEN DebitNoteStatus = "open" + DebitNoteStatus_APPLIED DebitNoteStatus = "applied" + DebitNoteStatus_BANISHED DebitNoteStatus = "banished" + DebitNoteStatus_PAID DebitNoteStatus = "paid" +) + // Direction is a string enum. type Direction string @@ -2099,6 +2242,7 @@ func (e InvoiceEventType) isValid() bool { InvoiceEventType_CREATECREDITNOTE, InvoiceEventType_APPLYPAYMENT, InvoiceEventType_APPLYDEBITNOTE, + InvoiceEventType_CREATEDEBITNOTE, InvoiceEventType_REFUNDINVOICE, InvoiceEventType_VOIDINVOICE, InvoiceEventType_VOIDREMAINDER, @@ -2119,6 +2263,7 @@ const ( InvoiceEventType_CREATECREDITNOTE InvoiceEventType = "create_credit_note" InvoiceEventType_APPLYPAYMENT InvoiceEventType = "apply_payment" InvoiceEventType_APPLYDEBITNOTE InvoiceEventType = "apply_debit_note" + InvoiceEventType_CREATEDEBITNOTE InvoiceEventType = "create_debit_note" InvoiceEventType_REFUNDINVOICE InvoiceEventType = "refund_invoice" InvoiceEventType_VOIDINVOICE InvoiceEventType = "void_invoice" InvoiceEventType_VOIDREMAINDER InvoiceEventType = "void_remainder" @@ -2349,7 +2494,7 @@ const ( ) // InvoiceStatus is a string enum. -// The current status of the invoice. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. +// The current status of the invoice. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. type InvoiceStatus string // MarshalJSON implements the json.Marshaler interface for InvoiceStatus. diff --git a/models/failed_payment_event.go b/models/failed_payment_event.go new file mode 100644 index 00000000..2cc71442 --- /dev/null +++ b/models/failed_payment_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// FailedPaymentEvent represents a FailedPaymentEvent struct. +type FailedPaymentEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `failed_payment` event + EventData FailedPaymentEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for FailedPaymentEvent. +// It customizes the JSON marshaling process for FailedPaymentEvent objects. +func (f FailedPaymentEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(f.toMap()) +} + +// toMap converts the FailedPaymentEvent object to a map representation for JSON marshaling. +func (f FailedPaymentEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, f.AdditionalProperties) + structMap["id"] = f.Id + structMap["timestamp"] = f.Timestamp.Format(time.RFC3339) + structMap["invoice"] = f.Invoice.toMap() + structMap["event_type"] = f.EventType + structMap["event_data"] = f.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for FailedPaymentEvent. +// It customizes the JSON unmarshaling process for FailedPaymentEvent objects. +func (f *FailedPaymentEvent) UnmarshalJSON(input []byte) error { + var temp failedPaymentEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + f.AdditionalProperties = additionalProperties + f.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + f.Timestamp = TimestampVal + f.Invoice = *temp.Invoice + f.EventType = *temp.EventType + f.EventData = *temp.EventData + return nil +} + +// failedPaymentEvent is a temporary struct used for validating the fields of FailedPaymentEvent. +type failedPaymentEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *FailedPaymentEventData `json:"event_data"` +} + +func (f *failedPaymentEvent) validate() error { + var errs []string + if f.Id == nil { + errs = append(errs, "required field `id` is missing for type `Failed Payment Event`") + } + if f.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Failed Payment Event`") + } + if f.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Failed Payment Event`") + } + if f.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Failed Payment Event`") + } + if f.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Failed Payment Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/failed_payment_event_data.go b/models/failed_payment_event_data.go new file mode 100644 index 00000000..a6821276 --- /dev/null +++ b/models/failed_payment_event_data.go @@ -0,0 +1,103 @@ +package models + +import ( + "encoding/json" + "errors" + "strings" +) + +// FailedPaymentEventData represents a FailedPaymentEventData struct. +// Example schema for an `failed_payment` event +type FailedPaymentEventData struct { + // The monetary value of the payment, expressed in cents. + AmountInCents int `json:"amount_in_cents"` + // The monetary value of the payment, expressed in dollars. + AppliedAmount int `json:"applied_amount"` + // The memo passed when the payment was created. + Memo Optional[string] `json:"memo"` + PaymentMethod InvoicePaymentMethodType `json:"payment_method"` + // The transaction ID of the failed payment. + TransactionId int `json:"transaction_id"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for FailedPaymentEventData. +// It customizes the JSON marshaling process for FailedPaymentEventData objects. +func (f FailedPaymentEventData) MarshalJSON() ( + []byte, + error) { + return json.Marshal(f.toMap()) +} + +// toMap converts the FailedPaymentEventData object to a map representation for JSON marshaling. +func (f FailedPaymentEventData) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, f.AdditionalProperties) + structMap["amount_in_cents"] = f.AmountInCents + structMap["applied_amount"] = f.AppliedAmount + if f.Memo.IsValueSet() { + if f.Memo.Value() != nil { + structMap["memo"] = f.Memo.Value() + } else { + structMap["memo"] = nil + } + } + structMap["payment_method"] = f.PaymentMethod + structMap["transaction_id"] = f.TransactionId + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for FailedPaymentEventData. +// It customizes the JSON unmarshaling process for FailedPaymentEventData objects. +func (f *FailedPaymentEventData) UnmarshalJSON(input []byte) error { + var temp failedPaymentEventData + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "amount_in_cents", "applied_amount", "memo", "payment_method", "transaction_id") + if err != nil { + return err + } + + f.AdditionalProperties = additionalProperties + f.AmountInCents = *temp.AmountInCents + f.AppliedAmount = *temp.AppliedAmount + f.Memo = temp.Memo + f.PaymentMethod = *temp.PaymentMethod + f.TransactionId = *temp.TransactionId + return nil +} + +// failedPaymentEventData is a temporary struct used for validating the fields of FailedPaymentEventData. +type failedPaymentEventData struct { + AmountInCents *int `json:"amount_in_cents"` + AppliedAmount *int `json:"applied_amount"` + Memo Optional[string] `json:"memo"` + PaymentMethod *InvoicePaymentMethodType `json:"payment_method"` + TransactionId *int `json:"transaction_id"` +} + +func (f *failedPaymentEventData) validate() error { + var errs []string + if f.AmountInCents == nil { + errs = append(errs, "required field `amount_in_cents` is missing for type `Failed Payment Event Data`") + } + if f.AppliedAmount == nil { + errs = append(errs, "required field `applied_amount` is missing for type `Failed Payment Event Data`") + } + if f.PaymentMethod == nil { + errs = append(errs, "required field `payment_method` is missing for type `Failed Payment Event Data`") + } + if f.TransactionId == nil { + errs = append(errs, "required field `transaction_id` is missing for type `Failed Payment Event Data`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/historic_usage.go b/models/historic_usage.go index 596386a4..9c7921a3 100644 --- a/models/historic_usage.go +++ b/models/historic_usage.go @@ -7,7 +7,7 @@ import ( ) // HistoricUsage represents a HistoricUsage struct. -// An optional object for Event Based Components, will be returned if provided `include=historic_usages` query param. +// Optional for Event Based Components. If the `include=historic_usages` query param is provided, the last ten billing periods will be returned. type HistoricUsage struct { // Total usage of a component for billing period TotalUsageQuantity *float64 `json:"total_usage_quantity,omitempty"` diff --git a/models/invoice.go b/models/invoice.go index 62360303..3cd68497 100644 --- a/models/invoice.go +++ b/models/invoice.go @@ -35,7 +35,7 @@ type Invoice struct { // If partial payments are applied to the invoice, this date will not be present until payment has been made in full. // The format is `"YYYY-MM-DD"`. PaidDate Optional[time.Time] `json:"paid_date"` - // The current status of the invoice. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. + // The current status of the invoice. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. Status *InvoiceStatus `json:"status,omitempty"` Role *InvoiceRole `json:"role,omitempty"` ParentInvoiceId Optional[int] `json:"parent_invoice_id"` diff --git a/models/invoice_event.go b/models/invoice_event.go index afab2688..9ffa0116 100644 --- a/models/invoice_event.go +++ b/models/invoice_event.go @@ -1,21 +1,42 @@ +/* +Package advancedbilling + +This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). +*/ package models import ( "encoding/json" - "log" - "time" + "errors" + "strings" ) // InvoiceEvent represents a InvoiceEvent struct. type InvoiceEvent struct { - Id *int `json:"id,omitempty"` - // Invoice Event Type - EventType *InvoiceEventType `json:"event_type,omitempty"` - // The event data is the data that, when combined with the command, results in the output invoice found in the invoice field. - EventData *InvoiceEventEventData `json:"event_data,omitempty"` - Timestamp *time.Time `json:"timestamp,omitempty"` - Invoice *Invoice `json:"invoice,omitempty"` - AdditionalProperties map[string]any `json:"_"` + value any + isApplyCreditNoteEvent bool + isApplyDebitNoteEvent bool + isApplyPaymentEvent bool + isBackportInvoiceEvent bool + isChangeChargebackStatusEvent bool + isChangeInvoiceCollectionMethodEvent bool + isChangeInvoiceStatusEvent bool + isCreateCreditNoteEvent bool + isCreateDebitNoteEvent bool + isFailedPaymentEvent bool + isIssueInvoiceEvent bool + isRefundInvoiceEvent bool + isRemovePaymentEvent bool + isVoidInvoiceEvent bool + isVoidRemainderEvent bool +} + +// String converts the InvoiceEvent object to a string representation. +func (i InvoiceEvent) String() string { + if bytes, err := json.Marshal(i.value); err == nil { + return strings.Trim(string(bytes), "\"") + } + return "" } // MarshalJSON implements the json.Marshaler interface for InvoiceEvent. @@ -23,64 +44,285 @@ type InvoiceEvent struct { func (i InvoiceEvent) MarshalJSON() ( []byte, error) { + if i.value == nil { + return nil, errors.New("No underlying type is set. Please use any of the `models.InvoiceEventContainer.From*` functions to initialize the InvoiceEvent object.") + } return json.Marshal(i.toMap()) } // toMap converts the InvoiceEvent object to a map representation for JSON marshaling. -func (i InvoiceEvent) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, i.AdditionalProperties) - if i.Id != nil { - structMap["id"] = i.Id +func (i *InvoiceEvent) toMap() any { + switch obj := i.value.(type) { + case *ApplyCreditNoteEvent: + return obj.toMap() + case *ApplyDebitNoteEvent: + return obj.toMap() + case *ApplyPaymentEvent: + return obj.toMap() + case *BackportInvoiceEvent: + return obj.toMap() + case *ChangeChargebackStatusEvent: + return obj.toMap() + case *ChangeInvoiceCollectionMethodEvent: + return obj.toMap() + case *ChangeInvoiceStatusEvent: + return obj.toMap() + case *CreateCreditNoteEvent: + return obj.toMap() + case *CreateDebitNoteEvent: + return obj.toMap() + case *FailedPaymentEvent: + return obj.toMap() + case *IssueInvoiceEvent: + return obj.toMap() + case *RefundInvoiceEvent: + return obj.toMap() + case *RemovePaymentEvent: + return obj.toMap() + case *VoidInvoiceEvent: + return obj.toMap() + case *VoidRemainderEvent: + return obj.toMap() } - if i.EventType != nil { - structMap["event_type"] = i.EventType + return nil +} + +// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEvent. +// It customizes the JSON unmarshaling process for InvoiceEvent objects. +func (i *InvoiceEvent) UnmarshalJSON(input []byte) error { + result, err := UnmarshallAnyOfWithDiscriminator(input, "event_type", + NewTypeHolderDiscriminator(&ApplyCreditNoteEvent{}, false, &i.isApplyCreditNoteEvent, "apply_credit_note"), + NewTypeHolderDiscriminator(&ApplyDebitNoteEvent{}, false, &i.isApplyDebitNoteEvent, "apply_debit_note"), + NewTypeHolderDiscriminator(&ApplyPaymentEvent{}, false, &i.isApplyPaymentEvent, "apply_payment"), + NewTypeHolderDiscriminator(&BackportInvoiceEvent{}, false, &i.isBackportInvoiceEvent, "backport_invoice"), + NewTypeHolderDiscriminator(&ChangeChargebackStatusEvent{}, false, &i.isChangeChargebackStatusEvent, "change_chargeback_status"), + NewTypeHolderDiscriminator(&ChangeInvoiceCollectionMethodEvent{}, false, &i.isChangeInvoiceCollectionMethodEvent, "change_invoice_collection_method"), + NewTypeHolderDiscriminator(&ChangeInvoiceStatusEvent{}, false, &i.isChangeInvoiceStatusEvent, "change_invoice_status"), + NewTypeHolderDiscriminator(&CreateCreditNoteEvent{}, false, &i.isCreateCreditNoteEvent, "create_credit_note"), + NewTypeHolderDiscriminator(&CreateDebitNoteEvent{}, false, &i.isCreateDebitNoteEvent, "create_debit_note"), + NewTypeHolderDiscriminator(&FailedPaymentEvent{}, false, &i.isFailedPaymentEvent, "failed_payment"), + NewTypeHolderDiscriminator(&IssueInvoiceEvent{}, false, &i.isIssueInvoiceEvent, "issue_invoice"), + NewTypeHolderDiscriminator(&RefundInvoiceEvent{}, false, &i.isRefundInvoiceEvent, "refund_invoice"), + NewTypeHolderDiscriminator(&RemovePaymentEvent{}, false, &i.isRemovePaymentEvent, "remove_payment"), + NewTypeHolderDiscriminator(&VoidInvoiceEvent{}, false, &i.isVoidInvoiceEvent, "void_invoice"), + NewTypeHolderDiscriminator(&VoidRemainderEvent{}, false, &i.isVoidRemainderEvent, "void_remainder"), + ) + + i.value = result + return err +} + +func (i *InvoiceEvent) AsApplyCreditNoteEvent() ( + *ApplyCreditNoteEvent, + bool) { + if !i.isApplyCreditNoteEvent { + return nil, false } - if i.EventData != nil { - structMap["event_data"] = i.EventData.toMap() + return i.value.(*ApplyCreditNoteEvent), true +} + +func (i *InvoiceEvent) AsApplyDebitNoteEvent() ( + *ApplyDebitNoteEvent, + bool) { + if !i.isApplyDebitNoteEvent { + return nil, false } - if i.Timestamp != nil { - structMap["timestamp"] = i.Timestamp.Format(time.RFC3339) + return i.value.(*ApplyDebitNoteEvent), true +} + +func (i *InvoiceEvent) AsApplyPaymentEvent() ( + *ApplyPaymentEvent, + bool) { + if !i.isApplyPaymentEvent { + return nil, false } - if i.Invoice != nil { - structMap["invoice"] = i.Invoice.toMap() + return i.value.(*ApplyPaymentEvent), true +} + +func (i *InvoiceEvent) AsBackportInvoiceEvent() ( + *BackportInvoiceEvent, + bool) { + if !i.isBackportInvoiceEvent { + return nil, false } - return structMap + return i.value.(*BackportInvoiceEvent), true } -// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEvent. -// It customizes the JSON unmarshaling process for InvoiceEvent objects. -func (i *InvoiceEvent) UnmarshalJSON(input []byte) error { - var temp invoiceEvent - err := json.Unmarshal(input, &temp) - if err != nil { - return err +func (i *InvoiceEvent) AsChangeChargebackStatusEvent() ( + *ChangeChargebackStatusEvent, + bool) { + if !i.isChangeChargebackStatusEvent { + return nil, false } - additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "event_type", "event_data", "timestamp", "invoice") - if err != nil { - return err + return i.value.(*ChangeChargebackStatusEvent), true +} + +func (i *InvoiceEvent) AsChangeInvoiceCollectionMethodEvent() ( + *ChangeInvoiceCollectionMethodEvent, + bool) { + if !i.isChangeInvoiceCollectionMethodEvent { + return nil, false } - - i.AdditionalProperties = additionalProperties - i.Id = temp.Id - i.EventType = temp.EventType - i.EventData = temp.EventData - if temp.Timestamp != nil { - TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) - if err != nil { - log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) - } - i.Timestamp = &TimestampVal - } - i.Invoice = temp.Invoice - return nil + return i.value.(*ChangeInvoiceCollectionMethodEvent), true +} + +func (i *InvoiceEvent) AsChangeInvoiceStatusEvent() ( + *ChangeInvoiceStatusEvent, + bool) { + if !i.isChangeInvoiceStatusEvent { + return nil, false + } + return i.value.(*ChangeInvoiceStatusEvent), true +} + +func (i *InvoiceEvent) AsCreateCreditNoteEvent() ( + *CreateCreditNoteEvent, + bool) { + if !i.isCreateCreditNoteEvent { + return nil, false + } + return i.value.(*CreateCreditNoteEvent), true +} + +func (i *InvoiceEvent) AsCreateDebitNoteEvent() ( + *CreateDebitNoteEvent, + bool) { + if !i.isCreateDebitNoteEvent { + return nil, false + } + return i.value.(*CreateDebitNoteEvent), true +} + +func (i *InvoiceEvent) AsFailedPaymentEvent() ( + *FailedPaymentEvent, + bool) { + if !i.isFailedPaymentEvent { + return nil, false + } + return i.value.(*FailedPaymentEvent), true +} + +func (i *InvoiceEvent) AsIssueInvoiceEvent() ( + *IssueInvoiceEvent, + bool) { + if !i.isIssueInvoiceEvent { + return nil, false + } + return i.value.(*IssueInvoiceEvent), true +} + +func (i *InvoiceEvent) AsRefundInvoiceEvent() ( + *RefundInvoiceEvent, + bool) { + if !i.isRefundInvoiceEvent { + return nil, false + } + return i.value.(*RefundInvoiceEvent), true +} + +func (i *InvoiceEvent) AsRemovePaymentEvent() ( + *RemovePaymentEvent, + bool) { + if !i.isRemovePaymentEvent { + return nil, false + } + return i.value.(*RemovePaymentEvent), true +} + +func (i *InvoiceEvent) AsVoidInvoiceEvent() ( + *VoidInvoiceEvent, + bool) { + if !i.isVoidInvoiceEvent { + return nil, false + } + return i.value.(*VoidInvoiceEvent), true +} + +func (i *InvoiceEvent) AsVoidRemainderEvent() ( + *VoidRemainderEvent, + bool) { + if !i.isVoidRemainderEvent { + return nil, false + } + return i.value.(*VoidRemainderEvent), true +} + +// internalInvoiceEvent represents a invoiceEvent struct. +type internalInvoiceEvent struct {} + +var InvoiceEventContainer internalInvoiceEvent + +// The internalInvoiceEvent instance, wrapping the provided ApplyCreditNoteEvent value. +func (i *internalInvoiceEvent) FromApplyCreditNoteEvent(val ApplyCreditNoteEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided ApplyDebitNoteEvent value. +func (i *internalInvoiceEvent) FromApplyDebitNoteEvent(val ApplyDebitNoteEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided ApplyPaymentEvent value. +func (i *internalInvoiceEvent) FromApplyPaymentEvent(val ApplyPaymentEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided BackportInvoiceEvent value. +func (i *internalInvoiceEvent) FromBackportInvoiceEvent(val BackportInvoiceEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided ChangeChargebackStatusEvent value. +func (i *internalInvoiceEvent) FromChangeChargebackStatusEvent(val ChangeChargebackStatusEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided ChangeInvoiceCollectionMethodEvent value. +func (i *internalInvoiceEvent) FromChangeInvoiceCollectionMethodEvent(val ChangeInvoiceCollectionMethodEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided ChangeInvoiceStatusEvent value. +func (i *internalInvoiceEvent) FromChangeInvoiceStatusEvent(val ChangeInvoiceStatusEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided CreateCreditNoteEvent value. +func (i *internalInvoiceEvent) FromCreateCreditNoteEvent(val CreateCreditNoteEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided CreateDebitNoteEvent value. +func (i *internalInvoiceEvent) FromCreateDebitNoteEvent(val CreateDebitNoteEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided FailedPaymentEvent value. +func (i *internalInvoiceEvent) FromFailedPaymentEvent(val FailedPaymentEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided IssueInvoiceEvent value. +func (i *internalInvoiceEvent) FromIssueInvoiceEvent(val IssueInvoiceEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided RefundInvoiceEvent value. +func (i *internalInvoiceEvent) FromRefundInvoiceEvent(val RefundInvoiceEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided RemovePaymentEvent value. +func (i *internalInvoiceEvent) FromRemovePaymentEvent(val RemovePaymentEvent) InvoiceEvent { + return InvoiceEvent{value: &val} +} + +// The internalInvoiceEvent instance, wrapping the provided VoidInvoiceEvent value. +func (i *internalInvoiceEvent) FromVoidInvoiceEvent(val VoidInvoiceEvent) InvoiceEvent { + return InvoiceEvent{value: &val} } -// invoiceEvent is a temporary struct used for validating the fields of InvoiceEvent. -type invoiceEvent struct { - Id *int `json:"id,omitempty"` - EventType *InvoiceEventType `json:"event_type,omitempty"` - EventData *InvoiceEventEventData `json:"event_data,omitempty"` - Timestamp *string `json:"timestamp,omitempty"` - Invoice *Invoice `json:"invoice,omitempty"` +// The internalInvoiceEvent instance, wrapping the provided VoidRemainderEvent value. +func (i *internalInvoiceEvent) FromVoidRemainderEvent(val VoidRemainderEvent) InvoiceEvent { + return InvoiceEvent{value: &val} } diff --git a/models/invoice_event_data.go b/models/invoice_event_data.go deleted file mode 100644 index 68493c06..00000000 --- a/models/invoice_event_data.go +++ /dev/null @@ -1,288 +0,0 @@ -package models - -import ( - "encoding/json" - "log" - "time" -) - -// InvoiceEventData represents a InvoiceEventData struct. -// The event data is the data that, when combined with the command, results in the output invoice found in the invoice field. -type InvoiceEventData struct { - // Unique identifier for the credit note application. It is generated automatically by Chargify and has the prefix "cdt_" followed by alphanumeric characters. - Uid *string `json:"uid,omitempty"` - // A unique, identifying string that appears on the credit note and in places it is referenced. - CreditNoteNumber *string `json:"credit_note_number,omitempty"` - // Unique identifier for the credit note. It is generated automatically by Chargify and has the prefix "cn_" followed by alphanumeric characters. - CreditNoteUid *string `json:"credit_note_uid,omitempty"` - // The full, original amount of the credit note. - OriginalAmount *string `json:"original_amount,omitempty"` - // The amount of the credit note applied to invoice. - AppliedAmount *string `json:"applied_amount,omitempty"` - // The time the credit note was applied, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" - TransactionTime *time.Time `json:"transaction_time,omitempty"` - // The credit note memo. - Memo *string `json:"memo,omitempty"` - // The role of the credit note (e.g. 'general') - Role *string `json:"role,omitempty"` - // Shows whether it was applied to consolidated invoice or not - ConsolidatedInvoice *bool `json:"consolidated_invoice,omitempty"` - // List of credit notes applied to children invoices (if consolidated invoice) - AppliedCreditNotes []AppliedCreditNoteData `json:"applied_credit_notes,omitempty"` - // A unique, identifying string that appears on the debit note and in places it is referenced. - DebitNoteNumber *string `json:"debit_note_number,omitempty"` - // Unique identifier for the debit note. It is generated automatically by Chargify and has the prefix "db_" followed by alphanumeric characters. - DebitNoteUid *string `json:"debit_note_uid,omitempty"` - // A nested data structure detailing the method of payment - PaymentMethod *InvoiceEventDataPaymentMethod `json:"payment_method,omitempty"` - // The Chargify id of the original payment - TransactionId *int `json:"transaction_id,omitempty"` - ParentInvoiceNumber Optional[int] `json:"parent_invoice_number"` - RemainingPrepaymentAmount Optional[string] `json:"remaining_prepayment_amount"` - // The flag that shows whether the original payment was a prepayment or not - Prepayment *bool `json:"prepayment,omitempty"` - External *bool `json:"external,omitempty"` - // The previous collection method of the invoice. - FromCollectionMethod *string `json:"from_collection_method,omitempty"` - // The new collection method of the invoice. - ToCollectionMethod *string `json:"to_collection_method,omitempty"` - // Consolidation level of the invoice, which is applicable to invoice consolidation. It will hold one of the following values: - // * "none": A normal invoice with no consolidation. - // * "child": An invoice segment which has been combined into a consolidated invoice. - // * "parent": A consolidated invoice, whose contents are composed of invoice segments. - // "Parent" invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments. - // See also the [invoice consolidation documentation](https://chargify.zendesk.com/hc/en-us/articles/4407746391835). - ConsolidationLevel *InvoiceConsolidationLevel `json:"consolidation_level,omitempty"` - // The status of the invoice before event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. - FromStatus *InvoiceStatus `json:"from_status,omitempty"` - // The status of the invoice after event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. - ToStatus *InvoiceStatus `json:"to_status,omitempty"` - // Amount due on the invoice, which is `total_amount - credit_amount - paid_amount`. - DueAmount *string `json:"due_amount,omitempty"` - // The invoice total, which is `subtotal_amount - discount_amount + tax_amount`.' - TotalAmount *string `json:"total_amount,omitempty"` - // If true, credit was created and applied it to the invoice. - ApplyCredit *bool `json:"apply_credit,omitempty"` - CreditNoteAttributes *CreditNote1 `json:"credit_note_attributes,omitempty"` - // The ID of the payment transaction to be refunded. - PaymentId *int `json:"payment_id,omitempty"` - // The amount of the refund. - RefundAmount *string `json:"refund_amount,omitempty"` - // The ID of the refund transaction. - RefundId *int `json:"refund_id,omitempty"` - // If true, the invoice is an advance invoice. - IsAdvanceInvoice *bool `json:"is_advance_invoice,omitempty"` - // The reason for the void. - Reason *string `json:"reason,omitempty"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for InvoiceEventData. -// It customizes the JSON marshaling process for InvoiceEventData objects. -func (i InvoiceEventData) MarshalJSON() ( - []byte, - error) { - return json.Marshal(i.toMap()) -} - -// toMap converts the InvoiceEventData object to a map representation for JSON marshaling. -func (i InvoiceEventData) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, i.AdditionalProperties) - if i.Uid != nil { - structMap["uid"] = i.Uid - } - if i.CreditNoteNumber != nil { - structMap["credit_note_number"] = i.CreditNoteNumber - } - if i.CreditNoteUid != nil { - structMap["credit_note_uid"] = i.CreditNoteUid - } - if i.OriginalAmount != nil { - structMap["original_amount"] = i.OriginalAmount - } - if i.AppliedAmount != nil { - structMap["applied_amount"] = i.AppliedAmount - } - if i.TransactionTime != nil { - structMap["transaction_time"] = i.TransactionTime.Format(time.RFC3339) - } - if i.Memo != nil { - structMap["memo"] = i.Memo - } - if i.Role != nil { - structMap["role"] = i.Role - } - if i.ConsolidatedInvoice != nil { - structMap["consolidated_invoice"] = i.ConsolidatedInvoice - } - if i.AppliedCreditNotes != nil { - structMap["applied_credit_notes"] = i.AppliedCreditNotes - } - if i.DebitNoteNumber != nil { - structMap["debit_note_number"] = i.DebitNoteNumber - } - if i.DebitNoteUid != nil { - structMap["debit_note_uid"] = i.DebitNoteUid - } - if i.PaymentMethod != nil { - structMap["payment_method"] = i.PaymentMethod.toMap() - } - if i.TransactionId != nil { - structMap["transaction_id"] = i.TransactionId - } - if i.ParentInvoiceNumber.IsValueSet() { - if i.ParentInvoiceNumber.Value() != nil { - structMap["parent_invoice_number"] = i.ParentInvoiceNumber.Value() - } else { - structMap["parent_invoice_number"] = nil - } - } - if i.RemainingPrepaymentAmount.IsValueSet() { - if i.RemainingPrepaymentAmount.Value() != nil { - structMap["remaining_prepayment_amount"] = i.RemainingPrepaymentAmount.Value() - } else { - structMap["remaining_prepayment_amount"] = nil - } - } - if i.Prepayment != nil { - structMap["prepayment"] = i.Prepayment - } - if i.External != nil { - structMap["external"] = i.External - } - if i.FromCollectionMethod != nil { - structMap["from_collection_method"] = i.FromCollectionMethod - } - if i.ToCollectionMethod != nil { - structMap["to_collection_method"] = i.ToCollectionMethod - } - if i.ConsolidationLevel != nil { - structMap["consolidation_level"] = i.ConsolidationLevel - } - if i.FromStatus != nil { - structMap["from_status"] = i.FromStatus - } - if i.ToStatus != nil { - structMap["to_status"] = i.ToStatus - } - if i.DueAmount != nil { - structMap["due_amount"] = i.DueAmount - } - if i.TotalAmount != nil { - structMap["total_amount"] = i.TotalAmount - } - if i.ApplyCredit != nil { - structMap["apply_credit"] = i.ApplyCredit - } - if i.CreditNoteAttributes != nil { - structMap["credit_note_attributes"] = i.CreditNoteAttributes.toMap() - } - if i.PaymentId != nil { - structMap["payment_id"] = i.PaymentId - } - if i.RefundAmount != nil { - structMap["refund_amount"] = i.RefundAmount - } - if i.RefundId != nil { - structMap["refund_id"] = i.RefundId - } - if i.IsAdvanceInvoice != nil { - structMap["is_advance_invoice"] = i.IsAdvanceInvoice - } - if i.Reason != nil { - structMap["reason"] = i.Reason - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEventData. -// It customizes the JSON unmarshaling process for InvoiceEventData objects. -func (i *InvoiceEventData) UnmarshalJSON(input []byte) error { - var temp invoiceEventData - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "uid", "credit_note_number", "credit_note_uid", "original_amount", "applied_amount", "transaction_time", "memo", "role", "consolidated_invoice", "applied_credit_notes", "debit_note_number", "debit_note_uid", "payment_method", "transaction_id", "parent_invoice_number", "remaining_prepayment_amount", "prepayment", "external", "from_collection_method", "to_collection_method", "consolidation_level", "from_status", "to_status", "due_amount", "total_amount", "apply_credit", "credit_note_attributes", "payment_id", "refund_amount", "refund_id", "is_advance_invoice", "reason") - if err != nil { - return err - } - - i.AdditionalProperties = additionalProperties - i.Uid = temp.Uid - i.CreditNoteNumber = temp.CreditNoteNumber - i.CreditNoteUid = temp.CreditNoteUid - i.OriginalAmount = temp.OriginalAmount - i.AppliedAmount = temp.AppliedAmount - if temp.TransactionTime != nil { - TransactionTimeVal, err := time.Parse(time.RFC3339, *temp.TransactionTime) - if err != nil { - log.Fatalf("Cannot Parse transaction_time as % s format.", time.RFC3339) - } - i.TransactionTime = &TransactionTimeVal - } - i.Memo = temp.Memo - i.Role = temp.Role - i.ConsolidatedInvoice = temp.ConsolidatedInvoice - i.AppliedCreditNotes = temp.AppliedCreditNotes - i.DebitNoteNumber = temp.DebitNoteNumber - i.DebitNoteUid = temp.DebitNoteUid - i.PaymentMethod = temp.PaymentMethod - i.TransactionId = temp.TransactionId - i.ParentInvoiceNumber = temp.ParentInvoiceNumber - i.RemainingPrepaymentAmount = temp.RemainingPrepaymentAmount - i.Prepayment = temp.Prepayment - i.External = temp.External - i.FromCollectionMethod = temp.FromCollectionMethod - i.ToCollectionMethod = temp.ToCollectionMethod - i.ConsolidationLevel = temp.ConsolidationLevel - i.FromStatus = temp.FromStatus - i.ToStatus = temp.ToStatus - i.DueAmount = temp.DueAmount - i.TotalAmount = temp.TotalAmount - i.ApplyCredit = temp.ApplyCredit - i.CreditNoteAttributes = temp.CreditNoteAttributes - i.PaymentId = temp.PaymentId - i.RefundAmount = temp.RefundAmount - i.RefundId = temp.RefundId - i.IsAdvanceInvoice = temp.IsAdvanceInvoice - i.Reason = temp.Reason - return nil -} - -// invoiceEventData is a temporary struct used for validating the fields of InvoiceEventData. -type invoiceEventData struct { - Uid *string `json:"uid,omitempty"` - CreditNoteNumber *string `json:"credit_note_number,omitempty"` - CreditNoteUid *string `json:"credit_note_uid,omitempty"` - OriginalAmount *string `json:"original_amount,omitempty"` - AppliedAmount *string `json:"applied_amount,omitempty"` - TransactionTime *string `json:"transaction_time,omitempty"` - Memo *string `json:"memo,omitempty"` - Role *string `json:"role,omitempty"` - ConsolidatedInvoice *bool `json:"consolidated_invoice,omitempty"` - AppliedCreditNotes []AppliedCreditNoteData `json:"applied_credit_notes,omitempty"` - DebitNoteNumber *string `json:"debit_note_number,omitempty"` - DebitNoteUid *string `json:"debit_note_uid,omitempty"` - PaymentMethod *InvoiceEventDataPaymentMethod `json:"payment_method,omitempty"` - TransactionId *int `json:"transaction_id,omitempty"` - ParentInvoiceNumber Optional[int] `json:"parent_invoice_number"` - RemainingPrepaymentAmount Optional[string] `json:"remaining_prepayment_amount"` - Prepayment *bool `json:"prepayment,omitempty"` - External *bool `json:"external,omitempty"` - FromCollectionMethod *string `json:"from_collection_method,omitempty"` - ToCollectionMethod *string `json:"to_collection_method,omitempty"` - ConsolidationLevel *InvoiceConsolidationLevel `json:"consolidation_level,omitempty"` - FromStatus *InvoiceStatus `json:"from_status,omitempty"` - ToStatus *InvoiceStatus `json:"to_status,omitempty"` - DueAmount *string `json:"due_amount,omitempty"` - TotalAmount *string `json:"total_amount,omitempty"` - ApplyCredit *bool `json:"apply_credit,omitempty"` - CreditNoteAttributes *CreditNote1 `json:"credit_note_attributes,omitempty"` - PaymentId *int `json:"payment_id,omitempty"` - RefundAmount *string `json:"refund_amount,omitempty"` - RefundId *int `json:"refund_id,omitempty"` - IsAdvanceInvoice *bool `json:"is_advance_invoice,omitempty"` - Reason *string `json:"reason,omitempty"` -} diff --git a/models/invoice_event_data_payment_method.go b/models/invoice_event_data_payment_method.go deleted file mode 100644 index ae8fb1c3..00000000 --- a/models/invoice_event_data_payment_method.go +++ /dev/null @@ -1,150 +0,0 @@ -/* -Package advancedbilling - -This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). -*/ -package models - -import ( - "encoding/json" - "errors" - "strings" -) - -// InvoiceEventDataPaymentMethod represents a InvoiceEventDataPaymentMethod struct. -// This is a container for any-of cases. -type InvoiceEventDataPaymentMethod struct { - value any - isPaymentMethodApplePay bool - isPaymentMethodBankAccount bool - isPaymentMethodCreditCard bool - isPaymentMethodExternal bool - isPaymentMethodPaypal bool -} - -// String converts the InvoiceEventDataPaymentMethod object to a string representation. -func (i InvoiceEventDataPaymentMethod) String() string { - if bytes, err := json.Marshal(i.value); err == nil { - return strings.Trim(string(bytes), "\"") - } - return "" -} - -// MarshalJSON implements the json.Marshaler interface for InvoiceEventDataPaymentMethod. -// It customizes the JSON marshaling process for InvoiceEventDataPaymentMethod objects. -func (i InvoiceEventDataPaymentMethod) MarshalJSON() ( - []byte, - error) { - if i.value == nil { - return nil, errors.New("No underlying type is set. Please use any of the `models.InvoiceEventDataPaymentMethodContainer.From*` functions to initialize the InvoiceEventDataPaymentMethod object.") - } - return json.Marshal(i.toMap()) -} - -// toMap converts the InvoiceEventDataPaymentMethod object to a map representation for JSON marshaling. -func (i *InvoiceEventDataPaymentMethod) toMap() any { - switch obj := i.value.(type) { - case *PaymentMethodApplePay: - return obj.toMap() - case *PaymentMethodBankAccount: - return obj.toMap() - case *PaymentMethodCreditCard: - return obj.toMap() - case *PaymentMethodExternal: - return obj.toMap() - case *PaymentMethodPaypal: - return obj.toMap() - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEventDataPaymentMethod. -// It customizes the JSON unmarshaling process for InvoiceEventDataPaymentMethod objects. -func (i *InvoiceEventDataPaymentMethod) UnmarshalJSON(input []byte) error { - result, err := UnmarshallAnyOf(input, - NewTypeHolder(&PaymentMethodApplePay{}, false, &i.isPaymentMethodApplePay), - NewTypeHolder(&PaymentMethodBankAccount{}, false, &i.isPaymentMethodBankAccount), - NewTypeHolder(&PaymentMethodCreditCard{}, false, &i.isPaymentMethodCreditCard), - NewTypeHolder(&PaymentMethodExternal{}, false, &i.isPaymentMethodExternal), - NewTypeHolder(&PaymentMethodPaypal{}, false, &i.isPaymentMethodPaypal), - ) - - i.value = result - return err -} - -func (i *InvoiceEventDataPaymentMethod) AsPaymentMethodApplePay() ( - *PaymentMethodApplePay, - bool) { - if !i.isPaymentMethodApplePay { - return nil, false - } - return i.value.(*PaymentMethodApplePay), true -} - -func (i *InvoiceEventDataPaymentMethod) AsPaymentMethodBankAccount() ( - *PaymentMethodBankAccount, - bool) { - if !i.isPaymentMethodBankAccount { - return nil, false - } - return i.value.(*PaymentMethodBankAccount), true -} - -func (i *InvoiceEventDataPaymentMethod) AsPaymentMethodCreditCard() ( - *PaymentMethodCreditCard, - bool) { - if !i.isPaymentMethodCreditCard { - return nil, false - } - return i.value.(*PaymentMethodCreditCard), true -} - -func (i *InvoiceEventDataPaymentMethod) AsPaymentMethodExternal() ( - *PaymentMethodExternal, - bool) { - if !i.isPaymentMethodExternal { - return nil, false - } - return i.value.(*PaymentMethodExternal), true -} - -func (i *InvoiceEventDataPaymentMethod) AsPaymentMethodPaypal() ( - *PaymentMethodPaypal, - bool) { - if !i.isPaymentMethodPaypal { - return nil, false - } - return i.value.(*PaymentMethodPaypal), true -} - -// internalInvoiceEventDataPaymentMethod represents a invoiceEventDataPaymentMethod struct. -// This is a container for any-of cases. -type internalInvoiceEventDataPaymentMethod struct {} - -var InvoiceEventDataPaymentMethodContainer internalInvoiceEventDataPaymentMethod - -// The internalInvoiceEventDataPaymentMethod instance, wrapping the provided PaymentMethodApplePay value. -func (i *internalInvoiceEventDataPaymentMethod) FromPaymentMethodApplePay(val PaymentMethodApplePay) InvoiceEventDataPaymentMethod { - return InvoiceEventDataPaymentMethod{value: &val} -} - -// The internalInvoiceEventDataPaymentMethod instance, wrapping the provided PaymentMethodBankAccount value. -func (i *internalInvoiceEventDataPaymentMethod) FromPaymentMethodBankAccount(val PaymentMethodBankAccount) InvoiceEventDataPaymentMethod { - return InvoiceEventDataPaymentMethod{value: &val} -} - -// The internalInvoiceEventDataPaymentMethod instance, wrapping the provided PaymentMethodCreditCard value. -func (i *internalInvoiceEventDataPaymentMethod) FromPaymentMethodCreditCard(val PaymentMethodCreditCard) InvoiceEventDataPaymentMethod { - return InvoiceEventDataPaymentMethod{value: &val} -} - -// The internalInvoiceEventDataPaymentMethod instance, wrapping the provided PaymentMethodExternal value. -func (i *internalInvoiceEventDataPaymentMethod) FromPaymentMethodExternal(val PaymentMethodExternal) InvoiceEventDataPaymentMethod { - return InvoiceEventDataPaymentMethod{value: &val} -} - -// The internalInvoiceEventDataPaymentMethod instance, wrapping the provided PaymentMethodPaypal value. -func (i *internalInvoiceEventDataPaymentMethod) FromPaymentMethodPaypal(val PaymentMethodPaypal) InvoiceEventDataPaymentMethod { - return InvoiceEventDataPaymentMethod{value: &val} -} diff --git a/models/invoice_event_event_data.go b/models/invoice_event_event_data.go deleted file mode 100644 index 7003b55b..00000000 --- a/models/invoice_event_event_data.go +++ /dev/null @@ -1,222 +0,0 @@ -/* -Package advancedbilling - -This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). -*/ -package models - -import ( - "encoding/json" - "errors" - "strings" -) - -// InvoiceEventEventData represents a InvoiceEventEventData struct. -// This is a container for any-of cases. -type InvoiceEventEventData struct { - value any - isApplyCreditNoteEventData bool - isApplyDebitNoteEventData bool - isApplyPaymentEventData bool - isChangeInvoiceCollectionMethodEventData bool - isIssueInvoiceEventData bool - isRefundInvoiceEventData bool - isRemovePaymentEventData bool - isVoidInvoiceEventData bool - isVoidRemainderEventData bool -} - -// String converts the InvoiceEventEventData object to a string representation. -func (i InvoiceEventEventData) String() string { - if bytes, err := json.Marshal(i.value); err == nil { - return strings.Trim(string(bytes), "\"") - } - return "" -} - -// MarshalJSON implements the json.Marshaler interface for InvoiceEventEventData. -// It customizes the JSON marshaling process for InvoiceEventEventData objects. -func (i InvoiceEventEventData) MarshalJSON() ( - []byte, - error) { - if i.value == nil { - return nil, errors.New("No underlying type is set. Please use any of the `models.InvoiceEventEventDataContainer.From*` functions to initialize the InvoiceEventEventData object.") - } - return json.Marshal(i.toMap()) -} - -// toMap converts the InvoiceEventEventData object to a map representation for JSON marshaling. -func (i *InvoiceEventEventData) toMap() any { - switch obj := i.value.(type) { - case *ApplyCreditNoteEventData: - return obj.toMap() - case *ApplyDebitNoteEventData: - return obj.toMap() - case *ApplyPaymentEventData: - return obj.toMap() - case *ChangeInvoiceCollectionMethodEventData: - return obj.toMap() - case *IssueInvoiceEventData: - return obj.toMap() - case *RefundInvoiceEventData: - return obj.toMap() - case *RemovePaymentEventData: - return obj.toMap() - case *VoidInvoiceEventData: - return obj.toMap() - case *VoidRemainderEventData: - return obj.toMap() - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEventEventData. -// It customizes the JSON unmarshaling process for InvoiceEventEventData objects. -func (i *InvoiceEventEventData) UnmarshalJSON(input []byte) error { - result, err := UnmarshallAnyOf(input, - NewTypeHolder(&ApplyCreditNoteEventData{}, false, &i.isApplyCreditNoteEventData), - NewTypeHolder(&ApplyDebitNoteEventData{}, false, &i.isApplyDebitNoteEventData), - NewTypeHolder(&ApplyPaymentEventData{}, false, &i.isApplyPaymentEventData), - NewTypeHolder(&ChangeInvoiceCollectionMethodEventData{}, false, &i.isChangeInvoiceCollectionMethodEventData), - NewTypeHolder(&IssueInvoiceEventData{}, false, &i.isIssueInvoiceEventData), - NewTypeHolder(&RefundInvoiceEventData{}, false, &i.isRefundInvoiceEventData), - NewTypeHolder(&RemovePaymentEventData{}, false, &i.isRemovePaymentEventData), - NewTypeHolder(&VoidInvoiceEventData{}, false, &i.isVoidInvoiceEventData), - NewTypeHolder(&VoidRemainderEventData{}, false, &i.isVoidRemainderEventData), - ) - - i.value = result - return err -} - -func (i *InvoiceEventEventData) AsApplyCreditNoteEventData() ( - *ApplyCreditNoteEventData, - bool) { - if !i.isApplyCreditNoteEventData { - return nil, false - } - return i.value.(*ApplyCreditNoteEventData), true -} - -func (i *InvoiceEventEventData) AsApplyDebitNoteEventData() ( - *ApplyDebitNoteEventData, - bool) { - if !i.isApplyDebitNoteEventData { - return nil, false - } - return i.value.(*ApplyDebitNoteEventData), true -} - -func (i *InvoiceEventEventData) AsApplyPaymentEventData() ( - *ApplyPaymentEventData, - bool) { - if !i.isApplyPaymentEventData { - return nil, false - } - return i.value.(*ApplyPaymentEventData), true -} - -func (i *InvoiceEventEventData) AsChangeInvoiceCollectionMethodEventData() ( - *ChangeInvoiceCollectionMethodEventData, - bool) { - if !i.isChangeInvoiceCollectionMethodEventData { - return nil, false - } - return i.value.(*ChangeInvoiceCollectionMethodEventData), true -} - -func (i *InvoiceEventEventData) AsIssueInvoiceEventData() ( - *IssueInvoiceEventData, - bool) { - if !i.isIssueInvoiceEventData { - return nil, false - } - return i.value.(*IssueInvoiceEventData), true -} - -func (i *InvoiceEventEventData) AsRefundInvoiceEventData() ( - *RefundInvoiceEventData, - bool) { - if !i.isRefundInvoiceEventData { - return nil, false - } - return i.value.(*RefundInvoiceEventData), true -} - -func (i *InvoiceEventEventData) AsRemovePaymentEventData() ( - *RemovePaymentEventData, - bool) { - if !i.isRemovePaymentEventData { - return nil, false - } - return i.value.(*RemovePaymentEventData), true -} - -func (i *InvoiceEventEventData) AsVoidInvoiceEventData() ( - *VoidInvoiceEventData, - bool) { - if !i.isVoidInvoiceEventData { - return nil, false - } - return i.value.(*VoidInvoiceEventData), true -} - -func (i *InvoiceEventEventData) AsVoidRemainderEventData() ( - *VoidRemainderEventData, - bool) { - if !i.isVoidRemainderEventData { - return nil, false - } - return i.value.(*VoidRemainderEventData), true -} - -// internalInvoiceEventEventData represents a invoiceEventEventData struct. -// This is a container for any-of cases. -type internalInvoiceEventEventData struct {} - -var InvoiceEventEventDataContainer internalInvoiceEventEventData - -// The internalInvoiceEventEventData instance, wrapping the provided ApplyCreditNoteEventData value. -func (i *internalInvoiceEventEventData) FromApplyCreditNoteEventData(val ApplyCreditNoteEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided ApplyDebitNoteEventData value. -func (i *internalInvoiceEventEventData) FromApplyDebitNoteEventData(val ApplyDebitNoteEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided ApplyPaymentEventData value. -func (i *internalInvoiceEventEventData) FromApplyPaymentEventData(val ApplyPaymentEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided ChangeInvoiceCollectionMethodEventData value. -func (i *internalInvoiceEventEventData) FromChangeInvoiceCollectionMethodEventData(val ChangeInvoiceCollectionMethodEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided IssueInvoiceEventData value. -func (i *internalInvoiceEventEventData) FromIssueInvoiceEventData(val IssueInvoiceEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided RefundInvoiceEventData value. -func (i *internalInvoiceEventEventData) FromRefundInvoiceEventData(val RefundInvoiceEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided RemovePaymentEventData value. -func (i *internalInvoiceEventEventData) FromRemovePaymentEventData(val RemovePaymentEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided VoidInvoiceEventData value. -func (i *internalInvoiceEventEventData) FromVoidInvoiceEventData(val VoidInvoiceEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} - -// The internalInvoiceEventEventData instance, wrapping the provided VoidRemainderEventData value. -func (i *internalInvoiceEventEventData) FromVoidRemainderEventData(val VoidRemainderEventData) InvoiceEventEventData { - return InvoiceEventEventData{value: &val} -} diff --git a/models/invoice_event_payment.go b/models/invoice_event_payment.go index 41b1972f..1ab2d6f0 100644 --- a/models/invoice_event_payment.go +++ b/models/invoice_event_payment.go @@ -7,23 +7,27 @@ package models import ( "encoding/json" + "errors" + "strings" ) // InvoiceEventPayment represents a InvoiceEventPayment struct. // A nested data structure detailing the method of payment type InvoiceEventPayment struct { - Type *string `json:"type,omitempty"` - MaskedAccountNumber *string `json:"masked_account_number,omitempty"` - MaskedRoutingNumber *string `json:"masked_routing_number,omitempty"` - CardBrand *string `json:"card_brand,omitempty"` - CardExpiration *string `json:"card_expiration,omitempty"` - LastFour Optional[string] `json:"last_four"` - MaskedCardNumber *string `json:"masked_card_number,omitempty"` - Details Optional[string] `json:"details"` - Kind *string `json:"kind,omitempty"` - Memo Optional[string] `json:"memo"` - Email *string `json:"email,omitempty"` - AdditionalProperties map[string]any `json:"_"` + value any + isPaymentMethodApplePay bool + isPaymentMethodBankAccount bool + isPaymentMethodCreditCard bool + isPaymentMethodExternal bool + isPaymentMethodPaypal bool +} + +// String converts the InvoiceEventPayment object to a string representation. +func (i InvoiceEventPayment) String() string { + if bytes, err := json.Marshal(i.value); err == nil { + return strings.Trim(string(bytes), "\"") + } + return "" } // MarshalJSON implements the json.Marshaler interface for InvoiceEventPayment. @@ -31,102 +35,116 @@ type InvoiceEventPayment struct { func (i InvoiceEventPayment) MarshalJSON() ( []byte, error) { + if i.value == nil { + return nil, errors.New("No underlying type is set. Please use any of the `models.InvoiceEventPaymentContainer.From*` functions to initialize the InvoiceEventPayment object.") + } return json.Marshal(i.toMap()) } // toMap converts the InvoiceEventPayment object to a map representation for JSON marshaling. -func (i InvoiceEventPayment) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, i.AdditionalProperties) - if i.Type != nil { - structMap["type"] = *i.Type - } else { - structMap["type"] = "Invoice Event Payment" - } - if i.MaskedAccountNumber != nil { - structMap["masked_account_number"] = i.MaskedAccountNumber - } - if i.MaskedRoutingNumber != nil { - structMap["masked_routing_number"] = i.MaskedRoutingNumber - } - if i.CardBrand != nil { - structMap["card_brand"] = i.CardBrand - } - if i.CardExpiration != nil { - structMap["card_expiration"] = i.CardExpiration - } - if i.LastFour.IsValueSet() { - if i.LastFour.Value() != nil { - structMap["last_four"] = i.LastFour.Value() - } else { - structMap["last_four"] = nil - } - } - if i.MaskedCardNumber != nil { - structMap["masked_card_number"] = i.MaskedCardNumber - } - if i.Details.IsValueSet() { - if i.Details.Value() != nil { - structMap["details"] = i.Details.Value() - } else { - structMap["details"] = nil - } +func (i *InvoiceEventPayment) toMap() any { + switch obj := i.value.(type) { + case *PaymentMethodApplePay: + return obj.toMap() + case *PaymentMethodBankAccount: + return obj.toMap() + case *PaymentMethodCreditCard: + return obj.toMap() + case *PaymentMethodExternal: + return obj.toMap() + case *PaymentMethodPaypal: + return obj.toMap() } - if i.Kind != nil { - structMap["kind"] = i.Kind - } - if i.Memo.IsValueSet() { - if i.Memo.Value() != nil { - structMap["memo"] = i.Memo.Value() - } else { - structMap["memo"] = nil - } - } - if i.Email != nil { - structMap["email"] = i.Email - } - return structMap + return nil } // UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEventPayment. // It customizes the JSON unmarshaling process for InvoiceEventPayment objects. func (i *InvoiceEventPayment) UnmarshalJSON(input []byte) error { - var temp invoiceEventPayment - err := json.Unmarshal(input, &temp) - if err != nil { - return err + result, err := UnmarshallAnyOfWithDiscriminator(input, "type", + NewTypeHolderDiscriminator(&PaymentMethodApplePay{}, false, &i.isPaymentMethodApplePay, "apple_pay"), + NewTypeHolderDiscriminator(&PaymentMethodBankAccount{}, false, &i.isPaymentMethodBankAccount, "bank_account"), + NewTypeHolderDiscriminator(&PaymentMethodCreditCard{}, false, &i.isPaymentMethodCreditCard, "credit_card"), + NewTypeHolderDiscriminator(&PaymentMethodExternal{}, false, &i.isPaymentMethodExternal, "external"), + NewTypeHolderDiscriminator(&PaymentMethodPaypal{}, false, &i.isPaymentMethodPaypal, "paypal_account"), + ) + + i.value = result + return err +} + +func (i *InvoiceEventPayment) AsPaymentMethodApplePay() ( + *PaymentMethodApplePay, + bool) { + if !i.isPaymentMethodApplePay { + return nil, false } - additionalProperties, err := UnmarshalAdditionalProperties(input, "type", "masked_account_number", "masked_routing_number", "card_brand", "card_expiration", "last_four", "masked_card_number", "details", "kind", "memo", "email") - if err != nil { - return err + return i.value.(*PaymentMethodApplePay), true +} + +func (i *InvoiceEventPayment) AsPaymentMethodBankAccount() ( + *PaymentMethodBankAccount, + bool) { + if !i.isPaymentMethodBankAccount { + return nil, false } - - i.AdditionalProperties = additionalProperties - i.Type = temp.Type - i.MaskedAccountNumber = temp.MaskedAccountNumber - i.MaskedRoutingNumber = temp.MaskedRoutingNumber - i.CardBrand = temp.CardBrand - i.CardExpiration = temp.CardExpiration - i.LastFour = temp.LastFour - i.MaskedCardNumber = temp.MaskedCardNumber - i.Details = temp.Details - i.Kind = temp.Kind - i.Memo = temp.Memo - i.Email = temp.Email - return nil + return i.value.(*PaymentMethodBankAccount), true +} + +func (i *InvoiceEventPayment) AsPaymentMethodCreditCard() ( + *PaymentMethodCreditCard, + bool) { + if !i.isPaymentMethodCreditCard { + return nil, false + } + return i.value.(*PaymentMethodCreditCard), true +} + +func (i *InvoiceEventPayment) AsPaymentMethodExternal() ( + *PaymentMethodExternal, + bool) { + if !i.isPaymentMethodExternal { + return nil, false + } + return i.value.(*PaymentMethodExternal), true +} + +func (i *InvoiceEventPayment) AsPaymentMethodPaypal() ( + *PaymentMethodPaypal, + bool) { + if !i.isPaymentMethodPaypal { + return nil, false + } + return i.value.(*PaymentMethodPaypal), true +} + +// internalInvoiceEventPayment represents a invoiceEventPayment struct. +// A nested data structure detailing the method of payment +type internalInvoiceEventPayment struct {} + +var InvoiceEventPaymentContainer internalInvoiceEventPayment + +// The internalInvoiceEventPayment instance, wrapping the provided PaymentMethodApplePay value. +func (i *internalInvoiceEventPayment) FromPaymentMethodApplePay(val PaymentMethodApplePay) InvoiceEventPayment { + return InvoiceEventPayment{value: &val} +} + +// The internalInvoiceEventPayment instance, wrapping the provided PaymentMethodBankAccount value. +func (i *internalInvoiceEventPayment) FromPaymentMethodBankAccount(val PaymentMethodBankAccount) InvoiceEventPayment { + return InvoiceEventPayment{value: &val} +} + +// The internalInvoiceEventPayment instance, wrapping the provided PaymentMethodCreditCard value. +func (i *internalInvoiceEventPayment) FromPaymentMethodCreditCard(val PaymentMethodCreditCard) InvoiceEventPayment { + return InvoiceEventPayment{value: &val} +} + +// The internalInvoiceEventPayment instance, wrapping the provided PaymentMethodExternal value. +func (i *internalInvoiceEventPayment) FromPaymentMethodExternal(val PaymentMethodExternal) InvoiceEventPayment { + return InvoiceEventPayment{value: &val} } -// invoiceEventPayment is a temporary struct used for validating the fields of InvoiceEventPayment. -type invoiceEventPayment struct { - Type *string `json:"type,omitempty"` - MaskedAccountNumber *string `json:"masked_account_number,omitempty"` - MaskedRoutingNumber *string `json:"masked_routing_number,omitempty"` - CardBrand *string `json:"card_brand,omitempty"` - CardExpiration *string `json:"card_expiration,omitempty"` - LastFour Optional[string] `json:"last_four"` - MaskedCardNumber *string `json:"masked_card_number,omitempty"` - Details Optional[string] `json:"details"` - Kind *string `json:"kind,omitempty"` - Memo Optional[string] `json:"memo"` - Email *string `json:"email,omitempty"` +// The internalInvoiceEventPayment instance, wrapping the provided PaymentMethodPaypal value. +func (i *internalInvoiceEventPayment) FromPaymentMethodPaypal(val PaymentMethodPaypal) InvoiceEventPayment { + return InvoiceEventPayment{value: &val} } diff --git a/models/invoice_event_payment_1.go b/models/invoice_event_payment_1.go deleted file mode 100644 index b3836a20..00000000 --- a/models/invoice_event_payment_1.go +++ /dev/null @@ -1,143 +0,0 @@ -package models - -import ( - "encoding/json" - "errors" - "strings" -) - -// InvoiceEventPayment1 represents a InvoiceEventPayment1 struct. -// A nested data structure detailing the method of payment -type InvoiceEventPayment1 struct { - Type *string `json:"type,omitempty"` - MaskedAccountNumber string `json:"masked_account_number"` - MaskedRoutingNumber string `json:"masked_routing_number"` - CardBrand string `json:"card_brand"` - CardExpiration *string `json:"card_expiration,omitempty"` - LastFour Optional[string] `json:"last_four"` - MaskedCardNumber string `json:"masked_card_number"` - Details *string `json:"details"` - Kind string `json:"kind"` - Memo *string `json:"memo"` - Email string `json:"email"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for InvoiceEventPayment1. -// It customizes the JSON marshaling process for InvoiceEventPayment1 objects. -func (i InvoiceEventPayment1) MarshalJSON() ( - []byte, - error) { - return json.Marshal(i.toMap()) -} - -// toMap converts the InvoiceEventPayment1 object to a map representation for JSON marshaling. -func (i InvoiceEventPayment1) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, i.AdditionalProperties) - if i.Type != nil { - structMap["type"] = *i.Type - } else { - structMap["type"] = "Invoice Event Payment1" - } - structMap["masked_account_number"] = i.MaskedAccountNumber - structMap["masked_routing_number"] = i.MaskedRoutingNumber - structMap["card_brand"] = i.CardBrand - if i.CardExpiration != nil { - structMap["card_expiration"] = i.CardExpiration - } - if i.LastFour.IsValueSet() { - if i.LastFour.Value() != nil { - structMap["last_four"] = i.LastFour.Value() - } else { - structMap["last_four"] = nil - } - } - structMap["masked_card_number"] = i.MaskedCardNumber - if i.Details != nil { - structMap["details"] = i.Details - } else { - structMap["details"] = nil - } - structMap["kind"] = i.Kind - if i.Memo != nil { - structMap["memo"] = i.Memo - } else { - structMap["memo"] = nil - } - structMap["email"] = i.Email - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEventPayment1. -// It customizes the JSON unmarshaling process for InvoiceEventPayment1 objects. -func (i *InvoiceEventPayment1) UnmarshalJSON(input []byte) error { - var temp invoiceEventPayment1 - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - err = temp.validate() - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "type", "masked_account_number", "masked_routing_number", "card_brand", "card_expiration", "last_four", "masked_card_number", "details", "kind", "memo", "email") - if err != nil { - return err - } - - i.AdditionalProperties = additionalProperties - i.Type = temp.Type - i.MaskedAccountNumber = *temp.MaskedAccountNumber - i.MaskedRoutingNumber = *temp.MaskedRoutingNumber - i.CardBrand = *temp.CardBrand - i.CardExpiration = temp.CardExpiration - i.LastFour = temp.LastFour - i.MaskedCardNumber = *temp.MaskedCardNumber - i.Details = temp.Details - i.Kind = *temp.Kind - i.Memo = temp.Memo - i.Email = *temp.Email - return nil -} - -// invoiceEventPayment1 is a temporary struct used for validating the fields of InvoiceEventPayment1. -type invoiceEventPayment1 struct { - Type *string `json:"type,omitempty"` - MaskedAccountNumber *string `json:"masked_account_number"` - MaskedRoutingNumber *string `json:"masked_routing_number"` - CardBrand *string `json:"card_brand"` - CardExpiration *string `json:"card_expiration,omitempty"` - LastFour Optional[string] `json:"last_four"` - MaskedCardNumber *string `json:"masked_card_number"` - Details *string `json:"details"` - Kind *string `json:"kind"` - Memo *string `json:"memo"` - Email *string `json:"email"` -} - -func (i *invoiceEventPayment1) validate() error { - var errs []string - if i.MaskedAccountNumber == nil { - errs = append(errs, "required field `masked_account_number` is missing for type `Invoice Event Payment1`") - } - if i.MaskedRoutingNumber == nil { - errs = append(errs, "required field `masked_routing_number` is missing for type `Invoice Event Payment1`") - } - if i.CardBrand == nil { - errs = append(errs, "required field `card_brand` is missing for type `Invoice Event Payment1`") - } - if i.MaskedCardNumber == nil { - errs = append(errs, "required field `masked_card_number` is missing for type `Invoice Event Payment1`") - } - if i.Kind == nil { - errs = append(errs, "required field `kind` is missing for type `Invoice Event Payment1`") - } - if i.Email == nil { - errs = append(errs, "required field `email` is missing for type `Invoice Event Payment1`") - } - if len(errs) == 0 { - return nil - } - return errors.New(strings.Join(errs, "\n")) -} diff --git a/models/invoice_event_payment_2.go b/models/invoice_event_payment_2.go deleted file mode 100644 index bd275b20..00000000 --- a/models/invoice_event_payment_2.go +++ /dev/null @@ -1,150 +0,0 @@ -/* -Package advancedbilling - -This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). -*/ -package models - -import ( - "encoding/json" - "errors" - "strings" -) - -// InvoiceEventPayment2 represents a InvoiceEventPayment2 struct. -// A nested data structure detailing the method of payment -type InvoiceEventPayment2 struct { - value any - isPaymentMethodApplePay bool - isPaymentMethodBankAccount bool - isPaymentMethodCreditCard bool - isPaymentMethodExternal bool - isPaymentMethodPaypal bool -} - -// String converts the InvoiceEventPayment2 object to a string representation. -func (i InvoiceEventPayment2) String() string { - if bytes, err := json.Marshal(i.value); err == nil { - return strings.Trim(string(bytes), "\"") - } - return "" -} - -// MarshalJSON implements the json.Marshaler interface for InvoiceEventPayment2. -// It customizes the JSON marshaling process for InvoiceEventPayment2 objects. -func (i InvoiceEventPayment2) MarshalJSON() ( - []byte, - error) { - if i.value == nil { - return nil, errors.New("No underlying type is set. Please use any of the `models.InvoiceEventPaymentContainer.From*` functions to initialize the InvoiceEventPayment2 object.") - } - return json.Marshal(i.toMap()) -} - -// toMap converts the InvoiceEventPayment2 object to a map representation for JSON marshaling. -func (i *InvoiceEventPayment2) toMap() any { - switch obj := i.value.(type) { - case *PaymentMethodApplePay: - return obj.toMap() - case *PaymentMethodBankAccount: - return obj.toMap() - case *PaymentMethodCreditCard: - return obj.toMap() - case *PaymentMethodExternal: - return obj.toMap() - case *PaymentMethodPaypal: - return obj.toMap() - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface for InvoiceEventPayment2. -// It customizes the JSON unmarshaling process for InvoiceEventPayment2 objects. -func (i *InvoiceEventPayment2) UnmarshalJSON(input []byte) error { - result, err := UnmarshallAnyOfWithDiscriminator(input, "type", - NewTypeHolderDiscriminator(&PaymentMethodApplePay{}, false, &i.isPaymentMethodApplePay, "apple_pay"), - NewTypeHolderDiscriminator(&PaymentMethodBankAccount{}, false, &i.isPaymentMethodBankAccount, "bank_account"), - NewTypeHolderDiscriminator(&PaymentMethodCreditCard{}, false, &i.isPaymentMethodCreditCard, "credit_card"), - NewTypeHolderDiscriminator(&PaymentMethodExternal{}, false, &i.isPaymentMethodExternal, "external"), - NewTypeHolderDiscriminator(&PaymentMethodPaypal{}, false, &i.isPaymentMethodPaypal, "paypal_account"), - ) - - i.value = result - return err -} - -func (i *InvoiceEventPayment2) AsPaymentMethodApplePay() ( - *PaymentMethodApplePay, - bool) { - if !i.isPaymentMethodApplePay { - return nil, false - } - return i.value.(*PaymentMethodApplePay), true -} - -func (i *InvoiceEventPayment2) AsPaymentMethodBankAccount() ( - *PaymentMethodBankAccount, - bool) { - if !i.isPaymentMethodBankAccount { - return nil, false - } - return i.value.(*PaymentMethodBankAccount), true -} - -func (i *InvoiceEventPayment2) AsPaymentMethodCreditCard() ( - *PaymentMethodCreditCard, - bool) { - if !i.isPaymentMethodCreditCard { - return nil, false - } - return i.value.(*PaymentMethodCreditCard), true -} - -func (i *InvoiceEventPayment2) AsPaymentMethodExternal() ( - *PaymentMethodExternal, - bool) { - if !i.isPaymentMethodExternal { - return nil, false - } - return i.value.(*PaymentMethodExternal), true -} - -func (i *InvoiceEventPayment2) AsPaymentMethodPaypal() ( - *PaymentMethodPaypal, - bool) { - if !i.isPaymentMethodPaypal { - return nil, false - } - return i.value.(*PaymentMethodPaypal), true -} - -// internalInvoiceEventPayment2 represents a invoiceEventPayment2 struct. -// A nested data structure detailing the method of payment -type internalInvoiceEventPayment2 struct {} - -var InvoiceEventPaymentContainer internalInvoiceEventPayment2 - -// The internalInvoiceEventPayment2 instance, wrapping the provided PaymentMethodApplePay value. -func (i *internalInvoiceEventPayment2) FromPaymentMethodApplePay(val PaymentMethodApplePay) InvoiceEventPayment2 { - return InvoiceEventPayment2{value: &val} -} - -// The internalInvoiceEventPayment2 instance, wrapping the provided PaymentMethodBankAccount value. -func (i *internalInvoiceEventPayment2) FromPaymentMethodBankAccount(val PaymentMethodBankAccount) InvoiceEventPayment2 { - return InvoiceEventPayment2{value: &val} -} - -// The internalInvoiceEventPayment2 instance, wrapping the provided PaymentMethodCreditCard value. -func (i *internalInvoiceEventPayment2) FromPaymentMethodCreditCard(val PaymentMethodCreditCard) InvoiceEventPayment2 { - return InvoiceEventPayment2{value: &val} -} - -// The internalInvoiceEventPayment2 instance, wrapping the provided PaymentMethodExternal value. -func (i *internalInvoiceEventPayment2) FromPaymentMethodExternal(val PaymentMethodExternal) InvoiceEventPayment2 { - return InvoiceEventPayment2{value: &val} -} - -// The internalInvoiceEventPayment2 instance, wrapping the provided PaymentMethodPaypal value. -func (i *internalInvoiceEventPayment2) FromPaymentMethodPaypal(val PaymentMethodPaypal) InvoiceEventPayment2 { - return InvoiceEventPayment2{value: &val} -} diff --git a/models/issue_invoice_event.go b/models/issue_invoice_event.go new file mode 100644 index 00000000..8c1a7f15 --- /dev/null +++ b/models/issue_invoice_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// IssueInvoiceEvent represents a IssueInvoiceEvent struct. +type IssueInvoiceEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `issue_invoice` event + EventData IssueInvoiceEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for IssueInvoiceEvent. +// It customizes the JSON marshaling process for IssueInvoiceEvent objects. +func (i IssueInvoiceEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(i.toMap()) +} + +// toMap converts the IssueInvoiceEvent object to a map representation for JSON marshaling. +func (i IssueInvoiceEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, i.AdditionalProperties) + structMap["id"] = i.Id + structMap["timestamp"] = i.Timestamp.Format(time.RFC3339) + structMap["invoice"] = i.Invoice.toMap() + structMap["event_type"] = i.EventType + structMap["event_data"] = i.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for IssueInvoiceEvent. +// It customizes the JSON unmarshaling process for IssueInvoiceEvent objects. +func (i *IssueInvoiceEvent) UnmarshalJSON(input []byte) error { + var temp issueInvoiceEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + i.AdditionalProperties = additionalProperties + i.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + i.Timestamp = TimestampVal + i.Invoice = *temp.Invoice + i.EventType = *temp.EventType + i.EventData = *temp.EventData + return nil +} + +// issueInvoiceEvent is a temporary struct used for validating the fields of IssueInvoiceEvent. +type issueInvoiceEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *IssueInvoiceEventData `json:"event_data"` +} + +func (i *issueInvoiceEvent) validate() error { + var errs []string + if i.Id == nil { + errs = append(errs, "required field `id` is missing for type `Issue Invoice Event`") + } + if i.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Issue Invoice Event`") + } + if i.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Issue Invoice Event`") + } + if i.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Issue Invoice Event`") + } + if i.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Issue Invoice Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/issue_invoice_event_data.go b/models/issue_invoice_event_data.go index 2a8e11a8..117cc6ca 100644 --- a/models/issue_invoice_event_data.go +++ b/models/issue_invoice_event_data.go @@ -16,9 +16,9 @@ type IssueInvoiceEventData struct { // "Parent" invoices do not have lines of their own, but they have subtotals and totals which aggregate the member invoice segments. // See also the [invoice consolidation documentation](https://chargify.zendesk.com/hc/en-us/articles/4407746391835). ConsolidationLevel InvoiceConsolidationLevel `json:"consolidation_level"` - // The status of the invoice before event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. + // The status of the invoice before event occurrence. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statusess) for more. FromStatus InvoiceStatus `json:"from_status"` - // The status of the invoice after event occurence. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. + // The status of the invoice after event occurrence. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statusess) for more. ToStatus InvoiceStatus `json:"to_status"` // Amount due on the invoice, which is `total_amount - credit_amount - paid_amount`. DueAmount string `json:"due_amount"` diff --git a/models/paid_invoice.go b/models/paid_invoice.go index 88c8604f..0d2b4226 100644 --- a/models/paid_invoice.go +++ b/models/paid_invoice.go @@ -8,7 +8,7 @@ import ( type PaidInvoice struct { // The uid of the paid invoice InvoiceId *string `json:"invoice_id,omitempty"` - // The current status of the invoice. See [Invoice Statuses](https://chargify.zendesk.com/hc/en-us/articles/4407737494171#line-item-breakdowns) for more. + // The current status of the invoice. See [Invoice Statuses](https://maxio-chargify.zendesk.com/hc/en-us/articles/5405078794253-Introduction-to-Invoices#invoice-statuses) for more. Status *InvoiceStatus `json:"status,omitempty"` // The remaining due amount on the invoice DueAmount *string `json:"due_amount,omitempty"` diff --git a/models/payment_method_apple_pay.go b/models/payment_method_apple_pay.go index 7a982ab1..f450b0d7 100644 --- a/models/payment_method_apple_pay.go +++ b/models/payment_method_apple_pay.go @@ -1,3 +1,8 @@ +/* +Package advancedbilling + +This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). +*/ package models import ( diff --git a/models/price_point.go b/models/price_point.go deleted file mode 100644 index f8bdab62..00000000 --- a/models/price_point.go +++ /dev/null @@ -1,132 +0,0 @@ -package models - -import ( - "encoding/json" -) - -// PricePoint represents a PricePoint struct. -type PricePoint struct { - Name *string `json:"name,omitempty"` - Handle *string `json:"handle,omitempty"` - // The identifier for the pricing scheme. See [Product Components](https://help.chargify.com/products/product-components.html) for an overview of pricing schemes. - PricingScheme *PricingScheme `json:"pricing_scheme,omitempty"` - Prices []Price `json:"prices,omitempty"` - // Whether to use the site level exchange rate or define your own prices for each currency if you have multiple currencies defined on the site. - UseSiteExchangeRate *bool `json:"use_site_exchange_rate,omitempty"` - // Whether or not the price point includes tax - TaxIncluded *bool `json:"tax_included,omitempty"` - // The numerical interval. i.e. an interval of ‘30’ coupled with an interval_unit of day would mean this price point would renew every 30 days. This property is only available for sites with Multifrequency enabled. - Interval *int `json:"interval,omitempty"` - // A string representing the interval unit for this price point, either month or day. This property is only available for sites with Multifrequency enabled. - IntervalUnit *IntervalUnit `json:"interval_unit,omitempty"` - OveragePricing *OveragePricing `json:"overage_pricing,omitempty"` - // Boolean which controls whether or not remaining units should be rolled over to the next period - RolloverPrepaidRemainder *bool `json:"rollover_prepaid_remainder,omitempty"` - // Boolean which controls whether or not the allocated quantity should be renewed at the beginning of each period - RenewPrepaidAllocation *bool `json:"renew_prepaid_allocation,omitempty"` - // (only for prepaid usage components where rollover_prepaid_remainder is true) The number of `expiration_interval_unit`s after which rollover amounts should expire - ExpirationInterval *float64 `json:"expiration_interval,omitempty"` - ExpirationIntervalUnit *IntervalUnit `json:"expiration_interval_unit,omitempty"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for PricePoint. -// It customizes the JSON marshaling process for PricePoint objects. -func (p PricePoint) MarshalJSON() ( - []byte, - error) { - return json.Marshal(p.toMap()) -} - -// toMap converts the PricePoint object to a map representation for JSON marshaling. -func (p PricePoint) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, p.AdditionalProperties) - if p.Name != nil { - structMap["name"] = p.Name - } - if p.Handle != nil { - structMap["handle"] = p.Handle - } - if p.PricingScheme != nil { - structMap["pricing_scheme"] = p.PricingScheme - } - if p.Prices != nil { - structMap["prices"] = p.Prices - } - if p.UseSiteExchangeRate != nil { - structMap["use_site_exchange_rate"] = p.UseSiteExchangeRate - } - if p.TaxIncluded != nil { - structMap["tax_included"] = p.TaxIncluded - } - if p.Interval != nil { - structMap["interval"] = p.Interval - } - if p.IntervalUnit != nil { - structMap["interval_unit"] = p.IntervalUnit - } - if p.OveragePricing != nil { - structMap["overage_pricing"] = p.OveragePricing.toMap() - } - if p.RolloverPrepaidRemainder != nil { - structMap["rollover_prepaid_remainder"] = p.RolloverPrepaidRemainder - } - if p.RenewPrepaidAllocation != nil { - structMap["renew_prepaid_allocation"] = p.RenewPrepaidAllocation - } - if p.ExpirationInterval != nil { - structMap["expiration_interval"] = p.ExpirationInterval - } - if p.ExpirationIntervalUnit != nil { - structMap["expiration_interval_unit"] = p.ExpirationIntervalUnit - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for PricePoint. -// It customizes the JSON unmarshaling process for PricePoint objects. -func (p *PricePoint) UnmarshalJSON(input []byte) error { - var temp pricePoint - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "name", "handle", "pricing_scheme", "prices", "use_site_exchange_rate", "tax_included", "interval", "interval_unit", "overage_pricing", "rollover_prepaid_remainder", "renew_prepaid_allocation", "expiration_interval", "expiration_interval_unit") - if err != nil { - return err - } - - p.AdditionalProperties = additionalProperties - p.Name = temp.Name - p.Handle = temp.Handle - p.PricingScheme = temp.PricingScheme - p.Prices = temp.Prices - p.UseSiteExchangeRate = temp.UseSiteExchangeRate - p.TaxIncluded = temp.TaxIncluded - p.Interval = temp.Interval - p.IntervalUnit = temp.IntervalUnit - p.OveragePricing = temp.OveragePricing - p.RolloverPrepaidRemainder = temp.RolloverPrepaidRemainder - p.RenewPrepaidAllocation = temp.RenewPrepaidAllocation - p.ExpirationInterval = temp.ExpirationInterval - p.ExpirationIntervalUnit = temp.ExpirationIntervalUnit - return nil -} - -// pricePoint is a temporary struct used for validating the fields of PricePoint. -type pricePoint struct { - Name *string `json:"name,omitempty"` - Handle *string `json:"handle,omitempty"` - PricingScheme *PricingScheme `json:"pricing_scheme,omitempty"` - Prices []Price `json:"prices,omitempty"` - UseSiteExchangeRate *bool `json:"use_site_exchange_rate,omitempty"` - TaxIncluded *bool `json:"tax_included,omitempty"` - Interval *int `json:"interval,omitempty"` - IntervalUnit *IntervalUnit `json:"interval_unit,omitempty"` - OveragePricing *OveragePricing `json:"overage_pricing,omitempty"` - RolloverPrepaidRemainder *bool `json:"rollover_prepaid_remainder,omitempty"` - RenewPrepaidAllocation *bool `json:"renew_prepaid_allocation,omitempty"` - ExpirationInterval *float64 `json:"expiration_interval,omitempty"` - ExpirationIntervalUnit *IntervalUnit `json:"expiration_interval_unit,omitempty"` -} diff --git a/models/refund.go b/models/refund.go deleted file mode 100644 index 242c5c17..00000000 --- a/models/refund.go +++ /dev/null @@ -1,95 +0,0 @@ -package models - -import ( - "encoding/json" -) - -// Refund represents a Refund struct. -type Refund struct { - // The amount to be refunded in decimal format as a string. Example: "10.50". Must not exceed the remaining refundable balance of the payment. - Amount *string `json:"amount,omitempty"` - // A description that will be attached to the refund - Memo *string `json:"memo,omitempty"` - // The ID of the payment to be refunded - PaymentId *int `json:"payment_id,omitempty"` - // Flag that marks refund as external (no money is returned to the customer). Defaults to `false`. - External *bool `json:"external,omitempty"` - // If set to true, creates credit and applies it to an invoice. Defaults to `false`. - ApplyCredit *bool `json:"apply_credit,omitempty"` - // If `apply_credit` set to false and refunding full amount, if `void_invoice` set to true, invoice will be voided after refund. Defaults to `false`. - VoidInvoice *bool `json:"void_invoice,omitempty"` - // An array of segment uids to refund or the string 'all' to indicate that all segments should be refunded - SegmentUids *RefundSegmentUids `json:"segment_uids,omitempty"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for Refund. -// It customizes the JSON marshaling process for Refund objects. -func (r Refund) MarshalJSON() ( - []byte, - error) { - return json.Marshal(r.toMap()) -} - -// toMap converts the Refund object to a map representation for JSON marshaling. -func (r Refund) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, r.AdditionalProperties) - if r.Amount != nil { - structMap["amount"] = r.Amount - } - if r.Memo != nil { - structMap["memo"] = r.Memo - } - if r.PaymentId != nil { - structMap["payment_id"] = r.PaymentId - } - if r.External != nil { - structMap["external"] = r.External - } - if r.ApplyCredit != nil { - structMap["apply_credit"] = r.ApplyCredit - } - if r.VoidInvoice != nil { - structMap["void_invoice"] = r.VoidInvoice - } - if r.SegmentUids != nil { - structMap["segment_uids"] = r.SegmentUids.toMap() - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for Refund. -// It customizes the JSON unmarshaling process for Refund objects. -func (r *Refund) UnmarshalJSON(input []byte) error { - var temp refund - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "amount", "memo", "payment_id", "external", "apply_credit", "void_invoice", "segment_uids") - if err != nil { - return err - } - - r.AdditionalProperties = additionalProperties - r.Amount = temp.Amount - r.Memo = temp.Memo - r.PaymentId = temp.PaymentId - r.External = temp.External - r.ApplyCredit = temp.ApplyCredit - r.VoidInvoice = temp.VoidInvoice - r.SegmentUids = temp.SegmentUids - return nil -} - -// refund is a temporary struct used for validating the fields of Refund. -type refund struct { - Amount *string `json:"amount,omitempty"` - Memo *string `json:"memo,omitempty"` - PaymentId *int `json:"payment_id,omitempty"` - External *bool `json:"external,omitempty"` - ApplyCredit *bool `json:"apply_credit,omitempty"` - VoidInvoice *bool `json:"void_invoice,omitempty"` - SegmentUids *RefundSegmentUids `json:"segment_uids,omitempty"` -} diff --git a/models/refund_invoice_event.go b/models/refund_invoice_event.go new file mode 100644 index 00000000..571323e5 --- /dev/null +++ b/models/refund_invoice_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// RefundInvoiceEvent represents a RefundInvoiceEvent struct. +type RefundInvoiceEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `refund_invoice` event + EventData RefundInvoiceEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for RefundInvoiceEvent. +// It customizes the JSON marshaling process for RefundInvoiceEvent objects. +func (r RefundInvoiceEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(r.toMap()) +} + +// toMap converts the RefundInvoiceEvent object to a map representation for JSON marshaling. +func (r RefundInvoiceEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, r.AdditionalProperties) + structMap["id"] = r.Id + structMap["timestamp"] = r.Timestamp.Format(time.RFC3339) + structMap["invoice"] = r.Invoice.toMap() + structMap["event_type"] = r.EventType + structMap["event_data"] = r.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for RefundInvoiceEvent. +// It customizes the JSON unmarshaling process for RefundInvoiceEvent objects. +func (r *RefundInvoiceEvent) UnmarshalJSON(input []byte) error { + var temp refundInvoiceEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + r.AdditionalProperties = additionalProperties + r.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + r.Timestamp = TimestampVal + r.Invoice = *temp.Invoice + r.EventType = *temp.EventType + r.EventData = *temp.EventData + return nil +} + +// refundInvoiceEvent is a temporary struct used for validating the fields of RefundInvoiceEvent. +type refundInvoiceEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *RefundInvoiceEventData `json:"event_data"` +} + +func (r *refundInvoiceEvent) validate() error { + var errs []string + if r.Id == nil { + errs = append(errs, "required field `id` is missing for type `Refund Invoice Event`") + } + if r.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Refund Invoice Event`") + } + if r.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Refund Invoice Event`") + } + if r.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Refund Invoice Event`") + } + if r.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Refund Invoice Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/refund_segment_uids.go b/models/refund_segment_uids.go deleted file mode 100644 index a96c4f73..00000000 --- a/models/refund_segment_uids.go +++ /dev/null @@ -1,96 +0,0 @@ -/* -Package advancedbilling - -This file was automatically generated for Maxio by APIMATIC v3.0 ( https://www.apimatic.io ). -*/ -package models - -import ( - "encoding/json" - "errors" - "strings" -) - -// RefundSegmentUids represents a RefundSegmentUids struct. -// This is a container for one-of cases. -type RefundSegmentUids struct { - value any - isArrayOfString bool - isString bool -} - -// String converts the RefundSegmentUids object to a string representation. -func (r RefundSegmentUids) String() string { - if bytes, err := json.Marshal(r.value); err == nil { - return strings.Trim(string(bytes), "\"") - } - return "" -} - -// MarshalJSON implements the json.Marshaler interface for RefundSegmentUids. -// It customizes the JSON marshaling process for RefundSegmentUids objects. -func (r RefundSegmentUids) MarshalJSON() ( - []byte, - error) { - if r.value == nil { - return nil, errors.New("No underlying type is set. Please use any of the `models.RefundSegmentUidsContainer.From*` functions to initialize the RefundSegmentUids object.") - } - return json.Marshal(r.toMap()) -} - -// toMap converts the RefundSegmentUids object to a map representation for JSON marshaling. -func (r *RefundSegmentUids) toMap() any { - switch obj := r.value.(type) { - case *[]string: - return *obj - case *string: - return *obj - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaler interface for RefundSegmentUids. -// It customizes the JSON unmarshaling process for RefundSegmentUids objects. -func (r *RefundSegmentUids) UnmarshalJSON(input []byte) error { - result, err := UnmarshallOneOf(input, - NewTypeHolder(new([]string), false, &r.isArrayOfString), - NewTypeHolder(new(string), false, &r.isString), - ) - - r.value = result - return err -} - -func (r *RefundSegmentUids) AsArrayOfString() ( - *[]string, - bool) { - if !r.isArrayOfString { - return nil, false - } - return r.value.(*[]string), true -} - -func (r *RefundSegmentUids) AsString() ( - *string, - bool) { - if !r.isString { - return nil, false - } - return r.value.(*string), true -} - -// internalRefundSegmentUids represents a refundSegmentUids struct. -// This is a container for one-of cases. -type internalRefundSegmentUids struct {} - -var RefundSegmentUidsContainer internalRefundSegmentUids - -// The internalRefundSegmentUids instance, wrapping the provided []string value. -func (r *internalRefundSegmentUids) FromArrayOfString(val []string) RefundSegmentUids { - return RefundSegmentUids{value: &val} -} - -// The internalRefundSegmentUids instance, wrapping the provided string value. -func (r *internalRefundSegmentUids) FromString(val string) RefundSegmentUids { - return RefundSegmentUids{value: &val} -} diff --git a/models/remove_payment_event.go b/models/remove_payment_event.go new file mode 100644 index 00000000..ef22d9a3 --- /dev/null +++ b/models/remove_payment_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// RemovePaymentEvent represents a RemovePaymentEvent struct. +type RemovePaymentEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `remove_payment` event + EventData RemovePaymentEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for RemovePaymentEvent. +// It customizes the JSON marshaling process for RemovePaymentEvent objects. +func (r RemovePaymentEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(r.toMap()) +} + +// toMap converts the RemovePaymentEvent object to a map representation for JSON marshaling. +func (r RemovePaymentEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, r.AdditionalProperties) + structMap["id"] = r.Id + structMap["timestamp"] = r.Timestamp.Format(time.RFC3339) + structMap["invoice"] = r.Invoice.toMap() + structMap["event_type"] = r.EventType + structMap["event_data"] = r.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for RemovePaymentEvent. +// It customizes the JSON unmarshaling process for RemovePaymentEvent objects. +func (r *RemovePaymentEvent) UnmarshalJSON(input []byte) error { + var temp removePaymentEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + r.AdditionalProperties = additionalProperties + r.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + r.Timestamp = TimestampVal + r.Invoice = *temp.Invoice + r.EventType = *temp.EventType + r.EventData = *temp.EventData + return nil +} + +// removePaymentEvent is a temporary struct used for validating the fields of RemovePaymentEvent. +type removePaymentEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *RemovePaymentEventData `json:"event_data"` +} + +func (r *removePaymentEvent) validate() error { + var errs []string + if r.Id == nil { + errs = append(errs, "required field `id` is missing for type `Remove Payment Event`") + } + if r.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Remove Payment Event`") + } + if r.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Remove Payment Event`") + } + if r.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Remove Payment Event`") + } + if r.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Remove Payment Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/remove_payment_event_data.go b/models/remove_payment_event_data.go index fc25d814..33980385 100644 --- a/models/remove_payment_event_data.go +++ b/models/remove_payment_event_data.go @@ -12,20 +12,20 @@ import ( // Example schema for an `remove_payment` event type RemovePaymentEventData struct { // Transaction ID of the original payment that was removed - TransactionId int `json:"transaction_id"` + TransactionId int `json:"transaction_id"` // Memo of the original payment - Memo string `json:"memo"` + Memo string `json:"memo"` // Full amount of the original payment - OriginalAmount *string `json:"original_amount,omitempty"` + OriginalAmount *string `json:"original_amount,omitempty"` // Applied amount of the original payment - AppliedAmount string `json:"applied_amount"` + AppliedAmount string `json:"applied_amount"` // Transaction time of the original payment, in ISO 8601 format, i.e. "2019-06-07T17:20:06Z" - TransactionTime time.Time `json:"transaction_time"` + TransactionTime time.Time `json:"transaction_time"` // A nested data structure detailing the method of payment - PaymentMethod InvoiceEventPayment2 `json:"payment_method"` + PaymentMethod InvoiceEventPayment `json:"payment_method"` // The flag that shows whether the original payment was a prepayment or not - Prepayment bool `json:"prepayment"` - AdditionalProperties map[string]any `json:"_"` + Prepayment bool `json:"prepayment"` + AdditionalProperties map[string]any `json:"_"` } // MarshalJSON implements the json.Marshaler interface for RemovePaymentEventData. @@ -86,13 +86,13 @@ func (r *RemovePaymentEventData) UnmarshalJSON(input []byte) error { // removePaymentEventData is a temporary struct used for validating the fields of RemovePaymentEventData. type removePaymentEventData struct { - TransactionId *int `json:"transaction_id"` - Memo *string `json:"memo"` - OriginalAmount *string `json:"original_amount,omitempty"` - AppliedAmount *string `json:"applied_amount"` - TransactionTime *string `json:"transaction_time"` - PaymentMethod *InvoiceEventPayment2 `json:"payment_method"` - Prepayment *bool `json:"prepayment"` + TransactionId *int `json:"transaction_id"` + Memo *string `json:"memo"` + OriginalAmount *string `json:"original_amount,omitempty"` + AppliedAmount *string `json:"applied_amount"` + TransactionTime *string `json:"transaction_time"` + PaymentMethod *InvoiceEventPayment `json:"payment_method"` + Prepayment *bool `json:"prepayment"` } func (r *removePaymentEventData) validate() error { diff --git a/models/seller.go b/models/seller.go deleted file mode 100644 index 57372251..00000000 --- a/models/seller.go +++ /dev/null @@ -1,74 +0,0 @@ -package models - -import ( - "encoding/json" -) - -// Seller represents a Seller struct. -type Seller struct { - Name *string `json:"name,omitempty"` - Address *InvoiceAddress `json:"address,omitempty"` - Phone *string `json:"phone,omitempty"` - LogoUrl Optional[string] `json:"logo_url"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for Seller. -// It customizes the JSON marshaling process for Seller objects. -func (s Seller) MarshalJSON() ( - []byte, - error) { - return json.Marshal(s.toMap()) -} - -// toMap converts the Seller object to a map representation for JSON marshaling. -func (s Seller) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, s.AdditionalProperties) - if s.Name != nil { - structMap["name"] = s.Name - } - if s.Address != nil { - structMap["address"] = s.Address.toMap() - } - if s.Phone != nil { - structMap["phone"] = s.Phone - } - if s.LogoUrl.IsValueSet() { - if s.LogoUrl.Value() != nil { - structMap["logo_url"] = s.LogoUrl.Value() - } else { - structMap["logo_url"] = nil - } - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for Seller. -// It customizes the JSON unmarshaling process for Seller objects. -func (s *Seller) UnmarshalJSON(input []byte) error { - var temp seller - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "name", "address", "phone", "logo_url") - if err != nil { - return err - } - - s.AdditionalProperties = additionalProperties - s.Name = temp.Name - s.Address = temp.Address - s.Phone = temp.Phone - s.LogoUrl = temp.LogoUrl - return nil -} - -// seller is a temporary struct used for validating the fields of Seller. -type seller struct { - Name *string `json:"name,omitempty"` - Address *InvoiceAddress `json:"address,omitempty"` - Phone *string `json:"phone,omitempty"` - LogoUrl Optional[string] `json:"logo_url"` -} diff --git a/models/shipping_address.go b/models/shipping_address.go deleted file mode 100644 index 18f59154..00000000 --- a/models/shipping_address.go +++ /dev/null @@ -1,106 +0,0 @@ -package models - -import ( - "encoding/json" -) - -// ShippingAddress represents a ShippingAddress struct. -type ShippingAddress struct { - Street Optional[string] `json:"street"` - Line2 Optional[string] `json:"line2"` - City Optional[string] `json:"city"` - State Optional[string] `json:"state"` - Zip Optional[string] `json:"zip"` - Country Optional[string] `json:"country"` - AdditionalProperties map[string]any `json:"_"` -} - -// MarshalJSON implements the json.Marshaler interface for ShippingAddress. -// It customizes the JSON marshaling process for ShippingAddress objects. -func (s ShippingAddress) MarshalJSON() ( - []byte, - error) { - return json.Marshal(s.toMap()) -} - -// toMap converts the ShippingAddress object to a map representation for JSON marshaling. -func (s ShippingAddress) toMap() map[string]any { - structMap := make(map[string]any) - MapAdditionalProperties(structMap, s.AdditionalProperties) - if s.Street.IsValueSet() { - if s.Street.Value() != nil { - structMap["street"] = s.Street.Value() - } else { - structMap["street"] = nil - } - } - if s.Line2.IsValueSet() { - if s.Line2.Value() != nil { - structMap["line2"] = s.Line2.Value() - } else { - structMap["line2"] = nil - } - } - if s.City.IsValueSet() { - if s.City.Value() != nil { - structMap["city"] = s.City.Value() - } else { - structMap["city"] = nil - } - } - if s.State.IsValueSet() { - if s.State.Value() != nil { - structMap["state"] = s.State.Value() - } else { - structMap["state"] = nil - } - } - if s.Zip.IsValueSet() { - if s.Zip.Value() != nil { - structMap["zip"] = s.Zip.Value() - } else { - structMap["zip"] = nil - } - } - if s.Country.IsValueSet() { - if s.Country.Value() != nil { - structMap["country"] = s.Country.Value() - } else { - structMap["country"] = nil - } - } - return structMap -} - -// UnmarshalJSON implements the json.Unmarshaler interface for ShippingAddress. -// It customizes the JSON unmarshaling process for ShippingAddress objects. -func (s *ShippingAddress) UnmarshalJSON(input []byte) error { - var temp shippingAddress - err := json.Unmarshal(input, &temp) - if err != nil { - return err - } - additionalProperties, err := UnmarshalAdditionalProperties(input, "street", "line2", "city", "state", "zip", "country") - if err != nil { - return err - } - - s.AdditionalProperties = additionalProperties - s.Street = temp.Street - s.Line2 = temp.Line2 - s.City = temp.City - s.State = temp.State - s.Zip = temp.Zip - s.Country = temp.Country - return nil -} - -// shippingAddress is a temporary struct used for validating the fields of ShippingAddress. -type shippingAddress struct { - Street Optional[string] `json:"street"` - Line2 Optional[string] `json:"line2"` - City Optional[string] `json:"city"` - State Optional[string] `json:"state"` - Zip Optional[string] `json:"zip"` - Country Optional[string] `json:"country"` -} diff --git a/models/void_invoice_event.go b/models/void_invoice_event.go new file mode 100644 index 00000000..f4c8eab8 --- /dev/null +++ b/models/void_invoice_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// VoidInvoiceEvent represents a VoidInvoiceEvent struct. +type VoidInvoiceEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `void_invoice` event + EventData VoidInvoiceEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for VoidInvoiceEvent. +// It customizes the JSON marshaling process for VoidInvoiceEvent objects. +func (v VoidInvoiceEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(v.toMap()) +} + +// toMap converts the VoidInvoiceEvent object to a map representation for JSON marshaling. +func (v VoidInvoiceEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, v.AdditionalProperties) + structMap["id"] = v.Id + structMap["timestamp"] = v.Timestamp.Format(time.RFC3339) + structMap["invoice"] = v.Invoice.toMap() + structMap["event_type"] = v.EventType + structMap["event_data"] = v.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for VoidInvoiceEvent. +// It customizes the JSON unmarshaling process for VoidInvoiceEvent objects. +func (v *VoidInvoiceEvent) UnmarshalJSON(input []byte) error { + var temp voidInvoiceEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + v.AdditionalProperties = additionalProperties + v.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + v.Timestamp = TimestampVal + v.Invoice = *temp.Invoice + v.EventType = *temp.EventType + v.EventData = *temp.EventData + return nil +} + +// voidInvoiceEvent is a temporary struct used for validating the fields of VoidInvoiceEvent. +type voidInvoiceEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *VoidInvoiceEventData `json:"event_data"` +} + +func (v *voidInvoiceEvent) validate() error { + var errs []string + if v.Id == nil { + errs = append(errs, "required field `id` is missing for type `Void Invoice Event`") + } + if v.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Void Invoice Event`") + } + if v.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Void Invoice Event`") + } + if v.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Void Invoice Event`") + } + if v.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Void Invoice Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/models/void_remainder_event.go b/models/void_remainder_event.go new file mode 100644 index 00000000..587de19c --- /dev/null +++ b/models/void_remainder_event.go @@ -0,0 +1,102 @@ +package models + +import ( + "encoding/json" + "errors" + "log" + "strings" + "time" +) + +// VoidRemainderEvent represents a VoidRemainderEvent struct. +type VoidRemainderEvent struct { + Id int64 `json:"id"` + Timestamp time.Time `json:"timestamp"` + Invoice Invoice `json:"invoice"` + EventType InvoiceEventType `json:"event_type"` + // Example schema for an `void_remainder` event + EventData VoidRemainderEventData `json:"event_data"` + AdditionalProperties map[string]any `json:"_"` +} + +// MarshalJSON implements the json.Marshaler interface for VoidRemainderEvent. +// It customizes the JSON marshaling process for VoidRemainderEvent objects. +func (v VoidRemainderEvent) MarshalJSON() ( + []byte, + error) { + return json.Marshal(v.toMap()) +} + +// toMap converts the VoidRemainderEvent object to a map representation for JSON marshaling. +func (v VoidRemainderEvent) toMap() map[string]any { + structMap := make(map[string]any) + MapAdditionalProperties(structMap, v.AdditionalProperties) + structMap["id"] = v.Id + structMap["timestamp"] = v.Timestamp.Format(time.RFC3339) + structMap["invoice"] = v.Invoice.toMap() + structMap["event_type"] = v.EventType + structMap["event_data"] = v.EventData.toMap() + return structMap +} + +// UnmarshalJSON implements the json.Unmarshaler interface for VoidRemainderEvent. +// It customizes the JSON unmarshaling process for VoidRemainderEvent objects. +func (v *VoidRemainderEvent) UnmarshalJSON(input []byte) error { + var temp voidRemainderEvent + err := json.Unmarshal(input, &temp) + if err != nil { + return err + } + err = temp.validate() + if err != nil { + return err + } + additionalProperties, err := UnmarshalAdditionalProperties(input, "id", "timestamp", "invoice", "event_type", "event_data") + if err != nil { + return err + } + + v.AdditionalProperties = additionalProperties + v.Id = *temp.Id + TimestampVal, err := time.Parse(time.RFC3339, *temp.Timestamp) + if err != nil { + log.Fatalf("Cannot Parse timestamp as % s format.", time.RFC3339) + } + v.Timestamp = TimestampVal + v.Invoice = *temp.Invoice + v.EventType = *temp.EventType + v.EventData = *temp.EventData + return nil +} + +// voidRemainderEvent is a temporary struct used for validating the fields of VoidRemainderEvent. +type voidRemainderEvent struct { + Id *int64 `json:"id"` + Timestamp *string `json:"timestamp"` + Invoice *Invoice `json:"invoice"` + EventType *InvoiceEventType `json:"event_type"` + EventData *VoidRemainderEventData `json:"event_data"` +} + +func (v *voidRemainderEvent) validate() error { + var errs []string + if v.Id == nil { + errs = append(errs, "required field `id` is missing for type `Void Remainder Event`") + } + if v.Timestamp == nil { + errs = append(errs, "required field `timestamp` is missing for type `Void Remainder Event`") + } + if v.Invoice == nil { + errs = append(errs, "required field `invoice` is missing for type `Void Remainder Event`") + } + if v.EventType == nil { + errs = append(errs, "required field `event_type` is missing for type `Void Remainder Event`") + } + if v.EventData == nil { + errs = append(errs, "required field `event_data` is missing for type `Void Remainder Event`") + } + if len(errs) == 0 { + return nil + } + return errors.New(strings.Join(errs, "\n")) +} diff --git a/subscription_components_controller.go b/subscription_components_controller.go index 2310cc23..d1156018 100644 --- a/subscription_components_controller.go +++ b/subscription_components_controller.go @@ -80,9 +80,11 @@ type ListSubscriptionComponentsInput struct { StartDatetime *string // Allows including additional data in the response. Use in query `include=subscription,historic_usages`. Include []models.ListSubscriptionComponentsInclude + // If in_use is set to true, it returns only components that are currently in use. However, if it's set to false or not provided, it returns all components connected with the subscription. + InUse *bool } -// ListSubscriptionComponents takes context, subscriptionId, dateField, direction, filter, endDate, endDatetime, pricePointIds, productFamilyIds, sort, startDate, startDatetime, include as parameters and +// ListSubscriptionComponents takes context, subscriptionId, dateField, direction, filter, endDate, endDatetime, pricePointIds, productFamilyIds, sort, startDate, startDatetime, include, inUse as parameters and // returns an models.ApiResponse with []models.SubscriptionComponentResponse data and // an error if there was an issue with the request or response. // This request will list a subscription's applied components. @@ -132,6 +134,9 @@ func (s *SubscriptionComponentsController) ListSubscriptionComponents( if input.Include != nil { req.QueryParam("include", input.Include) } + if input.InUse != nil { + req.QueryParam("in_use", *input.InUse) + } var result []models.SubscriptionComponentResponse decoder, resp, err := req.CallAsJson() @@ -553,9 +558,9 @@ type ListUsagesInput struct { // Either the Chargify id for the component or the component's handle prefixed by `handle:` ComponentId models.ListUsagesInputComponentId // Returns usages with an id greater than or equal to the one specified - SinceId *int + SinceId *int64 // Returns usages with an id less than or equal to the one specified - MaxId *int + MaxId *int64 // Returns usages with a created_at date greater than or equal to midnight (12:00 AM) on the date specified. SinceDate *time.Time // Returns usages with a created_at date less than or equal to midnight (12:00 AM) on the date specified. diff --git a/test/go.mod b/test/go.mod index 0c46fc26..7005a134 100644 --- a/test/go.mod +++ b/test/go.mod @@ -11,7 +11,7 @@ require ( ) require ( - github.com/apimatic/go-core-runtime v0.0.20 + github.com/apimatic/go-core-runtime v0.0.21 github.com/caarlos0/env/v10 v10.0.0 github.com/jaswdr/faker v1.19.1 github.com/maxio-com/ab-golang-sdk v0.0.1 diff --git a/test/go.sum b/test/go.sum index 09b8f235..3137bd04 100644 --- a/test/go.sum +++ b/test/go.sum @@ -1,5 +1,5 @@ -github.com/apimatic/go-core-runtime v0.0.20 h1:orjqhRC43F1xDRGOYbJsosTbja3UzE60DLvloHsG9xc= -github.com/apimatic/go-core-runtime v0.0.20/go.mod h1:kyqGg2v3OTV7o2fXHgbHLZPMinqZvIqw1JwdEd64OzM= +github.com/apimatic/go-core-runtime v0.0.21 h1:05q2QqxfCxY8ejQQjJYs78DFjFvOeSnMl3EZNRuw3bc= +github.com/apimatic/go-core-runtime v0.0.21/go.mod h1:kyqGg2v3OTV7o2fXHgbHLZPMinqZvIqw1JwdEd64OzM= github.com/caarlos0/env/v10 v10.0.0 h1:yIHUBZGsyqCnpTkbjk8asUlx6RFhhEs+h7TOBdgdzXA= github.com/caarlos0/env/v10 v10.0.0/go.mod h1:ZfulV76NvVPw3tm591U4SwL3Xx9ldzBP9aGxzeN7G18= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/test/suite.go b/test/suite.go index 657c769e..e8cbc8c1 100644 --- a/test/suite.go +++ b/test/suite.go @@ -126,7 +126,7 @@ func (s *APISuite) generateCustomer(ctx context.Context) models.Customer { func (s *APISuite) generateProductFamily(ctx context.Context) models.ProductFamily { resp, err := s.client.ProductFamiliesController().CreateProductFamily(ctx, &models.CreateProductFamilyRequest{ ProductFamily: models.CreateProductFamily{ - Name: strPtr(s.fkr.RandomStringWithLength(20)), + Name: s.fkr.RandomStringWithLength(20), }, })