models

package
v0.0.0-...-045564c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ActionKey = "action"

	InsertAction = "insert"
	UpdateAction = "update"
	DeleteAction = "delete"
)
View Source
const (
	APIURL                        = "https://api.stripe.com/v1"
	PathFmt                       = "/%s"
	HeaderAuthKey                 = "Authorization"
	HeaderAuthValueFormat         = "Bearer %s"
	UnexpectedErrorWithStatusCode = "unexpected error with status code %d"
)

An UnexpectedErrorWithStatusCode represents an unexpected error message with status code.

Variables

View Source
var EventsAction = (func() map[string]string {
	eventsAction := make(map[string]string)

	for _, events := range EventsMap {
		for _, event := range events {
			switch e := event; {
			case strings.Contains(e, eventKeyCreated):
				eventsAction[e] = InsertAction
			case strings.Contains(e, eventKeyDeleted):
				eventsAction[e] = DeleteAction
			default:
				eventsAction[e] = UpdateAction
			}
		}
	}

	return eventsAction
})()

EventsAction represents a dictionary with actions of events, where the key is an event and the value is an action.

View Source
var EventsMap = map[string][]string{
	resources.CreditNoteResource:                  resources.CreditNoteEvents,
	resources.InvoiceResource:                     resources.InvoiceEvents,
	resources.InvoiceItemResource:                 resources.InvoiceItemEvents,
	resources.PlanResource:                        resources.PlanEvents,
	resources.QuoteResource:                       resources.QuoteEvents,
	resources.SubscriptionResource:                resources.SubscriptionEvents,
	resources.SubscriptionScheduleResource:        resources.SubscriptionScheduleEvents,
	resources.CheckoutSessionResource:             resources.CheckoutSessionEvents,
	resources.AccountResource:                     resources.AccountEvents,
	resources.ApplicationFeeResource:              resources.ApplicationFeeEvents,
	resources.TopUpResource:                       resources.TopUpEvents,
	resources.TransferResource:                    resources.TransferEvents,
	resources.ChargeResource:                      resources.ChargeEvents,
	resources.CustomerResource:                    resources.CustomerEvents,
	resources.DisputeResource:                     resources.DisputeEvents,
	resources.FileResource:                        resources.FileEvents,
	resources.PaymentIntentResource:               resources.PaymentIntentEvents,
	resources.SetupIntentResource:                 resources.SetupIntentEvents,
	resources.PayoutResource:                      resources.PayoutEvents,
	resources.RefundResource:                      resources.RefundEvents,
	resources.RadarEarlyFraudWarningResource:      resources.RadarEarlyFraudWarningEvents,
	resources.ReviewResource:                      resources.ReviewEvents,
	resources.IdentityVerificationSessionResource: resources.IdentityVerificationSessionEvents,
	resources.IssuingAuthorizationResource:        resources.IssuingAuthorizationEvents,
	resources.IssuingCardholderResource:           resources.IssuingCardholderEvents,
	resources.IssuingCardResource:                 resources.IssuingCardEvents,
	resources.IssuingDisputeResource:              resources.IssuingDisputeEvents,
	resources.IssuingTransactionResource:          resources.IssuingTransactionEvents,
	resources.OrderResource:                       resources.OrderEvents,
	resources.PaymentLinkResource:                 resources.PaymentLinkEvents,
	resources.PaymentMethodResource:               resources.PaymentMethodEvents,
	resources.ProductResource:                     resources.ProductEvents,
	resources.PriceResource:                       resources.PriceEvents,
	resources.CouponResource:                      resources.CouponEvents,
	resources.PromotionCodeResource:               resources.PromotionCodeEvents,
	resources.TaxRateResource:                     resources.TaxRateEvents,
	resources.ReportingReportRunResource:          resources.ReportingReportRunEvents,
	resources.ReportingReportTypeResource:         resources.ReportingReportTypeEvents,
	resources.ScheduledQueryRunResource:           resources.ScheduledQueryRunEvents,
	resources.TerminalReaderResource:              resources.TerminalReaderEvents,
}

EventsMap represents a dictionary with all events in each resource, where the key is the resource and the value is a slice of events.

View Source
var IteratorTypeMap = map[IteratorType]struct{}{
	SnapshotIterator: {},
	CDCIterator:      {},
}

IteratorTypeMap contains valid iterators.

