Skip to content

Commit

Permalink
Merge pull request #354 from VictorAvelar/review-struct-naming-consis…
Browse files Browse the repository at this point in the history
…tency

ensure naming consistency across resources
  • Loading branch information
VictorAvelar authored Mar 16, 2024
2 parents 013a6af + 1a6e703 commit 57c3d82
Show file tree
Hide file tree
Showing 25 changed files with 442 additions and 446 deletions.
590 changes: 294 additions & 296 deletions docs/README.md

Large diffs are not rendered by default.

34 changes: 16 additions & 18 deletions mollie/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ import (
"time"
)

// BalancesService allows you to retrieve real-time as well as historical
// information about your Mollie balance.
//
// Works with Organization access tokens and App access tokens.
//
// The API is in **BETA** so be careful and expect changes.
//
// See: https://docs.mollie.com/reference/v2/balances-api/overview
type BalancesService service

// BalanceStatus reflects whether a balance is operational or not.
type BalanceStatus string

Expand Down Expand Up @@ -83,9 +73,9 @@ type BalancesList struct {
Links PaginationLinks `json:"_links,omitempty"`
}

// BalanceListOptions contains valid query parameters
// ListBalancesOptions contains valid query parameters
// for the list balances endpoint.
type BalanceListOptions struct {
type ListBalancesOptions struct {
Currency string `url:"currency,omitempty"`
From string `url:"from,omitempty"`
Limit int `url:"limit,omitempty"`
Expand Down Expand Up @@ -217,13 +207,21 @@ type BalanceTransactionsList struct {
Links PaginationLinks `json:"_links,omitempty"`
}

// BalanceTransactionsListOptions are valid query parameters for list
// ListBalanceTransactionsOptions are valid query parameters for list
// balance transactions requests.
type BalanceTransactionsListOptions struct {
type ListBalanceTransactionsOptions struct {
From string `url:"from,omitempty"`
Limit int `url:"limit,omitempty"`
}

// BalancesService allows you to retrieve real-time as well as historical
// information about your Mollie balance.
//
// Works with Organization access tokens and App access tokens.
//
// See: https://docs.mollie.com/reference/v2/balances-api/overview
type BalancesService service

// GetBalance retrieves a balance by its id.
//
// See: https://docs.mollie.com/reference/v2/balances-api/get-balance
Expand All @@ -245,7 +243,7 @@ func (bs *BalancesService) Primary(ctx context.Context) (res *Response, b *Balan
// balance, ordered from newest to oldest.
//
// See: https://docs.mollie.com/reference/v2/balances-api/list-balances
func (bs *BalancesService) List(ctx context.Context, options *BalanceListOptions) (
func (bs *BalancesService) List(ctx context.Context, options *ListBalancesOptions) (
res *Response,
bl *BalancesList,
err error,
Expand Down Expand Up @@ -282,7 +280,7 @@ func (bs *BalancesService) GetPrimaryReport(ctx context.Context, options *Balanc
func (bs *BalancesService) GetTransactionsList(
ctx context.Context,
balance string,
options *BalanceTransactionsListOptions,
options *ListBalanceTransactionsOptions,
) (
res *Response,
btl *BalanceTransactionsList,
Expand All @@ -295,7 +293,7 @@ func (bs *BalancesService) GetTransactionsList(
// primary balance of the account.
//
// See: https://docs.mollie.com/reference/v2/balances-api/list-primary-balance-transactions
func (bs *BalancesService) GetPrimaryTransactionsList(ctx context.Context, options *BalanceTransactionsListOptions) (
func (bs *BalancesService) GetPrimaryTransactionsList(ctx context.Context, options *ListBalanceTransactionsOptions) (
res *Response,
btl *BalanceTransactionsList,
err error,
Expand Down Expand Up @@ -357,7 +355,7 @@ func (bs *BalancesService) getReport(
func (bs *BalancesService) listTransactions(
ctx context.Context,
balance string,
options *BalanceTransactionsListOptions,
options *ListBalanceTransactionsOptions,
) (res *Response, btl *BalanceTransactionsList, err error) {
u := fmt.Sprintf("v2/balances/%s/transactions", balance)

Expand Down
6 changes: 3 additions & 3 deletions mollie/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func TestBalancesService_List(t *testing.T) {

type args struct {
ctx context.Context
options *BalanceListOptions
options *ListBalancesOptions
}

cases := []struct {
Expand Down Expand Up @@ -515,7 +515,7 @@ func TestBalancesService_ListBalanceTransactions(t *testing.T) {
type args struct {
ctx context.Context
balance string
options *BalanceTransactionsListOptions
options *ListBalanceTransactionsOptions
}

cases := []struct {
Expand Down Expand Up @@ -619,7 +619,7 @@ func TestBalancesService_ListPrimaryBalanceTransactions(t *testing.T) {

type args struct {
ctx context.Context
options *BalanceTransactionsListOptions
options *ListBalanceTransactionsOptions
}

cases := []struct {
Expand Down
8 changes: 4 additions & 4 deletions mollie/chargebacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ type ChargebackOptions struct {
Embed []EmbedValue `url:"embed,omitempty"`
}

// ChargebacksListOptions describes list chargebacks endpoint valid query string parameters.
type ChargebacksListOptions struct {
// ListChargebacksOptions describes list chargebacks endpoint valid query string parameters.
type ListChargebacksOptions struct {
From string `url:"from,omitempty"`
Limit int `url:"limit,omitempty"`
Include []IncludeValue `url:"include,omitempty"`
Expand Down Expand Up @@ -95,7 +95,7 @@ func (cs *ChargebacksService) Get(ctx context.Context, payment, chargeback strin
// List retrieves a list of chargebacks associated with your account/organization.
//
// See: https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks
func (cs *ChargebacksService) List(ctx context.Context, options *ChargebacksListOptions) (
func (cs *ChargebacksService) List(ctx context.Context, options *ListChargebacksOptions) (
res *Response,
cl *ChargebacksList,
err error,
Expand All @@ -106,7 +106,7 @@ func (cs *ChargebacksService) List(ctx context.Context, options *ChargebacksList
// ListForPayment retrieves a list of chargebacks associated with a single payment.
//
// See: https://docs.mollie.com/reference/v2/chargebacks-api/list-chargebacks
func (cs *ChargebacksService) ListForPayment(ctx context.Context, payment string, options *ChargebacksListOptions) (
func (cs *ChargebacksService) ListForPayment(ctx context.Context, payment string, options *ListChargebacksOptions) (
res *Response,
cl *ChargebacksList,
err error,
Expand Down
8 changes: 4 additions & 4 deletions mollie/chargebacks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestChargebacksService_List(t *testing.T) {

type args struct {
ctx context.Context
options *ChargebacksListOptions
options *ListChargebacksOptions
}

noPre := func() {}
Expand Down Expand Up @@ -173,7 +173,7 @@ func TestChargebacksService_List(t *testing.T) {
"list chargebacks with options",
args{
context.Background(),
&ChargebacksListOptions{
&ListChargebacksOptions{
ProfileID: "pfl_QkEhN94Ba",
},
},
Expand Down Expand Up @@ -253,7 +253,7 @@ func TestChargebacksService_ListForPayment(t *testing.T) {
type args struct {
ctx context.Context
payment string
options *ChargebacksListOptions
options *ListChargebacksOptions
}

cases := []struct {
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestChargebacksService_ListForPayment(t *testing.T) {
args{
context.Background(),
"tr_WDqYK6vllg",
&ChargebacksListOptions{
&ListChargebacksOptions{
ProfileID: "pfl_QkEhN94Ba",
},
},
Expand Down
8 changes: 4 additions & 4 deletions mollie/customers.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type Customer struct {
Links CustomerLinks `json:"_links,omitempty"`
}

// CustomersListOptions contains valid query parameters for the list customers endpoint.
type CustomersListOptions struct {
// ListCustomersOptions contains valid query parameters for the list customers endpoint.
type ListCustomersOptions struct {
From string `url:"from,omitempty"`
Limit int `url:"limit,omitempty"`
ProfileID string `url:"profileId,omitempty"`
Expand Down Expand Up @@ -144,7 +144,7 @@ func (cs *CustomersService) Delete(ctx context.Context, id string) (res *Respons
// List retrieves all customers created.
//
// See: https://docs.mollie.com/reference/v2/customers-api/list-customers
func (cs *CustomersService) List(ctx context.Context, options *CustomersListOptions) (
func (cs *CustomersService) List(ctx context.Context, options *ListCustomersOptions) (
res *Response,
cl *CustomersList,
err error,
Expand All @@ -164,7 +164,7 @@ func (cs *CustomersService) List(ctx context.Context, options *CustomersListOpti
// GetPayments retrieves all payments linked to the customer.
//
// See: https://docs.mollie.com/reference/v2/customers-api/list-customer-payments
func (cs *CustomersService) GetPayments(ctx context.Context, id string, options *CustomersListOptions) (
func (cs *CustomersService) GetPayments(ctx context.Context, id string, options *ListCustomersOptions) (
res *Response,
pl *PaymentList,
err error,
Expand Down
14 changes: 7 additions & 7 deletions mollie/customers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func TestCustomersService_List(t *testing.T) {
defer unsetEnv()
type args struct {
ctx context.Context
options *CustomersListOptions
options *ListCustomersOptions
}

cases := []struct {
Expand All @@ -319,7 +319,7 @@ func TestCustomersService_List(t *testing.T) {
http.StatusAccepted,
args{
context.Background(),
&CustomersListOptions{
&ListCustomersOptions{
SequenceType: OneOffSequence,
},
},
Expand Down Expand Up @@ -373,7 +373,7 @@ func TestCustomersService_List(t *testing.T) {
http.StatusInternalServerError,
args{
context.Background(),
&CustomersListOptions{
&ListCustomersOptions{
SequenceType: OneOffSequence,
},
},
Expand All @@ -387,7 +387,7 @@ func TestCustomersService_List(t *testing.T) {
http.StatusInternalServerError,
args{
context.Background(),
&CustomersListOptions{
&ListCustomersOptions{
SequenceType: OneOffSequence,
},
},
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestCustomerService_GetPayments(t *testing.T) {
type args struct {
ctx context.Context
customer string
options *CustomersListOptions
options *ListCustomersOptions
}

cases := []struct {
Expand Down Expand Up @@ -542,7 +542,7 @@ func TestCustomerService_GetPayments(t *testing.T) {
args{
context.Background(),
"cst_kEn1PlbGa",
&CustomersListOptions{Limit: 100},
&ListCustomersOptions{Limit: 100},
},
false,
nil,
Expand All @@ -562,7 +562,7 @@ func TestCustomerService_GetPayments(t *testing.T) {
args{
context.Background(),
"cst_kEn1PlbGa",
&CustomersListOptions{SequenceType: RecurringSequence},
&ListCustomersOptions{SequenceType: RecurringSequence},
},
true,
fmt.Errorf("500 Internal Server Error: An internal server error occurred while processing your request."),
Expand Down
6 changes: 3 additions & 3 deletions mollie/invoices.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ type InvoiceLinks struct {
Documentation *URL `json:"documentation,omitempty"`
}

// InvoicesListOptions describes list invoices endpoint valid query string parameters.
type InvoicesListOptions struct {
// ListInvoicesOptions describes list invoices endpoint valid query string parameters.
type ListInvoicesOptions struct {
Limit int64 `url:"limit,omitempty"`
Reference string `url:"reference,omitempty"`
Year string `url:"year,omitempty"`
Expand Down Expand Up @@ -87,7 +87,7 @@ func (is *InvoicesService) Get(ctx context.Context, id string) (res *Response, i
}

// List retrieves a list of invoices associated with your account/organization.
func (is *InvoicesService) List(ctx context.Context, options *InvoicesListOptions) (
func (is *InvoicesService) List(ctx context.Context, options *ListInvoicesOptions) (
res *Response,
il *InvoicesList,
err error,
Expand Down
6 changes: 3 additions & 3 deletions mollie/invoices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestInvoicesService_Get(t *testing.T) {
type args struct {
ctx context.Context
invoice string
options *InvoicesListOptions
options *ListInvoicesOptions
}

cases := []struct {
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestInvoicesService_List(t *testing.T) {
type args struct {
ctx context.Context
invoice string
options *InvoicesListOptions
options *ListInvoicesOptions
}

cases := []struct {
Expand Down Expand Up @@ -154,7 +154,7 @@ func TestInvoicesService_List(t *testing.T) {
args{
context.Background(),
"inv_xBEbP9rvAq",
&InvoicesListOptions{
&ListInvoicesOptions{
Year: strconv.Itoa(time.Now().Year()),
},
},
Expand Down
6 changes: 3 additions & 3 deletions mollie/mandates.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ type MandateLinks struct {
Documentation *URL `json:"documentation,omitempty"`
}

// MandatesListOptions contains valid query parameters
// ListMandatesOptions contains valid query parameters
// to filter the List mandates actions.
//
// From is a mandate id to offset from (inclusive)
// Limit is the max number of mandates to retrieve.
type MandatesListOptions struct {
type ListMandatesOptions struct {
Limit int `url:"limit,omitempty"`
From string `url:"from,omitempty"`
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func (ms *MandatesService) Revoke(ctx context.Context, customer, mandate string)
// ordered from newest to oldest.
//
// See: https://docs.mollie.com/reference/v2/mandates-api/list-mandates
func (ms *MandatesService) List(ctx context.Context, customer string, options *MandatesListOptions) (
func (ms *MandatesService) List(ctx context.Context, customer string, options *ListMandatesOptions) (
res *Response,
ml *MandatesList,
err error,
Expand Down
4 changes: 2 additions & 2 deletions mollie/mandates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func TestMandatesService_List(t *testing.T) {

type args struct {
ctx context.Context
options *MandatesListOptions
options *ListMandatesOptions
customer string
}

Expand Down Expand Up @@ -359,7 +359,7 @@ func TestMandatesService_List(t *testing.T) {
"list mandates with options works as expected.",
args{
context.Background(),
&MandatesListOptions{
&ListMandatesOptions{
Limit: 10,
},
"cst_4qqhO89gsT",
Expand Down
Loading

0 comments on commit 57c3d82

Please sign in to comment.