subscriptions

package
v0.0.0-...-a11cca7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

package subscriptions refers to subscriptions resource

Index

Constants

View Source
const (
	// TableName is the database table for this resource
	TableName = "subscriptions"
	// KeyName is the primary key value for this resource
	KeyName = "id"
	// Order defines the default sort order in sql for this resource
	Order = "id desc"
)

Variables

This section is empty.

Functions

func AllowedParams

func AllowedParams() []string

AllowedParams returns an array of acceptable params in update

func Query

func Query() *query.Query

Query returns a new query for subscriptions with a default order.

func Where

func Where(format string, args ...interface{}) *query.Query

Where returns a new query for subscriptions with the format and arguments supplied.

Types

type CardModel

type CardModel struct {
	Card struct {
		ID             string `json:"id"`
		BillingAddress struct {
			AddressLine1                 string `json:"address_line_1"`
			AddressLine2                 string `json:"address_line_2"`
			Locality                     string `json:"locality"`
			AdministrativeDistrictLevel1 string `json:"administrative_district_level_1"`
			PostalCode                   string `json:"postal_code"`
			Country                      string `json:"country"`
		} `json:"billing_address"`
		Fingerprint    string `json:"fingerprint"`
		Bin            string `json:"bin"`
		CardBrand      string `json:"card_brand"`
		CardType       string `json:"card_type"`
		CardholderName string `json:"cardholder_name"`
		CustomerID     string `json:"customer_id"`
		Enabled        bool   `json:"enabled"`
		ExpMonth       int    `json:"exp_month"`
		ExpYear        int    `json:"exp_year"`
		Last4          string `json:"last_4"`
		MerchantID     string `json:"merchant_id"`
		PrepaidType    string `json:"prepaid_type"`
		ReferenceID    string `json:"reference_id"`
		Version        int    `json:"version"`
	} `json:"card"`
}

type CatalogModel

type CatalogModel struct {
	CatalogObject struct {
		Type                  string    `json:"type"`
		ID                    string    `json:"id"`
		UpdatedAt             time.Time `json:"updated_at"`
		CreatedAt             time.Time `json:"created_at"`
		Version               int64     `json:"version"`
		IsDeleted             bool      `json:"is_deleted"`
		PresentAtAllLocations bool      `json:"present_at_all_locations"`
		SubscriptionPlanData  struct {
			Name   string `json:"name"`
			Phases []struct {
				UID                 string `json:"uid"`
				Cadence             string `json:"cadence"`
				RecurringPriceMoney struct {
					Amount   int    `json:"amount"`
					Currency string `json:"currency"`
				} `json:"recurring_price_money"`
				Ordinal int `json:"ordinal"`
			} `json:"phases"`
		} `json:"subscription_plan_data"`
	} `json:"catalog_object"`
	IDMappings []struct {
		ClientObjectID string `json:"client_object_id"`
		ObjectID       string `json:"object_id"`
	} `json:"id_mappings"`
}

type Charge

type Charge struct {
	Payment struct {
		ID          string    `json:"id"`
		CreatedAt   time.Time `json:"created_at"`
		UpdatedAt   time.Time `json:"updated_at"`
		AmountMoney struct {
			Amount   int    `json:"amount"`
			Currency string `json:"currency"`
		} `json:"amount_money"`
		Status        string `json:"status"`
		DelayDuration string `json:"delay_duration"`
		SourceType    string `json:"source_type"`
		CardDetails   struct {
			Status string `json:"status"`
			Card   struct {
				CardBrand   string `json:"card_brand"`
				Last4       string `json:"last_4"`
				ExpMonth    int    `json:"exp_month"`
				ExpYear     int    `json:"exp_year"`
				Fingerprint string `json:"fingerprint"`
				CardType    string `json:"card_type"`
				PrepaidType string `json:"prepaid_type"`
				Bin         string `json:"bin"`
			} `json:"card"`
			EntryMethod          string `json:"entry_method"`
			CvvStatus            string `json:"cvv_status"`
			AvsStatus            string `json:"avs_status"`
			StatementDescription string `json:"statement_description"`
			CardPaymentTimeline  struct {
				AuthorizedAt time.Time `json:"authorized_at"`
				CapturedAt   time.Time `json:"captured_at"`
			} `json:"card_payment_timeline"`
		} `json:"card_details"`
		LocationID string `json:"location_id"`
		OrderID    string `json:"order_id"`
		TotalMoney struct {
			Amount   int    `json:"amount"`
			Currency string `json:"currency"`
		} `json:"total_money"`
		ApprovedMoney struct {
			Amount   int    `json:"amount"`
			Currency string `json:"currency"`
		} `json:"approved_money"`
		ReceiptNumber      string    `json:"receipt_number"`
		ReceiptURL         string    `json:"receipt_url"`
		DelayAction        string    `json:"delay_action"`
		DelayedUntil       time.Time `json:"delayed_until"`
		ApplicationDetails struct {
			SquareProduct string `json:"square_product"`
			ApplicationID string `json:"application_id"`
		} `json:"application_details"`
		VersionToken string `json:"version_token"`
	} `json:"payment"`
}

