Skip to content

Commit

Permalink
Merge pull request #107 from VictorAvelar/rollback-structs-as-values
Browse files Browse the repository at this point in the history
Rollback structs as values
  • Loading branch information
VictorAvelar authored Nov 10, 2020
2 parents a7fb96c + 8075bed commit b9264ab
Show file tree
Hide file tree
Showing 26 changed files with 511 additions and 500 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ changelog:
sort: desc
filters:
exclude:
- "^docs"
- "^changelog"
- "Merge pull request^"
- ^docs
- ^changelog
- Merge pull request^
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## master

## v2.1.0

## Changed
- Rollback to use pointers inside struct tags as structs have no empty value
and thus the usage of values instead of pointers breaks most of the post requests.

## v2.0.2

### Fixed
- Normalized wording across structs

## v2.0.1

### Fixed
Expand Down
484 changes: 242 additions & 242 deletions docs/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/customers/customer.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func CreateCustomerPayment(cs *mollie.Customer, m *mollie.Client) {
var bt = mollie.BankTransfer

var p = mollie.Payment{
Amount: mollie.Amount{
Amount: &mollie.Amount{
Currency: "EUR",
Value: "10.12",
},
Expand Down
4 changes: 2 additions & 2 deletions examples/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func init() {
func CreateSubscription() {

newSubscription := &mollie.Subscription{
Amount: mollie.Amount{Currency: "EUR", Value: "25.00"},
Amount: &mollie.Amount{Currency: "EUR", Value: "25.00"},
Times: 4,
Interval: "3 months",
Description: "Quarterly payment",
Expand Down Expand Up @@ -58,7 +58,7 @@ func GetSubscription() {
func UpdateSubscription() {

updatedSubscription := &mollie.Subscription{
Amount: mollie.Amount{Currency: "EUR", Value: "10.00"},
Amount: &mollie.Amount{Currency: "EUR", Value: "10.00"},
}

sub, err := client.Subscriptions.Update(customerID, subscriptionID, updatedSubscription)
Expand Down
4 changes: 2 additions & 2 deletions mollie/app_fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package mollie

// ApplicationFee allows you to split a payment between a platform and connected merchant accounts.
type ApplicationFee struct {
Amount Amount `json:"amount,omitempty"`
Description string `json:"description,omitempty"`
Amount *Amount `json:"amount,omitempty"`
Description string `json:"description,omitempty"`
}
18 changes: 9 additions & 9 deletions mollie/captures.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ type CapturesService service

// CaptureLinks contains relevant links for a capture object
type CaptureLinks struct {
Self URL `json:"self,omitempty"`
Payment URL `json:"payment,omitempty"`
Shipment URL `json:"shipment,omitempty"`
Settlement URL `json:"settlement,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Self *URL `json:"self,omitempty"`
Payment *URL `json:"payment,omitempty"`
Shipment *URL `json:"shipment,omitempty"`
Settlement *URL `json:"settlement,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}

// Capture describes a single capture
Expand All @@ -25,20 +25,20 @@ type Capture struct {
Resource string `json:"resource,omitempty"`
ID string `json:"id,omitempty"`
Mode Mode `json:"mode,omitempty"`
Amount Amount `json:"amount,omitempty"`
SettlementAmount Amount `json:"settlementAmount,omitempty"`
Amount *Amount `json:"amount,omitempty"`
SettlementAmount *Amount `json:"settlementAmount,omitempty"`
PaymentID string `json:"paymentId,omitempty"`
ShipmentID string `json:"shipmentId,omitempty"`
SettlementID string `json:"settlementId,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
Links CaptureLinks `json:"links,omitempty"`
}

// CapturesList describes a list of captures
type CapturesList struct {
Count int `json:"count,omitempty"`
Embedded struct {
Captures []Capture
Captures []*Capture
} `json:"_embedded,omitempty"`
Links PaginationLinks `json:"_links,omitempty"`
}
Expand Down
16 changes: 8 additions & 8 deletions mollie/chargebacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ import (
type Chargeback struct {
Resource string `json:"resource,omitempty"`
ID string `json:"id,omitempty"`
Amount Amount `json:"amount,omitempty"`
SettlementAmount Amount `json:"settlementAmount,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
ReversedAt time.Time `json:"reversedAt,omitempty"`
Amount *Amount `json:"amount,omitempty"`
SettlementAmount *Amount `json:"settlementAmount,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
ReversedAt *time.Time `json:"reversedAt,omitempty"`
PaymentID string `json:"paymentId,omitempty"`
Links ChargebackLinks `json:"_links,omitempty"`
}

// ChargebackLinks describes all the possible links to be returned with
// a chargeback object.
type ChargebackLinks struct {
Self URL `json:"self,omitempty"`
Payment URL `json:"payment,omitempty"`
Settlement URL `json:"settlement,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Self *URL `json:"self,omitempty"`
Payment *URL `json:"payment,omitempty"`
Settlement *URL `json:"settlement,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}

// ChargebackOptions describes chargeback endpoint valid query string parameters.
Expand Down
4 changes: 2 additions & 2 deletions mollie/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,6 @@ const (

// Rate describes service rates, further divided into fixed and percentage costs.
type Rate struct {
Fixed Amount `json:"fixed,omitempty"`
Variable string `json:"variable,omitempty"`
Fixed *Amount `json:"fixed,omitempty"`
Variable string `json:"variable,omitempty"`
}
14 changes: 7 additions & 7 deletions mollie/customers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ type CustomersService service

// CustomerLinks contains the HAL resources for a customer response
type CustomerLinks struct {
Self URL `json:"self,omitempty"`
Mandates URL `json:"mandates,omitempty"`
Subscriptions URL `json:"subscriptions,omitempty"`
Payments URL `json:"payments,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Dashboard URL `json:"dashboard,omitempty"`
Self *URL `json:"self,omitempty"`
Mandates *URL `json:"mandates,omitempty"`
Subscriptions *URL `json:"subscriptions,omitempty"`
Payments *URL `json:"payments,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
Dashboard *URL `json:"dashboard,omitempty"`
}

// Customer represents buyers
Expand All @@ -31,7 +31,7 @@ type Customer struct {
Email string `json:"email,omitempty"`
Locale Locale `json:"locale,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
Links CustomerLinks `json:"_links,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions mollie/gift_cards.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ type GiftCardEnabled struct {

// GiftCardLinks are links embedded when a gift card is enabled.
type GiftCardLinks struct {
Self URL `json:"self,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Self *URL `json:"self,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}
16 changes: 8 additions & 8 deletions mollie/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type Invoice struct {
IssuedAt string `json:"issuedAt,omitempty"`
PaidAt string `json:"paidAt,omitempty"`
DueAt string `json:"dueAt,omitempty"`
NetAmount Amount `json:"netAmount,omitempty"`
VatAmount Amount `json:"vatAmount,omitempty"`
GrossAmount Amount `json:"grossAmount,omitempty"`
Lines []LineItem `json:"lines,omitempty"`
NetAmount *Amount `json:"netAmount,omitempty"`
VatAmount *Amount `json:"vatAmount,omitempty"`
GrossAmount *Amount `json:"grossAmount,omitempty"`
Lines []*LineItem `json:"lines,omitempty"`
Links InvoiceLinks `json:"_links,omitempty"`
}

Expand All @@ -41,15 +41,15 @@ type LineItem struct {
Description string `json:"description,omitempty"`
Count int64 `json:"count,omitempty"`
VatPercentage float64 `json:"vatPercentage,omitempty"`
Amount Amount `json:"amount,omitempty"`
Amount *Amount `json:"amount,omitempty"`
}

// InvoiceLinks describes all the possible links to be returned with
// a invoice object.
type InvoiceLinks struct {
Self URL `json:"self,omitempty"`
PDF URL `json:"pdf,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Self *URL `json:"self,omitempty"`
PDF *URL `json:"pdf,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}

// ListInvoiceOptions describes list invoices endpoint valid query string parameters.
Expand Down
26 changes: 13 additions & 13 deletions mollie/mandates.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ type Mandate struct {
ConsumerName string `json:"consumerName,omitempty"`
ConsumerAccount string `json:"consumerAccount,omitempty"`
ConsumerBic string `json:"consumerBic,omitempty"`
SignatureDate ShortDate `json:"signatureDate,omitempty"`
SignatureDate *ShortDate `json:"signatureDate,omitempty"`
MandateReference string `json:"mandateReference,omitempty"`
Mode Mode `json:"mode,omitempty"`
Status MandateStatus `json:"status,omitempty"`
CreatedAt time.Time `json:"createdAt,omitempty"`
CreatedAt *time.Time `json:"createdAt,omitempty"`
Details MandateDetails `json:"details,omitempty"`
Links MandateLinks `json:"_links,omitempty"`
}

// MandateDetails are possible values inside the mandate.details field
type MandateDetails struct {
ConsumerName string `json:"consumerName,omitempty"`
ConsumerAccount string `json:"consumerAccount,omitempty"`
ConsumerBic string `json:"consumerBic,omitempty"`
CardHolder string `json:"cardHolder,omitempty"`
CardNumber string `json:"cardNumber,omitempty"`
CardLabel CardLabel `json:"cardLabel,omitempty"`
CardFingerprint string `json:"cardFingerprint,omitempty"`
CardExpiryDate ShortDate `json:"cardExpiryDate,omitempty"`
ConsumerName string `json:"consumerName,omitempty"`
ConsumerAccount string `json:"consumerAccount,omitempty"`
ConsumerBic string `json:"consumerBic,omitempty"`
CardHolder string `json:"cardHolder,omitempty"`
CardNumber string `json:"cardNumber,omitempty"`
CardLabel CardLabel `json:"cardLabel,omitempty"`
CardFingerprint string `json:"cardFingerprint,omitempty"`
CardExpiryDate *ShortDate `json:"cardExpiryDate,omitempty"`
}

// MandateStatus for the Mandate object
Expand Down Expand Up @@ -73,9 +73,9 @@ type MandatesService service

// MandateLinks response objects
type MandateLinks struct {
Self URL `json:"self,omitempty"`
Customer URL `json:"customer,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Self *URL `json:"self,omitempty"`
Customer *URL `json:"customer,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}

// ListMandatesOptions contains valid query parameters
Expand Down
28 changes: 14 additions & 14 deletions mollie/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ import (

// PaymentMethodInfo describes a single method with details.
type PaymentMethodInfo struct {
Resource string `json:"resource,omitempty"`
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
MinimumAmount Amount `json:"minimumAmount,omitempty"`
MaximumAmount Amount `json:"maximumAmount,omitempty"`
Image Image `json:"image,omitempty"`
Pricing []PaymentMethodPricing `json:"pricing,omitempty"`
Links MethodsLinks `json:"_links,omitempty"`
Resource string `json:"resource,omitempty"`
ID string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
MinimumAmount *Amount `json:"minimumAmount,omitempty"`
MaximumAmount *Amount `json:"maximumAmount,omitempty"`
Image *Image `json:"image,omitempty"`
Pricing []*PaymentMethodPricing `json:"pricing,omitempty"`
Links MethodsLinks `json:"_links,omitempty"`
}

// MethodsLinks describes links attached to methods service responses.
type MethodsLinks struct {
Self URL `json:"self,omitempty"`
Documentation URL `json:"documentation,omitempty"`
Self *URL `json:"self,omitempty"`
Documentation *URL `json:"documentation,omitempty"`
}

// Image describes a generic image resource retrieved by Mollie.
Expand All @@ -36,16 +36,16 @@ type Image struct {
// PaymentMethodPricing contains information about commissions and fees
// applicable to a payment method.
type PaymentMethodPricing struct {
Description string `json:"description,omitempty"`
Fixed Amount `json:"fixed,omitempty"`
Variable string `json:"variable,omitempty"`
Description string `json:"description,omitempty"`
Fixed *Amount `json:"fixed,omitempty"`
Variable string `json:"variable,omitempty"`
}

// ListMethods describes a list of paginated payment methods.
type ListMethods struct {
Count int `json:"count,omitempty"`
Embedded struct {
Methods []PaymentMethodInfo
Methods []*PaymentMethodInfo
} `json:"_embedded,omitempty"`
Links PaginationLinks `json:"_links,omitempty"`
}
Expand Down
Loading

0 comments on commit b9264ab

Please sign in to comment.