Skip to content

Commit

Permalink
[DE-1013] Release v0.4.2 (#34)
Browse files Browse the repository at this point in the history
- Added `tax_exempt_reason` and `default_auto_renewal_profile_id` to `Customer`
- Added `received_on` to `InvoicePayment` and `CreateInvoicePayment`
- Added `product_price_point_id` and `product_price_point_handle` to `UpdateSubscription`
- Improved some properties descriptions
  • Loading branch information
maciej-nedza authored Oct 17, 2024
1 parent fca30de commit 5ab29bf
Show file tree
Hide file tree
Showing 14 changed files with 172 additions and 71 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ The following section explains how to use the advancedbilling library in a new p
To use the package in your application, you can install the package from [pkg.go.dev](https://pkg.go.dev/) using the following command:

```bash
$ go get github.com/maxio-com/[email protected].1
$ go get github.com/maxio-com/[email protected].2
```

You can also view the package at: https://pkg.go.dev/github.com/maxio-com/[email protected].1
You can also view the package at: https://pkg.go.dev/github.com/maxio-com/[email protected].2

## Initialize the API Client

Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func NewClient(configuration Configuration) ClientInterface {
configuration: configuration,
}

client.userAgent = utilities.UpdateUserAgent("AB SDK Go:0.4.1 on OS {os-info}")
client.userAgent = utilities.UpdateUserAgent("AB SDK Go:0.4.2 on OS {os-info}")
client.callBuilderFactory = callBuilderHandler(
func(server string) string {
if server == "" {
Expand Down
12 changes: 6 additions & 6 deletions doc/controllers/proforma-invoices.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ body := models.CreateSubscriptionRequest{
Subscription: models.CreateSubscription{
ProductHandle: models.ToPointer("gold-product"),
CustomerAttributes: models.ToPointer(models.CustomerAttributes{
FirstName: models.ToPointer("Myra"),
LastName: models.ToPointer("Maisel"),
Email: models.ToPointer("[email protected]"),
FirstName: models.ToPointer("Myra"),
LastName: models.ToPointer("Maisel"),
Email: models.ToPointer("[email protected]"),
}),
},
}
Expand Down Expand Up @@ -513,9 +513,9 @@ body := models.CreateSubscriptionRequest{
Subscription: models.CreateSubscription{
ProductHandle: models.ToPointer("gold-plan"),
CustomerAttributes: models.ToPointer(models.CustomerAttributes{
FirstName: models.ToPointer("first"),
LastName: models.ToPointer("last"),
Email: models.ToPointer("[email protected]"),
FirstName: models.ToPointer("first"),
LastName: models.ToPointer("last"),
Email: models.ToPointer("[email protected]"),
}),
},
}
Expand Down
24 changes: 12 additions & 12 deletions doc/controllers/subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -700,18 +700,18 @@ body := models.CreateSubscriptionRequest{
Subscription: models.CreateSubscription{
ProductHandle: models.ToPointer("basic"),
CustomerAttributes: models.ToPointer(models.CustomerAttributes{
FirstName: models.ToPointer("Joe"),
LastName: models.ToPointer("Blow"),
Email: models.ToPointer("[email protected]"),
Organization: models.ToPointer("Acme"),
Reference: models.ToPointer("XYZ"),
Address: models.ToPointer("123 Mass Ave."),
Address2: models.NewOptional(models.ToPointer("address_24")),
City: models.ToPointer("Boston"),
State: models.ToPointer("MA"),
Zip: models.ToPointer("02120"),
Country: models.ToPointer("US"),
Phone: models.ToPointer("(617) 111 - 0000"),
FirstName: models.ToPointer("Joe"),
LastName: models.ToPointer("Blow"),
Email: models.ToPointer("[email protected]"),
Organization: models.ToPointer("Acme"),
Reference: models.ToPointer("XYZ"),
Address: models.ToPointer("123 Mass Ave."),
Address2: models.NewOptional(models.ToPointer("address_24")),
City: models.ToPointer("Boston"),
State: models.ToPointer("MA"),
Zip: models.ToPointer("02120"),
Country: models.ToPointer("US"),
Phone: models.ToPointer("(617) 111 - 0000"),
}),
CreditCardAttributes: models.ToPointer(models.PaymentProfileAttributes{
FirstName: models.ToPointer("Joe"),
Expand Down
5 changes: 3 additions & 2 deletions doc/models/create-invoice-payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
| Name | Type | Tags | Description |
| --- | --- | --- | --- |
| `Amount` | [`*models.CreateInvoicePaymentAmount`](../../doc/models/containers/create-invoice-payment-amount.md) | Optional | This is a container for one-of cases. |
| `Memo` | `*string` | Optional | A description to be attached to the payment. |
| `Memo` | `*string` | Optional | A description to be attached to the payment. Applicable only to `external` payments. |
| `Method` | [`*models.InvoicePaymentMethodType`](../../doc/models/invoice-payment-method-type.md) | Optional | The type of payment method used. Defaults to other. |
| `Details` | `*string` | Optional | Additional information related to the payment method (eg. Check #) |
| `Details` | `*string` | Optional | Additional information related to the payment method (eg. Check #). Applicable only to `external` payments. |
| `PaymentProfileId` | `*int` | Optional | The ID of the payment profile to be used for the payment. |
| `ReceivedOn` | `*time.Time` | Optional | Date reflecting when the payment was received from a customer. Must be in the past. Applicable only to<br>`external` payments. |

## Example (as JSON)

Expand Down
1 change: 1 addition & 0 deletions doc/models/customer-attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| `Metafields` | `map[string]string` | Optional | (Optional) A set of key/value pairs representing custom fields and their values. Metafields will be created “on-the-fly” in your site for a given key, if they have not been created yet. |
| `ParentId` | `models.Optional[int]` | Optional | The parent ID in Chargify if applicable. Parent is another Customer object. |
| `SalesforceId` | `models.Optional[string]` | Optional | (Optional) The Salesforce ID of the customer. |
| `DefaultAutoRenewalProfileId` | `models.Optional[int]` | Optional | (Optional) The default auto-renewal profile ID for the customer |

## Example (as JSON)

Expand Down
4 changes: 3 additions & 1 deletion doc/models/customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
| `Country` | `models.Optional[string]` | Optional | The customer shipping address country |
| `CountryName` | `models.Optional[string]` | Optional | The customer's full name of country |
| `Phone` | `models.Optional[string]` | Optional | The phone number of the customer |
| `Verified` | `models.Optional[bool]` | Optional | Is the customer verified to use ACH as a payment method. Available only on Authorize.Net gateway |
| `Verified` | `models.Optional[bool]` | Optional | Is the customer verified to use ACH as a payment method. |
| `PortalCustomerCreatedAt` | `models.Optional[time.Time]` | Optional | The timestamp of when the Billing Portal entry was created at for the customer |
| `PortalInviteLastSentAt` | `models.Optional[time.Time]` | Optional | The timestamp of when the Billing Portal invite was last sent at |
| `PortalInviteLastAcceptedAt` | `models.Optional[time.Time]` | Optional | The timestamp of when the Billing Portal invite was last accepted |
Expand All @@ -37,6 +37,8 @@
| `Locale` | `models.Optional[string]` | Optional | The locale for the customer to identify language-region |
| `DefaultSubscriptionGroupUid` | `models.Optional[string]` | Optional | - |
| `SalesforceId` | `models.Optional[string]` | Optional | The Salesforce ID for the customer |
| `TaxExemptReason` | `models.Optional[string]` | Optional | The Tax Exemption Reason Code for the customer |
| `DefaultAutoRenewalProfileId` | `models.Optional[int]` | Optional | The default auto-renewal profile ID for the customer |

## Example (as JSON)

Expand Down
2 changes: 2 additions & 0 deletions doc/models/invoice-payment.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
| `GatewayHandle` | `models.Optional[string]` | Optional | - |
| `GatewayUsed` | `*string` | Optional | - |
| `GatewayTransactionId` | `models.Optional[string]` | Optional | The transaction ID for the payment as returned from the payment gateway |
| `ReceivedOn` | `models.Optional[time.Time]` | Optional | Date reflecting when the payment was received from a customer. Must be in the past. Applicable only to<br>`external` payments. |
| `Uid` | `*string` | Optional | - |

## Example (as JSON)

Expand Down
2 changes: 2 additions & 0 deletions doc/models/update-subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
| `Components` | [`[]models.UpdateSubscriptionComponent`](../../doc/models/update-subscription-component.md) | Optional | (Optional) An array of component ids and custom prices to be added to the subscription. |
| `DunningCommunicationDelayEnabled` | `models.Optional[bool]` | Optional | Enable Communication Delay feature, making sure no communication (email or SMS) is sent to the Customer between 9PM and 8AM in time zone set by the `dunning_communication_delay_time_zone` attribute. |
| `DunningCommunicationDelayTimeZone` | `models.Optional[string]` | Optional | Time zone for the Dunning Communication Delay feature. |
| `ProductPricePointId` | `*int` | Optional | Set to change the current product's price point. |
| `ProductPricePointHandle` | `*string` | Optional | Set to change the current product's price point. |

## Example (as JSON)

Expand Down
22 changes: 19 additions & 3 deletions models/create_invoice_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ package models

import (
"encoding/json"
"log"
"time"
)

// CreateInvoicePayment represents a CreateInvoicePayment struct.
type CreateInvoicePayment struct {
// A string of the dollar amount to be refunded (eg. "10.50" => $10.50)
Amount *CreateInvoicePaymentAmount `json:"amount,omitempty"`
// A description to be attached to the payment.
// A description to be attached to the payment. Applicable only to `external` payments.
Memo *string `json:"memo,omitempty"`
// The type of payment method used. Defaults to other.
Method *InvoicePaymentMethodType `json:"method,omitempty"`
// Additional information related to the payment method (eg. Check #)
// Additional information related to the payment method (eg. Check #). Applicable only to `external` payments.
Details *string `json:"details,omitempty"`
// The ID of the payment profile to be used for the payment.
PaymentProfileId *int `json:"payment_profile_id,omitempty"`
// Date reflecting when the payment was received from a customer. Must be in the past. Applicable only to
// `external` payments.
ReceivedOn *time.Time `json:"received_on,omitempty"`
AdditionalProperties map[string]any `json:"_"`
}

Expand Down Expand Up @@ -51,6 +56,9 @@ func (c CreateInvoicePayment) toMap() map[string]any {
if c.PaymentProfileId != nil {
structMap["payment_profile_id"] = c.PaymentProfileId
}
if c.ReceivedOn != nil {
structMap["received_on"] = c.ReceivedOn.Format(DEFAULT_DATE)
}
return structMap
}

Expand All @@ -62,7 +70,7 @@ func (c *CreateInvoicePayment) UnmarshalJSON(input []byte) error {
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "amount", "memo", "method", "details", "payment_profile_id")
additionalProperties, err := UnmarshalAdditionalProperties(input, "amount", "memo", "method", "details", "payment_profile_id", "received_on")
if err != nil {
return err
}
Expand All @@ -73,6 +81,13 @@ func (c *CreateInvoicePayment) UnmarshalJSON(input []byte) error {
c.Method = temp.Method
c.Details = temp.Details
c.PaymentProfileId = temp.PaymentProfileId
if temp.ReceivedOn != nil {
ReceivedOnVal, err := time.Parse(DEFAULT_DATE, *temp.ReceivedOn)
if err != nil {
log.Fatalf("Cannot Parse received_on as % s format.", DEFAULT_DATE)
}
c.ReceivedOn = &ReceivedOnVal
}
return nil
}

Expand All @@ -83,4 +98,5 @@ type tempCreateInvoicePayment struct {
Method *InvoicePaymentMethodType `json:"method,omitempty"`
Details *string `json:"details,omitempty"`
PaymentProfileId *int `json:"payment_profile_id,omitempty"`
ReceivedOn *string `json:"received_on,omitempty"`
}
26 changes: 24 additions & 2 deletions models/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Customer struct {
CountryName Optional[string] `json:"country_name"`
// The phone number of the customer
Phone Optional[string] `json:"phone"`
// Is the customer verified to use ACH as a payment method. Available only on Authorize.Net gateway
// Is the customer verified to use ACH as a payment method.
Verified Optional[bool] `json:"verified"`
// The timestamp of when the Billing Portal entry was created at for the customer
PortalCustomerCreatedAt Optional[time.Time] `json:"portal_customer_created_at"`
Expand All @@ -68,6 +68,10 @@ type Customer struct {
DefaultSubscriptionGroupUid Optional[string] `json:"default_subscription_group_uid"`
// The Salesforce ID for the customer
SalesforceId Optional[string] `json:"salesforce_id"`
// The Tax Exemption Reason Code for the customer
TaxExemptReason Optional[string] `json:"tax_exempt_reason"`
// The default auto-renewal profile ID for the customer
DefaultAutoRenewalProfileId Optional[int] `json:"default_auto_renewal_profile_id"`
AdditionalProperties map[string]any `json:"_"`
}

Expand Down Expand Up @@ -266,6 +270,20 @@ func (c Customer) toMap() map[string]any {
structMap["salesforce_id"] = nil
}
}
if c.TaxExemptReason.IsValueSet() {
if c.TaxExemptReason.Value() != nil {
structMap["tax_exempt_reason"] = c.TaxExemptReason.Value()
} else {
structMap["tax_exempt_reason"] = nil
}
}
if c.DefaultAutoRenewalProfileId.IsValueSet() {
if c.DefaultAutoRenewalProfileId.Value() != nil {
structMap["default_auto_renewal_profile_id"] = c.DefaultAutoRenewalProfileId.Value()
} else {
structMap["default_auto_renewal_profile_id"] = nil
}
}
return structMap
}

Expand All @@ -277,7 +295,7 @@ func (c *Customer) UnmarshalJSON(input []byte) error {
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "first_name", "last_name", "email", "cc_emails", "organization", "reference", "id", "created_at", "updated_at", "address", "address_2", "city", "state", "state_name", "zip", "country", "country_name", "phone", "verified", "portal_customer_created_at", "portal_invite_last_sent_at", "portal_invite_last_accepted_at", "tax_exempt", "vat_number", "parent_id", "locale", "default_subscription_group_uid", "salesforce_id")
additionalProperties, err := UnmarshalAdditionalProperties(input, "first_name", "last_name", "email", "cc_emails", "organization", "reference", "id", "created_at", "updated_at", "address", "address_2", "city", "state", "state_name", "zip", "country", "country_name", "phone", "verified", "portal_customer_created_at", "portal_invite_last_sent_at", "portal_invite_last_accepted_at", "tax_exempt", "vat_number", "parent_id", "locale", "default_subscription_group_uid", "salesforce_id", "tax_exempt_reason", "default_auto_renewal_profile_id")
if err != nil {
return err
}
Expand Down Expand Up @@ -344,6 +362,8 @@ func (c *Customer) UnmarshalJSON(input []byte) error {
c.Locale = temp.Locale
c.DefaultSubscriptionGroupUid = temp.DefaultSubscriptionGroupUid
c.SalesforceId = temp.SalesforceId
c.TaxExemptReason = temp.TaxExemptReason
c.DefaultAutoRenewalProfileId = temp.DefaultAutoRenewalProfileId
return nil
}

Expand Down Expand Up @@ -377,4 +397,6 @@ type tempCustomer struct {
Locale Optional[string] `json:"locale"`
DefaultSubscriptionGroupUid Optional[string] `json:"default_subscription_group_uid"`
SalesforceId Optional[string] `json:"salesforce_id"`
TaxExemptReason Optional[string] `json:"tax_exempt_reason"`
DefaultAutoRenewalProfileId Optional[int] `json:"default_auto_renewal_profile_id"`
}
Loading

0 comments on commit 5ab29bf

Please sign in to comment.