type CustomerModel

type CustomerModel struct {
	Customer struct {
		ID           string    `json:"id"`
		CreatedAt    time.Time `json:"created_at"`
		UpdatedAt    time.Time `json:"updated_at"`
		GivenName    string    `json:"given_name"`
		FamilyName   string    `json:"family_name"`
		EmailAddress string    `json:"email_address"`
		Address      struct {
			AddressLine1                 string `json:"address_line_1"`
			AddressLine2                 string `json:"address_line_2"`
			Locality                     string `json:"locality"`
			AdministrativeDistrictLevel1 string `json:"administrative_district_level_1"`
			PostalCode                   string `json:"postal_code"`
			Country                      string `json:"country"`
		} `json:"address"`
		PhoneNumber string `json:"phone_number"`
		ReferenceID string `json:"reference_id"`
		Note        string `json:"note"`
		Preferences struct {
			EmailUnsubscribed bool `json:"email_unsubscribed"`
		} `json:"preferences"`
		CreationSource string `json:"creation_source"`
		Version        int    `json:"version"`
	} `json:"customer"`
}

type ErrorModel

type ErrorModel struct {
	Errors []struct {
		Code     string `json:"code"`
		Detail   string `json:"detail"`
		Field    string `json:"field"`
		Category string `json:"category"`
	} `json:"errors"`
}

type Subscription

type Subscription struct {
	// resource.Base defines behaviour and fields shared between all resources
	resource.Base

	// status.ResourceStatus defines a status field and associated behaviour
	status.ResourceStatus

	Id             string
	Created        time.Time
	Amount         float64
	Currency       string
	CustomerId     string
	CustomerEmail  string
	SubscriptionId string
	UserId         int64
	Plan           string
	ProductId      int64
}

Subscription handles saving and retrieving users from the database

func Find

func Find(id string) (*Subscription, error)

Find fetches a single subscription record from the database by id.

func FindAll

func FindAll(q *query.Query) ([]*Subscription, error)

FindAll fetches all subscription records matching this query from the database.

func FindCustomerId

func FindCustomerId(userId int64) (*Subscription, error)

Find fetches a single subscription record from the database by user id.

func FindFirst

func FindFirst(format string, args ...interface{}) (*Subscription, error)

FindFirst fetches a single user record from the database using a where query with the format and args provided.

func FindPayment

func FindPayment(id string) (*Subscription, error)

FindPayment fetches a single subscription record from the database by PaymentIntent id.

func FindSubscription

func FindSubscription(id string) (*Subscription, error)

FindSubscription fetches a single subscription record from the database by Subscriber id.

func New

func New() *Subscription

New creates and initialises a new subscriptions instance.

func NewWithColumns

func NewWithColumns(cols map[string]interface{}) *Subscription

NewWithColumns creates a new subscription instance and fills with data from the database cols provided.

type SubscriptionModel

type SubscriptionModel struct {
	Subscription struct {
		ID         string    `json:"id"`
		LocationID string    `json:"location_id"`
		PlanID     string    `json:"plan_id"`
		CustomerID string    `json:"customer_id"`
		StartDate  string    `json:"start_date"`
		Status     string    `json:"status"`
		Version    int64     `json:"version"`
		CreatedAt  time.Time `json:"created_at"`
		CardID     string    `json:"card_id"`
		Timezone   string    `json:"timezone"`
	} `json:"subscription"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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