View Source
var ResourcesMap = map[string]string{
	resources.CreditNoteResource:                  resources.CreditNotesList,
	resources.BillingPortalConfigurationResource:  resources.BillingPortalConfigurationsList,
	resources.InvoiceResource:                     resources.InvoicesList,
	resources.InvoiceItemResource:                 resources.InvoiceItemsList,
	resources.PlanResource:                        resources.PlanList,
	resources.QuoteResource:                       resources.QuotesList,
	resources.SubscriptionResource:                resources.SubscriptionsList,
	resources.SubscriptionScheduleResource:        resources.SubscriptionSchedulesList,
	resources.CheckoutSessionResource:             resources.CheckoutSessionsList,
	resources.AccountResource:                     resources.AccountsList,
	resources.ApplicationFeeResource:              resources.ApplicationFeesList,
	resources.TopUpResource:                       resources.TopUpsList,
	resources.TransferResource:                    resources.TransfersList,
	resources.ChargeResource:                      resources.ChargesList,
	resources.CustomerResource:                    resources.CustomersList,
	resources.DisputeResource:                     resources.DisputesList,
	resources.FileResource:                        resources.FilesList,
	resources.PaymentIntentResource:               resources.PaymentIntentsList,
	resources.SetupIntentResource:                 resources.SetupIntentsList,
	resources.PayoutResource:                      resources.PayoutsList,
	resources.RefundResource:                      resources.RefundsList,
	resources.RadarEarlyFraudWarningResource:      resources.RadarEarlyFraudWarningsList,
	resources.ReviewResource:                      resources.ReviewsList,
	resources.IdentityVerificationSessionResource: resources.IdentityVerificationSessionsList,
	resources.IssuingAuthorizationResource:        resources.IssuingAuthorizationsList,
	resources.IssuingCardholderResource:           resources.IssuingCardholdersList,
	resources.IssuingCardResource:                 resources.IssuingCardsList,
	resources.IssuingDisputeResource:              resources.IssuingDisputesList,
	resources.IssuingTransactionResource:          resources.IssuingTransactionsList,
	resources.OrderResource:                       resources.OrdersList,
	resources.PaymentLinkResource:                 resources.PaymentLinksList,
	resources.PaymentMethodResource:               resources.PaymentMethodsList,
	resources.ProductResource:                     resources.ProductsList,
	resources.PriceResource:                       resources.PricesList,
	resources.CouponResource:                      resources.CouponsList,
	resources.PromotionCodeResource:               resources.PromotionCodesList,
	resources.TaxRateResource:                     resources.TaxRatesList,
	resources.ReportingReportRunResource:          resources.ReportingReportRunsList,
	resources.ReportingReportTypeResource:         resources.ReportingReportTypesList,
	resources.ScheduledQueryRunResource:           resources.ScheduledQueryRunsList,
	resources.TerminalReaderResource:              resources.TerminalReadersList,
}

ResourcesMap represents a dictionary with valid resources, where the key is the object type and the value is the name of the API endpoints of that object type.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error struct {
		Message string `json:"message"`
		Type    string `json:"type"`
	} `json:"error"`
}

An ErrorResponse represents a response error from Stripe.

type EventData

type EventData struct {
	ID      string          `json:"id"`
	Created int64           `json:"created"`
	Data    EventDataObject `json:"data"`
	Type    string          `json:"type"`
}

A EventData represents a data of event response.

type EventDataObject

type EventDataObject struct {
	Object map[string]interface{} `json:"object"`
}

An EventDataObject represents a full object of event data.

type EventResponse

type EventResponse struct {
	Data    EventsData `json:"data"`
	HasMore bool       `json:"has_more"`
}

A EventResponse represents a response event data from Stripe.

type EventsData

type EventsData []EventData

An EventsData represents a slice of EventData.

func (EventsData) Reverse

func (e EventsData) Reverse()

Reverse reverses an EventsData.

type IteratorType

type IteratorType string

An IteratorType represents a type of iterators.

const (
	// A SnapshotIterator represents a snapshot iterator type.
	SnapshotIterator IteratorType = "snapshot"

	// A CDCIterator represents a cdc iterator type.
	CDCIterator IteratorType = "cdc"
)

type ResourceResponse

type ResourceResponse struct {
	Data []map[string]interface{} `json:"data"`
}

A ResourceResponse represents a response resource data from Stripe.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL