Skip to content

Commit

Permalink
[DE-932] Release 5.0.0 - add salesforceId to customer
Browse files Browse the repository at this point in the history
  • Loading branch information
maciej-nedza committed Aug 21, 2024
1 parent be156fd commit 783a8d2
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 80 deletions.
1 change: 1 addition & 0 deletions doc/models/create-customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
| `TaxExempt` | `*bool` | Optional | - |
| `TaxExemptReason` | `*string` | Optional | - |
| `ParentId` | `models.Optional[int]` | Optional | The parent ID in Chargify if applicable. Parent is another Customer object. |
| `SalesforceId` | `models.Optional[string]` | Optional | The Salesforce ID of the customer |

## 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 @@ -27,6 +27,7 @@
| `VatNumber` | `*string` | Optional | (Optional) Supplying the VAT number allows EU customer’s to opt-out of the Value Added Tax assuming the merchant address and customer billing address are not within the same EU country. It’s important to omit the country code from the VAT number upon entry. Otherwise, taxes will be assessed upon the purchase. |
| `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. |

## Example (as JSON)

Expand Down
1 change: 1 addition & 0 deletions doc/models/customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
| `ParentId` | `models.Optional[int]` | Optional | The parent ID in Chargify if applicable. Parent is another Customer object. |
| `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 |

## Example (as JSON)

Expand Down
1 change: 1 addition & 0 deletions doc/models/update-customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
| `TaxExemptReason` | `*string` | Optional | - |
| `ParentId` | `models.Optional[int]` | Optional | - |
| `Verified` | `models.Optional[bool]` | Optional | Is the customer verified to use ACH as a payment method. Available only on Authorize.Net gateway |
| `SalesforceId` | `models.Optional[string]` | Optional | The Salesforce ID of the customer |

## Example (as JSON)

Expand Down
Binary file modified maxio-advanced-billing-go_generic_lib.zip
Binary file not shown.
87 changes: 49 additions & 38 deletions models/create_customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,29 @@ import (

// CreateCustomer represents a CreateCustomer struct.
type CreateCustomer struct {
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
CcEmails *string `json:"cc_emails,omitempty"`
Organization *string `json:"organization,omitempty"`
Reference *string `json:"reference,omitempty"`
Address *string `json:"address,omitempty"`
Address2 *string `json:"address_2,omitempty"`
City *string `json:"city,omitempty"`
State *string `json:"state,omitempty"`
Zip *string `json:"zip,omitempty"`
Country *string `json:"country,omitempty"`
Phone *string `json:"phone,omitempty"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
CcEmails *string `json:"cc_emails,omitempty"`
Organization *string `json:"organization,omitempty"`
Reference *string `json:"reference,omitempty"`
Address *string `json:"address,omitempty"`
Address2 *string `json:"address_2,omitempty"`
City *string `json:"city,omitempty"`
State *string `json:"state,omitempty"`
Zip *string `json:"zip,omitempty"`
Country *string `json:"country,omitempty"`
Phone *string `json:"phone,omitempty"`
// Set a specific language on a customer record.
Locale *string `json:"locale,omitempty"`
VatNumber *string `json:"vat_number,omitempty"`
TaxExempt *bool `json:"tax_exempt,omitempty"`
TaxExemptReason *string `json:"tax_exempt_reason,omitempty"`
Locale *string `json:"locale,omitempty"`
VatNumber *string `json:"vat_number,omitempty"`
TaxExempt *bool `json:"tax_exempt,omitempty"`
TaxExemptReason *string `json:"tax_exempt_reason,omitempty"`
// The parent ID in Chargify if applicable. Parent is another Customer object.
ParentId Optional[int] `json:"parent_id"`
AdditionalProperties map[string]any `json:"_"`
ParentId Optional[int] `json:"parent_id"`
// The Salesforce ID of the customer
SalesforceId Optional[string] `json:"salesforce_id"`
AdditionalProperties map[string]any `json:"_"`
}

// MarshalJSON implements the json.Marshaler interface for CreateCustomer.
Expand Down Expand Up @@ -100,6 +102,13 @@ func (c CreateCustomer) toMap() map[string]any {
structMap["parent_id"] = nil
}
}
if c.SalesforceId.IsValueSet() {
if c.SalesforceId.Value() != nil {
structMap["salesforce_id"] = c.SalesforceId.Value()
} else {
structMap["salesforce_id"] = nil
}
}
return structMap
}

Expand All @@ -115,7 +124,7 @@ func (c *CreateCustomer) UnmarshalJSON(input []byte) error {
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "first_name", "last_name", "email", "cc_emails", "organization", "reference", "address", "address_2", "city", "state", "zip", "country", "phone", "locale", "vat_number", "tax_exempt", "tax_exempt_reason", "parent_id")
additionalProperties, err := UnmarshalAdditionalProperties(input, "first_name", "last_name", "email", "cc_emails", "organization", "reference", "address", "address_2", "city", "state", "zip", "country", "phone", "locale", "vat_number", "tax_exempt", "tax_exempt_reason", "parent_id", "salesforce_id")
if err != nil {
return err
}
Expand All @@ -139,29 +148,31 @@ func (c *CreateCustomer) UnmarshalJSON(input []byte) error {
c.TaxExempt = temp.TaxExempt
c.TaxExemptReason = temp.TaxExemptReason
c.ParentId = temp.ParentId
c.SalesforceId = temp.SalesforceId
return nil
}

// tempCreateCustomer is a temporary struct used for validating the fields of CreateCustomer.
type tempCreateCustomer struct {
FirstName *string `json:"first_name"`
LastName *string `json:"last_name"`
Email *string `json:"email"`
CcEmails *string `json:"cc_emails,omitempty"`
Organization *string `json:"organization,omitempty"`
Reference *string `json:"reference,omitempty"`
Address *string `json:"address,omitempty"`
Address2 *string `json:"address_2,omitempty"`
City *string `json:"city,omitempty"`
State *string `json:"state,omitempty"`
Zip *string `json:"zip,omitempty"`
Country *string `json:"country,omitempty"`
Phone *string `json:"phone,omitempty"`
Locale *string `json:"locale,omitempty"`
VatNumber *string `json:"vat_number,omitempty"`
TaxExempt *bool `json:"tax_exempt,omitempty"`
TaxExemptReason *string `json:"tax_exempt_reason,omitempty"`
ParentId Optional[int] `json:"parent_id"`
FirstName *string `json:"first_name"`
LastName *string `json:"last_name"`
Email *string `json:"email"`
CcEmails *string `json:"cc_emails,omitempty"`
Organization *string `json:"organization,omitempty"`
Reference *string `json:"reference,omitempty"`
Address *string `json:"address,omitempty"`
Address2 *string `json:"address_2,omitempty"`
City *string `json:"city,omitempty"`
State *string `json:"state,omitempty"`
Zip *string `json:"zip,omitempty"`
Country *string `json:"country,omitempty"`
Phone *string `json:"phone,omitempty"`
Locale *string `json:"locale,omitempty"`
VatNumber *string `json:"vat_number,omitempty"`
TaxExempt *bool `json:"tax_exempt,omitempty"`
TaxExemptReason *string `json:"tax_exempt_reason,omitempty"`
ParentId Optional[int] `json:"parent_id"`
SalesforceId Optional[string] `json:"salesforce_id"`
}

func (c *tempCreateCustomer) validate() error {
Expand Down
13 changes: 12 additions & 1 deletion models/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ type Customer struct {
// The locale for the customer to identify language-region
Locale Optional[string] `json:"locale"`
DefaultSubscriptionGroupUid Optional[string] `json:"default_subscription_group_uid"`
// The Salesforce ID for the customer
SalesforceId Optional[string] `json:"salesforce_id"`
AdditionalProperties map[string]any `json:"_"`
}

Expand Down Expand Up @@ -257,6 +259,13 @@ func (c Customer) toMap() map[string]any {
structMap["default_subscription_group_uid"] = nil
}
}
if c.SalesforceId.IsValueSet() {
if c.SalesforceId.Value() != nil {
structMap["salesforce_id"] = c.SalesforceId.Value()
} else {
structMap["salesforce_id"] = nil
}
}
return structMap
}

Expand All @@ -268,7 +277,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")
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")
if err != nil {
return err
}
Expand Down Expand Up @@ -334,6 +343,7 @@ func (c *Customer) UnmarshalJSON(input []byte) error {
c.ParentId = temp.ParentId
c.Locale = temp.Locale
c.DefaultSubscriptionGroupUid = temp.DefaultSubscriptionGroupUid
c.SalesforceId = temp.SalesforceId
return nil
}

Expand Down Expand Up @@ -366,4 +376,5 @@ type tempCustomer struct {
ParentId Optional[int] `json:"parent_id"`
Locale Optional[string] `json:"locale"`
DefaultSubscriptionGroupUid Optional[string] `json:"default_subscription_group_uid"`
SalesforceId Optional[string] `json:"salesforce_id"`
}
13 changes: 12 additions & 1 deletion models/customer_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type CustomerAttributes struct {
Metafields map[string]string `json:"metafields,omitempty"`
// The parent ID in Chargify if applicable. Parent is another Customer object.
ParentId Optional[int] `json:"parent_id"`
// (Optional) The Salesforce ID of the customer.
SalesforceId Optional[string] `json:"salesforce_id"`
AdditionalProperties map[string]any `json:"_"`
}

Expand Down Expand Up @@ -123,6 +125,13 @@ func (c CustomerAttributes) toMap() map[string]any {
structMap["parent_id"] = nil
}
}
if c.SalesforceId.IsValueSet() {
if c.SalesforceId.Value() != nil {
structMap["salesforce_id"] = c.SalesforceId.Value()
} else {
structMap["salesforce_id"] = nil
}
}
return structMap
}

Expand All @@ -134,7 +143,7 @@ func (c *CustomerAttributes) UnmarshalJSON(input []byte) error {
if err != nil {
return err
}
additionalProperties, err := UnmarshalAdditionalProperties(input, "first_name", "last_name", "email", "cc_emails", "organization", "reference", "address", "address_2", "city", "state", "zip", "country", "phone", "verified", "tax_exempt", "vat_number", "metafields", "parent_id")
additionalProperties, err := UnmarshalAdditionalProperties(input, "first_name", "last_name", "email", "cc_emails", "organization", "reference", "address", "address_2", "city", "state", "zip", "country", "phone", "verified", "tax_exempt", "vat_number", "metafields", "parent_id", "salesforce_id")
if err != nil {
return err
}
Expand All @@ -158,6 +167,7 @@ func (c *CustomerAttributes) UnmarshalJSON(input []byte) error {
c.VatNumber = temp.VatNumber
c.Metafields = temp.Metafields
c.ParentId = temp.ParentId
c.SalesforceId = temp.SalesforceId
return nil
}

Expand All @@ -181,4 +191,5 @@ type tempCustomerAttributes struct {
VatNumber *string `json:"vat_number,omitempty"`
Metafields map[string]string `json:"metafields,omitempty"`
ParentId Optional[int] `json:"parent_id"`
SalesforceId Optional[string] `json:"salesforce_id"`
}
Loading

0 comments on commit 783a8d2

Please sign in to comment.