Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(api)!: remove post /webhooks/account_holders endpoint #133

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 90
configured_endpoints: 89
417 changes: 335 additions & 82 deletions accountholder.go

Large diffs are not rendered by default.

20 changes: 0 additions & 20 deletions accountholder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,6 @@ func TestAccountHolderUpdateWithOptionalParams(t *testing.T) {
}
}

func TestAccountHolderNewWebhook(t *testing.T) {
if !testutil.CheckTestServer(t) {
return
}
client := lithic.NewClient(
option.WithBaseURL("http://127.0.0.1:4010"),
option.WithAPIKey("APIKey"),
)
_, err := client.AccountHolders.NewWebhook(context.TODO(), lithic.AccountHolderNewWebhookParams{
URL: lithic.F("string"),
})
if err != nil {
var apierr *lithic.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
}

func TestAccountHolderListDocuments(t *testing.T) {
if !testutil.CheckTestServer(t) {
return
Expand Down
3 changes: 3 additions & 0 deletions aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (

type Error = apierror.Error

// This is an alias to an internal type.
type Address = shared.Address

// This is an alias to an internal type.
type AddressParam = shared.AddressParam

Expand Down
6 changes: 4 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go/internal/shared#CarrierParam">CarrierParam</a>
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go/internal/shared#ShippingAddressParam">ShippingAddressParam</a>

# Shared Response Types

- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go/internal/shared">shared</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go/internal/shared#Address">Address</a>

# lithic

Response Types:
Expand Down Expand Up @@ -33,15 +37,13 @@ Response Types:
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolder">AccountHolder</a>
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderDocument">AccountHolderDocument</a>
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderUpdateResponse">AccountHolderUpdateResponse</a>
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderNewWebhookResponse">AccountHolderNewWebhookResponse</a>
- <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderListDocumentsResponse">AccountHolderListDocumentsResponse</a>

Methods:

- <code title="post /account_holders">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderNewParams">AccountHolderNewParams</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolder">AccountHolder</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /account_holders/{account_holder_token}">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountHolderToken <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolder">AccountHolder</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /account_holders/{account_holder_token}">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountHolderToken <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderUpdateParams">AccountHolderUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderUpdateResponse">AccountHolderUpdateResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /webhooks/account_holders">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.NewWebhook">NewWebhook</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, body <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderNewWebhookParams">AccountHolderNewWebhookParams</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderNewWebhookResponse">AccountHolderNewWebhookResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /account_holders/{account_holder_token}/documents">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.ListDocuments">ListDocuments</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountHolderToken <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderListDocumentsResponse">AccountHolderListDocumentsResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /account_holders/{account_holder_token}/resubmit">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.Resubmit">Resubmit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountHolderToken <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderResubmitParams">AccountHolderResubmitParams</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolder">AccountHolder</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /account_holders/{account_holder_token}/documents/{document_token}">client.AccountHolders.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderService.GetDocument">GetDocument</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountHolderToken <a href="https://pkg.go.dev/builtin#string">string</a>, documentToken <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go">lithic</a>.<a href="https://pkg.go.dev/github.com/lithic-com/lithic-go#AccountHolderDocument">AccountHolderDocument</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
Expand Down
19 changes: 19 additions & 0 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ type Event struct {
Created time.Time `json:"created,required" format:"date-time"`
// Event types:
//
// - `account_holder.created` - Notification that a new account holder has been
// created and was not rejected.
// - `account_holder.updated` - Notification that an account holder was updated.
// - `account_holder.verification` - Notification than an account holder's identity
// verification is complete.
// - `card.created` - Notification that a card has been created.
// - `card.shipped` - Physical card shipment notification. See
// https://docs.lithic.com/docs/cards#physical-card-shipped-webhook.
Expand Down Expand Up @@ -134,6 +139,11 @@ func (r *Event) UnmarshalJSON(data []byte) (err error) {

// Event types:
//
// - `account_holder.created` - Notification that a new account holder has been
// created and was not rejected.
// - `account_holder.updated` - Notification that an account holder was updated.
// - `account_holder.verification` - Notification than an account holder's identity
// verification is complete.
// - `card.created` - Notification that a card has been created.
// - `card.shipped` - Physical card shipment notification. See
// https://docs.lithic.com/docs/cards#physical-card-shipped-webhook.
Expand All @@ -150,6 +160,9 @@ func (r *Event) UnmarshalJSON(data []byte) (err error) {
type EventEventType string

const (
EventEventTypeAccountHolderCreated EventEventType = "account_holder.created"
EventEventTypeAccountHolderUpdated EventEventType = "account_holder.updated"
EventEventTypeAccountHolderVerification EventEventType = "account_holder.verification"
EventEventTypeCardCreated EventEventType = "card.created"
EventEventTypeCardShipped EventEventType = "card.shipped"
EventEventTypeCardTransactionUpdated EventEventType = "card_transaction.updated"
Expand Down Expand Up @@ -196,6 +209,9 @@ func (r *EventSubscription) UnmarshalJSON(data []byte) (err error) {
type EventSubscriptionEventType string

const (
EventSubscriptionEventTypeAccountHolderCreated EventSubscriptionEventType = "account_holder.created"
EventSubscriptionEventTypeAccountHolderUpdated EventSubscriptionEventType = "account_holder.updated"
EventSubscriptionEventTypeAccountHolderVerification EventSubscriptionEventType = "account_holder.verification"
EventSubscriptionEventTypeCardCreated EventSubscriptionEventType = "card.created"
EventSubscriptionEventTypeCardShipped EventSubscriptionEventType = "card.shipped"
EventSubscriptionEventTypeCardTransactionUpdated EventSubscriptionEventType = "card_transaction.updated"
Expand Down Expand Up @@ -292,6 +308,9 @@ func (r EventListParams) URLQuery() (v url.Values) {
type EventListParamsEventType string

const (
EventListParamsEventTypeAccountHolderCreated EventListParamsEventType = "account_holder.created"
EventListParamsEventTypeAccountHolderUpdated EventListParamsEventType = "account_holder.updated"
EventListParamsEventTypeAccountHolderVerification EventListParamsEventType = "account_holder.verification"
EventListParamsEventTypeCardCreated EventListParamsEventType = "card.created"
EventListParamsEventTypeCardShipped EventListParamsEventType = "card.shipped"
EventListParamsEventTypeCardTransactionUpdated EventListParamsEventType = "card_transaction.updated"
Expand Down
2 changes: 1 addition & 1 deletion event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestEventListWithOptionalParams(t *testing.T) {
Begin: lithic.F(time.Now()),
End: lithic.F(time.Now()),
EndingBefore: lithic.F("string"),
EventTypes: lithic.F([]lithic.EventListParamsEventType{lithic.EventListParamsEventTypeCardCreated, lithic.EventListParamsEventTypeCardShipped, lithic.EventListParamsEventTypeCardTransactionUpdated}),
EventTypes: lithic.F([]lithic.EventListParamsEventType{lithic.EventListParamsEventTypeAccountHolderCreated, lithic.EventListParamsEventTypeAccountHolderUpdated, lithic.EventListParamsEventTypeAccountHolderVerification}),
PageSize: lithic.F(int64(1)),
StartingAfter: lithic.F("string"),
WithContent: lithic.F(true),
Expand Down
9 changes: 9 additions & 0 deletions eventsubscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func (r EventSubscriptionNewParams) MarshalJSON() (data []byte, err error) {
type EventSubscriptionNewParamsEventType string

const (
EventSubscriptionNewParamsEventTypeAccountHolderCreated EventSubscriptionNewParamsEventType = "account_holder.created"
EventSubscriptionNewParamsEventTypeAccountHolderUpdated EventSubscriptionNewParamsEventType = "account_holder.updated"
EventSubscriptionNewParamsEventTypeAccountHolderVerification EventSubscriptionNewParamsEventType = "account_holder.verification"
EventSubscriptionNewParamsEventTypeCardCreated EventSubscriptionNewParamsEventType = "card.created"
EventSubscriptionNewParamsEventTypeCardShipped EventSubscriptionNewParamsEventType = "card.shipped"
EventSubscriptionNewParamsEventTypeCardTransactionUpdated EventSubscriptionNewParamsEventType = "card_transaction.updated"
Expand Down Expand Up @@ -230,6 +233,9 @@ func (r EventSubscriptionUpdateParams) MarshalJSON() (data []byte, err error) {
type EventSubscriptionUpdateParamsEventType string

const (
EventSubscriptionUpdateParamsEventTypeAccountHolderCreated EventSubscriptionUpdateParamsEventType = "account_holder.created"
EventSubscriptionUpdateParamsEventTypeAccountHolderUpdated EventSubscriptionUpdateParamsEventType = "account_holder.updated"
EventSubscriptionUpdateParamsEventTypeAccountHolderVerification EventSubscriptionUpdateParamsEventType = "account_holder.verification"
EventSubscriptionUpdateParamsEventTypeCardCreated EventSubscriptionUpdateParamsEventType = "card.created"
EventSubscriptionUpdateParamsEventTypeCardShipped EventSubscriptionUpdateParamsEventType = "card.shipped"
EventSubscriptionUpdateParamsEventTypeCardTransactionUpdated EventSubscriptionUpdateParamsEventType = "card_transaction.updated"
Expand Down Expand Up @@ -349,6 +355,9 @@ func (r EventSubscriptionSendSimulatedExampleParams) MarshalJSON() (data []byte,
type EventSubscriptionSendSimulatedExampleParamsEventType string

const (
EventSubscriptionSendSimulatedExampleParamsEventTypeAccountHolderCreated EventSubscriptionSendSimulatedExampleParamsEventType = "account_holder.created"
EventSubscriptionSendSimulatedExampleParamsEventTypeAccountHolderUpdated EventSubscriptionSendSimulatedExampleParamsEventType = "account_holder.updated"
EventSubscriptionSendSimulatedExampleParamsEventTypeAccountHolderVerification EventSubscriptionSendSimulatedExampleParamsEventType = "account_holder.verification"
EventSubscriptionSendSimulatedExampleParamsEventTypeCardCreated EventSubscriptionSendSimulatedExampleParamsEventType = "card.created"
EventSubscriptionSendSimulatedExampleParamsEventTypeCardShipped EventSubscriptionSendSimulatedExampleParamsEventType = "card.shipped"
EventSubscriptionSendSimulatedExampleParamsEventTypeCardTransactionUpdated EventSubscriptionSendSimulatedExampleParamsEventType = "card_transaction.updated"
Expand Down
6 changes: 3 additions & 3 deletions eventsubscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestEventSubscriptionNewWithOptionalParams(t *testing.T) {
URL: lithic.F("https://example.com"),
Description: lithic.F("string"),
Disabled: lithic.F(true),
EventTypes: lithic.F([]lithic.EventSubscriptionNewParamsEventType{lithic.EventSubscriptionNewParamsEventTypeCardCreated, lithic.EventSubscriptionNewParamsEventTypeCardShipped, lithic.EventSubscriptionNewParamsEventTypeCardTransactionUpdated}),
EventTypes: lithic.F([]lithic.EventSubscriptionNewParamsEventType{lithic.EventSubscriptionNewParamsEventTypeAccountHolderCreated, lithic.EventSubscriptionNewParamsEventTypeAccountHolderUpdated, lithic.EventSubscriptionNewParamsEventTypeAccountHolderVerification}),
})
if err != nil {
var apierr *lithic.Error
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestEventSubscriptionUpdateWithOptionalParams(t *testing.T) {
URL: lithic.F("https://example.com"),
Description: lithic.F("string"),
Disabled: lithic.F(true),
EventTypes: lithic.F([]lithic.EventSubscriptionUpdateParamsEventType{lithic.EventSubscriptionUpdateParamsEventTypeCardCreated, lithic.EventSubscriptionUpdateParamsEventTypeCardShipped, lithic.EventSubscriptionUpdateParamsEventTypeCardTransactionUpdated}),
EventTypes: lithic.F([]lithic.EventSubscriptionUpdateParamsEventType{lithic.EventSubscriptionUpdateParamsEventTypeAccountHolderCreated, lithic.EventSubscriptionUpdateParamsEventTypeAccountHolderUpdated, lithic.EventSubscriptionUpdateParamsEventTypeAccountHolderVerification}),
},
)
if err != nil {
Expand Down Expand Up @@ -252,7 +252,7 @@ func TestEventSubscriptionSendSimulatedExampleWithOptionalParams(t *testing.T) {
context.TODO(),
"string",
lithic.EventSubscriptionSendSimulatedExampleParams{
EventType: lithic.F(lithic.EventSubscriptionSendSimulatedExampleParamsEventTypeCardCreated),
EventType: lithic.F(lithic.EventSubscriptionSendSimulatedExampleParamsEventTypeAccountHolderCreated),
},
)
if err != nil {
Expand Down
35 changes: 35 additions & 0 deletions internal/shared/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,41 @@ import (
"github.com/lithic-com/lithic-go/internal/param"
)

type Address struct {
// Valid deliverable address (no PO boxes).
Address1 string `json:"address1,required"`
// Name of city.
City string `json:"city,required"`
// Valid country code. Only USA is currently supported, entered in uppercase ISO
// 3166-1 alpha-3 three-character format.
Country string `json:"country,required"`
// Valid postal code. Only USA ZIP codes are currently supported, entered as a
// five-digit ZIP or nine-digit ZIP+4.
PostalCode string `json:"postal_code,required"`
// Valid state code. Only USA state codes are currently supported, entered in
// uppercase ISO 3166-2 two-character format.
State string `json:"state,required"`
// Unit or apartment number (if applicable).
Address2 string `json:"address2"`
JSON addressJSON
}

// addressJSON contains the JSON metadata for the struct [Address]
type addressJSON struct {
Address1 apijson.Field
City apijson.Field
Country apijson.Field
PostalCode apijson.Field
State apijson.Field
Address2 apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *Address) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

type AddressParam struct {
// Valid deliverable address (no PO boxes).
Address1 param.Field[string] `json:"address1,required"`
Expand Down
Loading