Skip to content

v2.0.0

Latest
Compare
Choose a tag to compare
@niteshsandal-merge niteshsandal-merge released this 01 Jul 00:48
ac6a825

Merge Go SDK Release Notes - Version [2.0.0]

This release includes support for all of the latest updates as of June 10th to the Merge API. For more information, see https://www.merge.dev/changelog/week-2-june-2025

Breaking Changes:

  • Client initialization:
    You must now explicitly set the base URL using option.WithBaseURL, selecting from the environments defined in environments.go. Here's an example below:
Production:   "https://api.merge.dev/api",
ProductionEu: "https://api-eu.merge.dev/api",
import (
    "context"
    "fmt"
    "log"
    merge "github.com/merge-api/merge-go-client/v2"
    mergeclient "github.com/merge-api/merge-go-client/v2/client"
    "github.com/merge-api/merge-go-client/v2/option"

)
token := merge.String("Your account token")
client := mergeclient.NewClient(
        option.WithApiKey("Your API key"),
        option.WithAccountToken(token),
        option.WithBaseURL(merge.Environments.Production),

 )


  • Expand Query Params:
    Previously a comma separated string was used for multiple enums. Now users will pass in a list of enums, then the SDK will pass them into the request correctly. Here's an example below:
import (
    "context"
    "fmt"
    "log"
    merge "github.com/merge-api/merge-go-client/v2"
    mergeclient "github.com/merge-api/merge-go-client/v2/client"
    "github.com/merge-api/merge-go-client/v2/accounting"
    "github.com/merge-api/merge-go-client/v2/option"

)

token := merge.String("Your account token")
client := mergeclient.NewClient(
        option.WithApiKey("Your API key"),
        option.WithAccountToken(token),
        option.WithBaseURL(merge.Environments.Production),

 )

expandFields := []*accounting.InvoicesListRequestExpandItem{
  accounting.InvoicesListRequestExpandItemEmployee.Ptr(),
  accounting.InvoicesListRequestExpandItemAccountingPeriod.Ptr(),
  accounting.InvoicesListRequestExpandItemAppliedPayments.Ptr(),
}

req := &accounting.InvoicesListRequest{
    Expand: expandFields,
}
// paginate the response
ctx := context.TODO()
page, err := client.Accounting.Invoices.List(ctx, req)
if err != nil {
    log.Fatalf("failed to list invoices: %v", err)
}
    
total := 0
    for page != nil {
        fmt.Printf("Received %d invoices\n", len(page.Results))
        for _, invoice := range page.Results {
            fmt.Printf("Invoice ID: %v\n", invoice.Id)
            total++
        }
        // Try to get the next page
        nextPage, err := page.GetNextPage(ctx)
        if err != nil {
            // If it's core.ErrNoPages, we're done
            break
        }
        page = nextPage
    }