From 0e17b7ba29c2603bdca31efb3d741f72ed027eb7 Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Mon, 2 Oct 2023 11:53:40 +0100
Subject: [PATCH 1/8] ci: only run workflow handle-release-pr-title-edit for
release PRs (#20)
---
.github/workflows/handle-release-pr-title-edit.yml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/handle-release-pr-title-edit.yml b/.github/workflows/handle-release-pr-title-edit.yml
index 9f3a7d6..caa0a96 100644
--- a/.github/workflows/handle-release-pr-title-edit.yml
+++ b/.github/workflows/handle-release-pr-title-edit.yml
@@ -9,8 +9,9 @@ jobs:
update_pr_content:
name: Update pull request content
if: |
- (github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) ||
- (github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version') &&
+ ((github.event.action == 'edited' && github.event.changes.title.from != github.event.pull_request.title) ||
+ (github.event.action == 'unlabeled' && github.event.label.name == 'autorelease: custom version')) &&
+ startsWith(github.event.pull_request.head.ref, 'release-please--') &&
github.event.pull_request.state == 'open' &&
github.event.sender.login != 'stainless-bot' &&
github.repository == 'Finch-API/finch-api-go'
From 485231744684360e93901208d92fc0ae78fd9586 Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Mon, 2 Oct 2023 17:47:56 -0400
Subject: [PATCH 2/8] test: use `TEST_API_BASE_URL` in tests (#22)
---
account_test.go | 17 +++++++++++----
client_test.go | 30 ++++++++++++++++++++++---
hrisbenefit_test.go | 41 ++++++++++++++++++++++++++---------
hrisbenefitindividual_test.go | 25 ++++++++++++++++-----
hriscompany_test.go | 9 ++++++--
hrisdirectory_test.go | 9 ++++++--
hrisemployment_test.go | 9 ++++++--
hrisindividual_test.go | 9 ++++++--
hrispayment_test.go | 9 ++++++--
hrispaystatement_test.go | 9 ++++++--
internal/testutil/testutil.go | 4 ++--
paginationauto_test.go | 9 ++++++--
paginationmanual_test.go | 9 ++++++--
provider_test.go | 9 ++++++--
usage_test.go | 9 ++++++--
15 files changed, 162 insertions(+), 45 deletions(-)
diff --git a/account_test.go b/account_test.go
index dabf5fc..4521167 100644
--- a/account_test.go
+++ b/account_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestAccountDisconnect(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.Account.Disconnect(context.TODO())
@@ -31,11 +36,15 @@ func TestAccountDisconnect(t *testing.T) {
}
func TestAccountIntrospect(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.Account.Introspect(context.TODO())
diff --git a/client_test.go b/client_test.go
index 5e7a384..495b688 100644
--- a/client_test.go
+++ b/client_test.go
@@ -6,16 +6,25 @@ import (
"context"
"fmt"
"net/http"
+ "os"
"testing"
"time"
finchgo "github.com/Finch-API/finch-api-go"
+ "github.com/Finch-API/finch-api-go/internal/testutil"
"github.com/Finch-API/finch-api-go/option"
)
func TestContextCancel(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
cancelCtx, cancel := context.WithCancel(context.Background())
@@ -35,8 +44,15 @@ func (t *neverTransport) RoundTrip(req *http.Request) (*http.Response, error) {
}
func TestContextCancelDelay(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
option.WithHTTPClient(&http.Client{Transport: &neverTransport{}}),
)
@@ -52,6 +68,14 @@ func TestContextCancelDelay(t *testing.T) {
}
func TestContextDeadline(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+
testTimeout := time.After(3 * time.Second)
testDone := make(chan bool)
@@ -61,7 +85,7 @@ func TestContextDeadline(t *testing.T) {
go func() {
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
option.WithHTTPClient(&http.Client{Transport: &neverTransport{}}),
)
diff --git a/hrisbenefit_test.go b/hrisbenefit_test.go
index 03d762c..ce335e6 100644
--- a/hrisbenefit_test.go
+++ b/hrisbenefit_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISBenefitNewWithOptionalParams(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.New(context.TODO(), finchgo.HRISBenefitNewParams{
@@ -35,11 +40,15 @@ func TestHRISBenefitNewWithOptionalParams(t *testing.T) {
}
func TestHRISBenefitGet(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.Get(context.TODO(), "string")
@@ -53,11 +62,15 @@ func TestHRISBenefitGet(t *testing.T) {
}
func TestHRISBenefitUpdateWithOptionalParams(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.Update(
@@ -77,11 +90,15 @@ func TestHRISBenefitUpdateWithOptionalParams(t *testing.T) {
}
func TestHRISBenefitList(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.List(context.TODO())
@@ -95,11 +112,15 @@ func TestHRISBenefitList(t *testing.T) {
}
func TestHRISBenefitListSupportedBenefits(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.ListSupportedBenefits(context.TODO())
diff --git a/hrisbenefitindividual_test.go b/hrisbenefitindividual_test.go
index 2e96b13..d89a44a 100644
--- a/hrisbenefitindividual_test.go
+++ b/hrisbenefitindividual_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISBenefitIndividualEnrolledIDs(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.Individuals.EnrolledIDs(context.TODO(), "string")
@@ -31,11 +36,15 @@ func TestHRISBenefitIndividualEnrolledIDs(t *testing.T) {
}
func TestHRISBenefitIndividualGetManyBenefitsWithOptionalParams(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.Individuals.GetManyBenefits(
@@ -55,11 +64,15 @@ func TestHRISBenefitIndividualGetManyBenefitsWithOptionalParams(t *testing.T) {
}
func TestHRISBenefitIndividualUnenrollManyWithOptionalParams(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Benefits.Individuals.UnenrollMany(
diff --git a/hriscompany_test.go b/hriscompany_test.go
index 5b7288f..0af22dd 100644
--- a/hriscompany_test.go
+++ b/hriscompany_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISCompanyGet(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Company.Get(context.TODO())
diff --git a/hrisdirectory_test.go b/hrisdirectory_test.go
index c18f1fe..eaebd2f 100644
--- a/hrisdirectory_test.go
+++ b/hrisdirectory_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISDirectoryListIndividualsWithOptionalParams(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Directory.ListIndividuals(context.TODO(), finchgo.HRISDirectoryListIndividualsParams{
diff --git a/hrisemployment_test.go b/hrisemployment_test.go
index f884ddc..d0ba3e6 100644
--- a/hrisemployment_test.go
+++ b/hrisemployment_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISEmploymentGetMany(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Employments.GetMany(context.TODO(), finchgo.HRISEmploymentGetManyParams{
diff --git a/hrisindividual_test.go b/hrisindividual_test.go
index b89d447..8c30917 100644
--- a/hrisindividual_test.go
+++ b/hrisindividual_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISIndividualGetManyWithOptionalParams(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Individuals.GetMany(context.TODO(), finchgo.HRISIndividualGetManyParams{
diff --git a/hrispayment_test.go b/hrispayment_test.go
index 3d74ac3..22b72e0 100644
--- a/hrispayment_test.go
+++ b/hrispayment_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
"time"
@@ -14,11 +15,15 @@ import (
)
func TestHRISPaymentList(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.Payments.List(context.TODO(), finchgo.HRISPaymentListParams{
diff --git a/hrispaystatement_test.go b/hrispaystatement_test.go
index f27f493..1271686 100644
--- a/hrispaystatement_test.go
+++ b/hrispaystatement_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestHRISPayStatementGetMany(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.HRIS.PayStatements.GetMany(context.TODO(), finchgo.HRISPayStatementGetManyParams{
diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go
index 5de39d6..e82e8d7 100644
--- a/internal/testutil/testutil.go
+++ b/internal/testutil/testutil.go
@@ -7,8 +7,8 @@ import (
"testing"
)
-func CheckTestServer(t *testing.T) bool {
- if _, err := http.Get("http://127.0.0.1:4010"); err != nil {
+func CheckTestServer(t *testing.T, url string) bool {
+ if _, err := http.Get(url); err != nil {
str := os.Getenv("SKIP_MOCK_TESTS")
skip, err := strconv.ParseBool(str)
if err != nil {
diff --git a/paginationauto_test.go b/paginationauto_test.go
index ef96b4b..1c1af0d 100644
--- a/paginationauto_test.go
+++ b/paginationauto_test.go
@@ -4,6 +4,7 @@ package finchgo_test
import (
"context"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -12,11 +13,15 @@ import (
)
func TestAutoPagination(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
iter := client.HRIS.Directory.ListIndividualsAutoPaging(context.TODO(), finchgo.HRISDirectoryListIndividualsParams{})
diff --git a/paginationmanual_test.go b/paginationmanual_test.go
index 4bb05e9..b29f012 100644
--- a/paginationmanual_test.go
+++ b/paginationmanual_test.go
@@ -4,6 +4,7 @@ package finchgo_test
import (
"context"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -12,11 +13,15 @@ import (
)
func TestManualPagination(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
page, err := client.HRIS.Directory.ListIndividuals(context.TODO(), finchgo.HRISDirectoryListIndividualsParams{})
diff --git a/provider_test.go b/provider_test.go
index d653da3..823c442 100644
--- a/provider_test.go
+++ b/provider_test.go
@@ -5,6 +5,7 @@ package finchgo_test
import (
"context"
"errors"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -13,11 +14,15 @@ import (
)
func TestProviderList(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
_, err := client.Providers.List(context.TODO())
diff --git a/usage_test.go b/usage_test.go
index 710fda8..1cfda3d 100644
--- a/usage_test.go
+++ b/usage_test.go
@@ -4,6 +4,7 @@ package finchgo_test
import (
"context"
+ "os"
"testing"
finchgo "github.com/Finch-API/finch-api-go"
@@ -12,11 +13,15 @@ import (
)
func TestUsage(t *testing.T) {
- if !testutil.CheckTestServer(t) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
return
}
client := finchgo.NewClient(
- option.WithBaseURL("http://127.0.0.1:4010"),
+ option.WithBaseURL(baseURL),
option.WithAccessToken("AccessToken"),
)
page, err := client.HRIS.Directory.ListIndividuals(context.TODO(), finchgo.HRISDirectoryListIndividualsParams{})
From 24b06e23bcfcaf13d5bdeae175348b71bdd0176d Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Mon, 2 Oct 2023 19:00:26 -0400
Subject: [PATCH 3/8] fix: prevent index out of range bug during
auto-pagination (#23)
---
hrisdirectory.go | 2 +-
internal/shared/pagination.go | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hrisdirectory.go b/hrisdirectory.go
index 8fc99d4..4c4199b 100644
--- a/hrisdirectory.go
+++ b/hrisdirectory.go
@@ -123,7 +123,7 @@ func (r *IndividualsPageAutoPager) Next() bool {
if r.idx >= len(r.page.Individuals) {
r.idx = 0
r.page, r.err = r.page.GetNextPage()
- if r.err != nil || r.page == nil {
+ if r.err != nil || r.page == nil || len(r.page.Individuals) == 0 {
return false
}
}
diff --git a/internal/shared/pagination.go b/internal/shared/pagination.go
index 320b355..c097f43 100644
--- a/internal/shared/pagination.go
+++ b/internal/shared/pagination.go
@@ -75,7 +75,7 @@ func (r *SinglePageAutoPager[T]) Next() bool {
if r.idx >= len(r.page.Items) {
r.idx = 0
r.page, r.err = r.page.GetNextPage()
- if r.err != nil || r.page == nil {
+ if r.err != nil || r.page == nil || len(r.page.Items) == 0 {
return false
}
}
@@ -163,7 +163,7 @@ func (r *ResponsesPageAutoPager[T]) Next() bool {
if r.idx >= len(r.page.Responses) {
r.idx = 0
r.page, r.err = r.page.GetNextPage()
- if r.err != nil || r.page == nil {
+ if r.err != nil || r.page == nil || len(r.page.Responses) == 0 {
return false
}
}
From f16872dc5025c7c6d88673f65a1b5a14a3fa3e65 Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Tue, 3 Oct 2023 10:38:12 -0400
Subject: [PATCH 4/8] feat(api): add `/forward` endpoint and other updates
(#25)
---
.stats.yml | 2 +-
api.md | 10 +++
client.go | 12 ++--
hris.go | 2 +-
hrisemployment.go | 5 +-
hrispaystatement.go | 2 +-
provider.go | 5 +-
requestforwarding.go | 132 ++++++++++++++++++++++++++++++++++++++
requestforwarding_test.go | 42 ++++++++++++
9 files changed, 201 insertions(+), 11 deletions(-)
create mode 100644 requestforwarding.go
create mode 100644 requestforwarding_test.go
diff --git a/.stats.yml b/.stats.yml
index 2d2fedb..a78b7ab 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1 +1 @@
-configured_endpoints: 18
+configured_endpoints: 19
diff --git a/api.md b/api.md
index d611d76..e6d59c4 100644
--- a/api.md
+++ b/api.md
@@ -139,3 +139,13 @@ Methods:
Custom Methods:
- VerifySignature
+
+# RequestForwarding
+
+Response Types:
+
+- finchgo.RequestForwardingForwardResponse
+
+Methods:
+
+- client.RequestForwarding.Forward(ctx context.Context, body finchgo.RequestForwardingForwardParams) (finchgo.RequestForwardingForwardResponse, error)
diff --git a/client.go b/client.go
index 42096b5..a486e32 100644
--- a/client.go
+++ b/client.go
@@ -12,11 +12,12 @@ import (
// interacting with the Finch API. You should not instantiate this client directly,
// and instead use the [NewClient] method instead.
type Client struct {
- Options []option.RequestOption
- HRIS *HRISService
- Providers *ProviderService
- Account *AccountService
- Webhooks *WebhookService
+ Options []option.RequestOption
+ HRIS *HRISService
+ Providers *ProviderService
+ Account *AccountService
+ Webhooks *WebhookService
+ RequestForwarding *RequestForwardingService
}
// NewClient generates a new client with the default option read from the
@@ -42,6 +43,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
r.Providers = NewProviderService(opts...)
r.Account = NewAccountService(opts...)
r.Webhooks = NewWebhookService(opts...)
+ r.RequestForwarding = NewRequestForwardingService(opts...)
return
}
diff --git a/hris.go b/hris.go
index 9ce81bb..c0c5b7b 100644
--- a/hris.go
+++ b/hris.go
@@ -122,7 +122,7 @@ func (r *Location) UnmarshalJSON(data []byte) (err error) {
type Money struct {
// Amount for money object (in cents)
- Amount int64 `json:"amount"`
+ Amount int64 `json:"amount,nullable"`
Currency string `json:"currency"`
JSON moneyJSON
}
diff --git a/hrisemployment.go b/hrisemployment.go
index efe4b17..9d65e6a 100644
--- a/hrisemployment.go
+++ b/hrisemployment.go
@@ -91,7 +91,9 @@ type EmploymentData struct {
// Note: This property is only available if enabled for your account. Please reach
// out to your Finch representative if you would like access.
PayGroupIDs []string `json:"pay_group_ids,nullable"`
- StartDate string `json:"start_date,nullable"`
+ // The source system's unique employment identifier for this individual
+ SourceID string `json:"source_id,nullable"`
+ StartDate string `json:"start_date,nullable"`
// The current title of the individual.
Title string `json:"title,nullable"`
// Note: This property is only available if enabled for your account. Please reach
@@ -119,6 +121,7 @@ type employmentDataJSON struct {
Manager apijson.Field
MiddleName apijson.Field
PayGroupIDs apijson.Field
+ SourceID apijson.Field
StartDate apijson.Field
Title apijson.Field
WorkID apijson.Field
diff --git a/hrispaystatement.go b/hrispaystatement.go
index cde9fc4..e038416 100644
--- a/hrispaystatement.go
+++ b/hrispaystatement.go
@@ -75,7 +75,7 @@ type PayStatement struct {
// The array of taxes objects associated with this pay statement.
Taxes []PayStatementTax `json:"taxes,nullable"`
// The number of hours worked for this pay period
- TotalHours int64 `json:"total_hours,nullable"`
+ TotalHours float64 `json:"total_hours,nullable"`
// The type of the payment associated with the pay statement.
Type PayStatementType `json:"type,nullable"`
JSON payStatementJSON
diff --git a/provider.go b/provider.go
index d9bc36f..d7e7fad 100644
--- a/provider.go
+++ b/provider.go
@@ -61,8 +61,9 @@ type Provider struct {
Icon string `json:"icon"`
// The url to the official logo of the payroll provider.
Logo string `json:"logo"`
- // Whether the Finch integration with this provider uses the Assisted Connect Flow
- // by default.
+ // [DEPRECATED] Whether the Finch integration with this provider uses the Assisted
+ // Connect Flow by default. This field is now deprecated. Please check for a `type`
+ // of `assisted` in the `authentication_methods` field instead.
Manual bool `json:"manual"`
// whether MFA is required for the provider.
MfaRequired bool `json:"mfa_required"`
diff --git a/requestforwarding.go b/requestforwarding.go
new file mode 100644
index 0000000..cb61b34
--- /dev/null
+++ b/requestforwarding.go
@@ -0,0 +1,132 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package finchgo
+
+import (
+ "context"
+ "net/http"
+
+ "github.com/Finch-API/finch-api-go/internal/apijson"
+ "github.com/Finch-API/finch-api-go/internal/param"
+ "github.com/Finch-API/finch-api-go/internal/requestconfig"
+ "github.com/Finch-API/finch-api-go/option"
+)
+
+// RequestForwardingService contains methods and other services that help with
+// interacting with the Finch API. Note, unlike clients, this service does not read
+// variables from the environment automatically. You should not instantiate this
+// service directly, and instead use the [NewRequestForwardingService] method
+// instead.
+type RequestForwardingService struct {
+ Options []option.RequestOption
+}
+
+// NewRequestForwardingService generates a new service that applies the given
+// options to each request. These options are applied after the parent client's
+// options (if there is one), and before any request-specific options.
+func NewRequestForwardingService(opts ...option.RequestOption) (r *RequestForwardingService) {
+ r = &RequestForwardingService{}
+ r.Options = opts
+ return
+}
+
+// The Forward API allows you to make direct requests to an employment system.
+func (r *RequestForwardingService) Forward(ctx context.Context, body RequestForwardingForwardParams, opts ...option.RequestOption) (res *RequestForwardingForwardResponse, err error) {
+ opts = append(r.Options[:], opts...)
+ path := "forward"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return
+}
+
+type RequestForwardingForwardResponse struct {
+ // A string representation of the HTTP response body of the forwarded request’s
+ // response received from the underlying integration’s API. This field may be null
+ // in the case where the upstream system’s response is empty.
+ Data string `json:"data,required,nullable"`
+ // The HTTP headers of the forwarded request’s response, exactly as received from
+ // the underlying integration’s API.
+ Headers interface{} `json:"headers,required,nullable"`
+ // An object containing details of your original forwarded request, for your ease
+ // of reference.
+ Request RequestForwardingForwardResponseRequest `json:"request,required"`
+ // The HTTP status code of the forwarded request’s response, exactly received from
+ // the underlying integration’s API. This value will be returned as an integer.
+ StatusCode int64 `json:"statusCode,required"`
+ JSON requestForwardingForwardResponseJSON
+}
+
+// requestForwardingForwardResponseJSON contains the JSON metadata for the struct
+// [RequestForwardingForwardResponse]
+type requestForwardingForwardResponseJSON struct {
+ Data apijson.Field
+ Headers apijson.Field
+ Request apijson.Field
+ StatusCode apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RequestForwardingForwardResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+// An object containing details of your original forwarded request, for your ease
+// of reference.
+type RequestForwardingForwardResponseRequest struct {
+ // The body that was specified for the forwarded request. If a value was not
+ // specified in the original request, this value will be returned as null ;
+ // otherwise, this value will always be returned as a string.
+ Data string `json:"data,required,nullable"`
+ // The specified HTTP headers that were included in the forwarded request. If no
+ // headers were specified, this will be returned as `null`.
+ Headers interface{} `json:"headers,required,nullable"`
+ // The HTTP method that was specified for the forwarded request. Valid values
+ // include: `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`.
+ Method string `json:"method,required"`
+ // The query parameters that were included in the forwarded request. If no query
+ // parameters were specified, this will be returned as `null`.
+ Params interface{} `json:"params,required,nullable"`
+ // The URL route path that was specified for the forwarded request.
+ Route string `json:"route,required"`
+ JSON requestForwardingForwardResponseRequestJSON
+}
+
+// requestForwardingForwardResponseRequestJSON contains the JSON metadata for the
+// struct [RequestForwardingForwardResponseRequest]
+type requestForwardingForwardResponseRequestJSON struct {
+ Data apijson.Field
+ Headers apijson.Field
+ Method apijson.Field
+ Params apijson.Field
+ Route apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *RequestForwardingForwardResponseRequest) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+type RequestForwardingForwardParams struct {
+ // The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
+ // , `PUT` , `DELETE` , and `PATCH`.
+ Method param.Field[string] `json:"method,required"`
+ // The URL route path for the forwarded request. This value must begin with a
+ // forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
+ // underscores.
+ Route param.Field[string] `json:"route,required"`
+ // The body for the forwarded request. This value must be specified as either a
+ // string or a valid JSON object.
+ Data param.Field[string] `json:"data"`
+ // The HTTP headers to include on the forwarded request. This value must be
+ // specified as an object of key-value pairs. Example:
+ // `{"Content-Type": "application/xml", "X-API-Version": "v1" }`
+ Headers param.Field[interface{}] `json:"headers"`
+ // The query parameters for the forwarded request. This value must be specified as
+ // a valid JSON object rather than a query string.
+ Params param.Field[interface{}] `json:"params"`
+}
+
+func (r RequestForwardingForwardParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
diff --git a/requestforwarding_test.go b/requestforwarding_test.go
new file mode 100644
index 0000000..65bbaa5
--- /dev/null
+++ b/requestforwarding_test.go
@@ -0,0 +1,42 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package finchgo_test
+
+import (
+ "context"
+ "errors"
+ "os"
+ "testing"
+
+ finchgo "github.com/Finch-API/finch-api-go"
+ "github.com/Finch-API/finch-api-go/internal/testutil"
+ "github.com/Finch-API/finch-api-go/option"
+)
+
+func TestRequestForwardingForwardWithOptionalParams(t *testing.T) {
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := finchgo.NewClient(
+ option.WithBaseURL(baseURL),
+ option.WithAccessToken("AccessToken"),
+ )
+ _, err := client.RequestForwarding.Forward(context.TODO(), finchgo.RequestForwardingForwardParams{
+ Method: finchgo.F("string"),
+ Route: finchgo.F("string"),
+ Data: finchgo.F("string"),
+ Headers: finchgo.F[any](map[string]interface{}{}),
+ Params: finchgo.F[any](map[string]interface{}{}),
+ })
+ if err != nil {
+ var apierr *finchgo.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
From 0dd63e219897c5dce9fd26d2aa7380979c9aeb4c Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Tue, 3 Oct 2023 13:08:07 -0400
Subject: [PATCH 5/8] chore(docs): adjust some docstrings (#26)
---
provider.go | 5 ++---
requestforwarding.go | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/provider.go b/provider.go
index d7e7fad..d9bc36f 100644
--- a/provider.go
+++ b/provider.go
@@ -61,9 +61,8 @@ type Provider struct {
Icon string `json:"icon"`
// The url to the official logo of the payroll provider.
Logo string `json:"logo"`
- // [DEPRECATED] Whether the Finch integration with this provider uses the Assisted
- // Connect Flow by default. This field is now deprecated. Please check for a `type`
- // of `assisted` in the `authentication_methods` field instead.
+ // Whether the Finch integration with this provider uses the Assisted Connect Flow
+ // by default.
Manual bool `json:"manual"`
// whether MFA is required for the provider.
MfaRequired bool `json:"mfa_required"`
diff --git a/requestforwarding.go b/requestforwarding.go
index cb61b34..35af12e 100644
--- a/requestforwarding.go
+++ b/requestforwarding.go
@@ -81,7 +81,7 @@ type RequestForwardingForwardResponseRequest struct {
// headers were specified, this will be returned as `null`.
Headers interface{} `json:"headers,required,nullable"`
// The HTTP method that was specified for the forwarded request. Valid values
- // include: `GET` , `POST` , `PUT` , `DELETE` , and `PATCH`.
+ // include: `GET`, `POST`, `PUT` , `DELETE`, and `PATCH`.
Method string `json:"method,required"`
// The query parameters that were included in the forwarded request. If no query
// parameters were specified, this will be returned as `null`.
From 13f64a3dd1124e7c54f7def4e96df55b41c8c26a Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Tue, 3 Oct 2023 13:50:35 -0400
Subject: [PATCH 6/8] chore(tests): update test examples (#27)
---
requestforwarding_test.go | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/requestforwarding_test.go b/requestforwarding_test.go
index 65bbaa5..dd4af31 100644
--- a/requestforwarding_test.go
+++ b/requestforwarding_test.go
@@ -26,11 +26,16 @@ func TestRequestForwardingForwardWithOptionalParams(t *testing.T) {
option.WithAccessToken("AccessToken"),
)
_, err := client.RequestForwarding.Forward(context.TODO(), finchgo.RequestForwardingForwardParams{
- Method: finchgo.F("string"),
- Route: finchgo.F("string"),
- Data: finchgo.F("string"),
- Headers: finchgo.F[any](map[string]interface{}{}),
- Params: finchgo.F[any](map[string]interface{}{}),
+ Method: finchgo.F("POST"),
+ Route: finchgo.F("/people/search"),
+ Data: finchgo.Null[string](),
+ Headers: finchgo.F[any](map[string]interface{}{
+ "content-type": "application/json",
+ }),
+ Params: finchgo.F[any](map[string]interface{}{
+ "showInactive": true,
+ "humanReadable": true,
+ }),
})
if err != nil {
var apierr *finchgo.Error
From 23fa6ecd1e5633600590d0cea21c8f08eb1fa1f0 Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Tue, 3 Oct 2023 13:57:06 -0400
Subject: [PATCH 7/8] chore(docs): adjust some docstrings (#28)
---
requestforwarding.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/requestforwarding.go b/requestforwarding.go
index 35af12e..555e462 100644
--- a/requestforwarding.go
+++ b/requestforwarding.go
@@ -108,8 +108,8 @@ func (r *RequestForwardingForwardResponseRequest) UnmarshalJSON(data []byte) (er
}
type RequestForwardingForwardParams struct {
- // The HTTP method for the forwarded request. Valid values include: `GET` , `POST`
- // , `PUT` , `DELETE` , and `PATCH`.
+ // The HTTP method for the forwarded request. Valid values include: `GET`, `POST`,
+ // `PUT`, `DELETE`, and `PATCH`.
Method param.Field[string] `json:"method,required"`
// The URL route path for the forwarded request. This value must begin with a
// forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and
From 67c250c3faa20df9e9dda2e8a8751c223678262a Mon Sep 17 00:00:00 2001
From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com>
Date: Tue, 3 Oct 2023 13:57:17 -0400
Subject: [PATCH 8/8] release: 0.0.5
---
.release-please-manifest.json | 2 +-
CHANGELOG.md | 20 ++++++++++++++++++++
README.md | 2 +-
internal/version.go | 2 +-
4 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 2ed3b71..944189a 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.0.4"
+ ".": "0.0.5"
}
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 160e61c..631c768 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,25 @@
# Changelog
+## 0.0.5 (2023-10-03)
+
+Full Changelog: [v0.0.4...v0.0.5](https://github.com/Finch-API/finch-api-go/compare/v0.0.4...v0.0.5)
+
+### Features
+
+* **api:** add `/forward` endpoint and other updates ([#25](https://github.com/Finch-API/finch-api-go/issues/25)) ([f16872d](https://github.com/Finch-API/finch-api-go/commit/f16872dc5025c7c6d88673f65a1b5a14a3fa3e65))
+
+
+### Bug Fixes
+
+* prevent index out of range bug during auto-pagination ([#23](https://github.com/Finch-API/finch-api-go/issues/23)) ([24b06e2](https://github.com/Finch-API/finch-api-go/commit/24b06e23bcfcaf13d5bdeae175348b71bdd0176d))
+
+
+### Chores
+
+* **docs:** adjust some docstrings ([#26](https://github.com/Finch-API/finch-api-go/issues/26)) ([0dd63e2](https://github.com/Finch-API/finch-api-go/commit/0dd63e219897c5dce9fd26d2aa7380979c9aeb4c))
+* **docs:** adjust some docstrings ([#28](https://github.com/Finch-API/finch-api-go/issues/28)) ([23fa6ec](https://github.com/Finch-API/finch-api-go/commit/23fa6ecd1e5633600590d0cea21c8f08eb1fa1f0))
+* **tests:** update test examples ([#27](https://github.com/Finch-API/finch-api-go/issues/27)) ([13f64a3](https://github.com/Finch-API/finch-api-go/commit/13f64a3dd1124e7c54f7def4e96df55b41c8c26a))
+
## 0.0.4 (2023-09-26)
Full Changelog: [v0.0.3...v0.0.4](https://github.com/Finch-API/finch-api-go/compare/v0.0.3...v0.0.4)
diff --git a/README.md b/README.md
index 5cb2410..69050e2 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Or to pin the version:
```sh
-go get -u 'github.com/Finch-API/finch-api-go@v0.0.4'
+go get -u 'github.com/Finch-API/finch-api-go@v0.0.5'
```
diff --git a/internal/version.go b/internal/version.go
index e0649b4..1d49a30 100644
--- a/internal/version.go
+++ b/internal/version.go
@@ -2,4 +2,4 @@
package internal
-const PackageVersion = "0.0.4" // x-release-please-version
+const PackageVersion = "0.0.5" // x-release-please-version