marketplace

package
v0.8.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AnnualSubscription  Subscription = "Annual"
	MonthlySubscription Subscription = "Monthly"

	AccountTypePersonal     AccountType = "Personal"
	AccountTypeOrganization AccountType = "Organization"
)

Variables

View Source
var ServerTimeZone, _ = time.LoadLocation("Europe/Berlin")

Functions

func FeePercentage

func FeePercentage(date time.Time) float64

func PaidOutPercentage

func PaidOutPercentage(date time.Time) float64

Types

type AccountType

type AccountType string

AccountType is either a Personal or an Organization account

type Amount

type Amount float64

func (Amount) Format

func (a Amount) Format() string

func (Amount) IsZero

func (a Amount) IsZero() bool

type ChurnedCustomer

type ChurnedCustomer struct {
	Customer
	LastPurchase     YearMonthDay
	Subscription     Subscription
	FreeSubscription bool
}

func (ChurnedCustomer) PaidDuration

func (c ChurnedCustomer) PaidDuration(first YearMonthDay) string

type ChurnedCustomerList

type ChurnedCustomerList []ChurnedCustomer

func (ChurnedCustomerList) Customers added in v0.6.0

func (c ChurnedCustomerList) Customers() Customers

type ChurnedCustomers

type ChurnedCustomers struct {
	ChurnedCustomers ChurnedCustomerList
	ActiveUserCount  int
}

func NewChurnedCustomers

func NewChurnedCustomers(customers []ChurnedCustomer) ChurnedCustomers

func (ChurnedCustomers) ChurnRatePercentage

func (c ChurnedCustomers) ChurnRatePercentage() float64

func (ChurnedCustomers) Contains

func (c ChurnedCustomers) Contains(id CustomerID) bool

func (ChurnedCustomers) Count

func (c ChurnedCustomers) Count() int

func (ChurnedCustomers) CountAnnual

func (c ChurnedCustomers) CountAnnual() int

func (ChurnedCustomers) CountMonthly

func (c ChurnedCustomers) CountMonthly() int

func (ChurnedCustomers) Customers

func (c ChurnedCustomers) Customers() Customers

func (ChurnedCustomers) GroupByPaidDuration

func (c ChurnedCustomers) GroupByPaidDuration(first CustomerDateMap) []NumberedGroup

func (ChurnedCustomers) IsNotEmpty

func (c ChurnedCustomers) IsNotEmpty() bool

func (ChurnedCustomers) SortedByDate

func (c ChurnedCustomers) SortedByDate() ChurnedCustomerList

func (ChurnedCustomers) SortedByDayOfMonth

func (c ChurnedCustomers) SortedByDayOfMonth() ChurnedCustomerList

type Client

type Client interface {
	GetCurrentPluginInfo() (PluginInfo, error)
	GetPluginInfo(id string) (PluginInfo, error)

	GetCurrentPluginRating() (Rating, error)
	GetPluginRating(id string) (Rating, error)

	DownloadsMonthly(uniqueDownloads bool, channel, build, product, country, productCommonCode string) ([]DownloadMonthly, error)
	DownloadsWeekly(uniqueDownloads bool, channel, build, product, country, productCommonCode string) ([]DownloadAndDate, error)
	DownloadsDaily(uniqueDownloads bool, channel, build, product, country, productCommonCode string) ([]DownloadAndDate, error)
	Downloads(period string, uniqueDownloads bool, channel, build, product, country, productCommonCode string) (DownloadResponse, error)

	// GetAllSalesInfo returns the sales of the complete lifespan of the plugin
	GetAllSalesInfo() (Sales, error)
	// GetSalesInfo returns the sales in the given range.
	// If it covers more than one year, then the sales will be fetched in yearly chunks.
	GetSalesInfo(beginDate, endDate YearMonthDay) (Sales, error)

	// GetAllTrialsInfo returns the trial license data of the complete lifespan of the plugin
	GetAllTrialsInfo() (Transactions, error)
	// GetTrialsInfo returns the trial license data of the given range.
	// If it covers more than one year, then the sales will be fetched in yearly chunks.
	GetTrialsInfo(beginDate, endDate YearMonthDay) (Transactions, error)

	// GetJSON performs a generic request to the marketplace, it expects that JSON data is returned
	GetJSON(path string, params map[string]string, target interface{}) error
}

func NewClient

func NewClient(pluginID, token string) Client

type CountrySales

type CountrySales struct {
	Country  string
	TotalUSD Amount
	Sales    Sales
}

CountrySales contains the sales of a specific country.

type CountryTransactions added in v0.8.0

type CountryTransactions struct {
	Country      string
	Transactions Transactions
}

type Currency

type Currency string

Currency is a currency, as used by the JetBrains API

type CurrencySales

type CurrencySales struct {
	// Currency is the currency used in this struct
	Currency Currency
	// TotalSales is the sum of all sales in currency "Currency"
	TotalSales Amount
	// TotalSalesUSD is the sum of all sales, but in USD
	TotalSalesUSD Amount
	// Sales
	Sales Sales
}

CurrencySales contains the sales in a certain currency.

type Customer

type Customer struct {
	ID      CustomerID  `json:"code"`
	Name    string      `json:"name"`
	Country string      `json:"country"`
	Type    AccountType `json:"type"`
}

Customer defines a specific customer

func NewCustomer

func NewCustomer(id CustomerID, name, country string, accountType AccountType) Customer

NewCustomer returns a new customer

func (Customer) String

func (c Customer) String() string

String returns a string representation for debugging purposes

type CustomerDateMap

type CustomerDateMap map[CustomerID]YearMonthDay

CustomerDateMap maps a customer ID to a YearMonthDate

type CustomerID

type CustomerID int

CustomerID identifies a specific customer, this is used by the JetBrains API

type CustomerSales

type CustomerSales struct {
	Customer Customer
	Sales    Sales
	TotalUSD Amount
}

CustomerSales contains the sales of a specific customer

func (*CustomerSales) FirstPurchase

func (c *CustomerSales) FirstPurchase() YearMonthDay

FirstPurchase returns the first purchase of this customer. If there are no sales, then the zero value of time.Time is returned.

func (*CustomerSales) LatestPurchase

func (c *CustomerSales) LatestPurchase() time.Time

LatestPurchase returns the latest purchase of this customer. If there are no sales, then the zero value of time.Time is returned.

type CustomerSalesMap

type CustomerSalesMap map[CustomerID]*CustomerSales

func (CustomerSalesMap) GroupByPaidMonths

func (m CustomerSalesMap) GroupByPaidMonths(customers Customers, before time.Time) []NumberedGroup

func (CustomerSalesMap) PaidMonths

func (m CustomerSalesMap) PaidMonths(id CustomerID, before time.Time) int

func (CustomerSalesMap) TotalSales

func (m CustomerSalesMap) TotalSales(id CustomerID) Amount

type CustomerTransactionMap added in v0.8.0

type CustomerTransactionMap map[CustomerID]Transactions

func (CustomerTransactionMap) RetainCustomers added in v0.8.0

func (t CustomerTransactionMap) RetainCustomers(retained []Customer) CustomerTransactionMap

type Customers

type Customers []Customer

Customers defines a slice of Customer

func (Customers) AsMap

func (c Customers) AsMap() CustomersMap

func (Customers) GroupByCountry

func (c Customers) GroupByCountry() []GroupedCustomers

func (Customers) SortByDateMapping

func (c Customers) SortByDateMapping(mapping CustomerDateMap) Customers

SortByID returns a slice sorted by the date of first purchase

func (Customers) SortByID

func (c Customers) SortByID() Customers

SortByID returns a new slice, which is ascendingly sorted by customer id.

type CustomersMap

type CustomersMap map[CustomerID]Customer

CustomersMap maps a customer ID to customer

func (CustomersMap) Without

func (m CustomersMap) Without(customersMap CustomersMap) CustomersMap

type DateGroupedSales

type DateGroupedSales struct {
	Date     YearMonthDay
	Name     string
	TotalUSD Amount
	Sales    Sales
}

DateGroupedSales is a number of sales, which have a group name and a date

type DateGroupedTransactions added in v0.8.0

type DateGroupedTransactions struct {
	Date         YearMonthDay
	Transactions Transactions
}

DateGroupedTransactions defines a basic transaction tied to a date

type DownloadAndDate

type DownloadAndDate struct {
	Downloads int

	Year  int
	Month time.Month
	Day   int
}

func (DownloadAndDate) Date

func (d DownloadAndDate) Date() YearMonthDay

type DownloadData

type DownloadData struct {
	Dimension string `json:"dimension"`
	Serie     []NameValuePair
}

type DownloadMonthly

type DownloadMonthly struct {
	Year      int
	Month     time.Month
	Downloads int
}

func (DownloadMonthly) Date

func (d DownloadMonthly) Date() YearMonth

type DownloadResponse

type DownloadResponse struct {
	Measure    string `json:"measure"`
	Filters    []Filter
	Dimension1 string `json:"dim1"`
	Data       DownloadData
}

type Filter

type Filter struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type GroupedCustomers

type GroupedCustomers struct {
	Name      string
	Customers Customers
}

GroupedCustomers is a name with a list of customers

type GroupedSales

type GroupedSales struct {
	Name     string
	TotalUSD Amount
	Sales    Sales
}

GroupedSales is a number of sales, which have a group name

type NameValuePair

type NameValuePair struct {
	Name  string `json:"name"`
	Value int    `json:"value"`
}

type NumberedGroup

type NumberedGroup struct {
	Name  string
	Value int
}

NumberedGroup is a name with a count

type PluginInfo

type PluginInfo struct {
	ID            int    `json:"id"`
	Name          string `json:"name"`
	Description   string `json:"description"`
	Link          string `json:"link"`
	Approved      bool   `json:"approve"`
	XmlID         string `json:"xmlId"`
	CustomIdeList bool   `json:"customIdeList"`
	PreviewText   string `json:"preview"`

	ContactEmail string `json:"email"`
	Copyright    string `json:"copyright"`
	Downloads    int    `json:"downloads"`
	PurchaseInfo PurchaseInfo

	URLs                map[string]json.RawMessage `json:"urls"`
	Tags                []Tag                      `json:"tags"`
	RemovalRequested    bool                       `json:"removalRequested"`
	HasUnapprovedUpdate bool                       `json:"hasUnapprovedUpdate"`
	ReadyForSale        bool                       `json:"readyForSale"`
	IconMarketplacePath string                     `json:"icon"`
}

type PurchaseInfo

type PurchaseInfo struct {
	ProductCode string `json:"productCode"`
}

type Rating added in v0.6.0

type Rating struct {
	MeanRating float64        `json:"meanRating"`
	MeanVotes  int            `json:"meanVotes"`
	UserRating int            `json:"userRating"`
	Votes      map[string]int `json:"votes"`
}

func (Rating) CalculateRating added in v0.6.0

func (r Rating) CalculateRating() float64

func (Rating) VotesCount added in v0.6.0

func (r Rating) VotesCount() int

func (Rating) VotesSum added in v0.6.0

func (r Rating) VotesSum() int

type Sale

type Sale struct {
	Transaction
	// Amount is the amount paid by the customer, in currency 'Currency'
	Amount Amount `json:"amount"`
	// Currency is the currency of the transaction
	Currency Currency `json:"currency"`
	// AmountUSD is Amount, converted into USD. This value is returned by the JetBrains API.
	AmountUSD Amount `json:"amountUSD"`
	// Period defines, if the transaction was for a monthly or annual license
	Period Subscription `json:"period"`
}

Sale represents a single transaction. Its structure is defined by the JetBrains API

func NewSale

func NewSale(refID string, year, month, day int, subscription Subscription, customer Customer, amount Amount, currency Currency, amountUSD Amount) Sale

func (Sale) ExchangeRate

func (s Sale) ExchangeRate() float32

ExchangeRate returns the exchange rate of AmountUSD / Amount

func (Sale) FeeAmount

func (s Sale) FeeAmount() Amount

FeeAmount returns the fee, in the currency of this sale, which is paid to JetBrains.

func (Sale) FeeAmountUSD

func (s Sale) FeeAmountUSD() Amount

FeeAmountUSD is the fee in USD, which is paid to JetBrains.

func (Sale) IsFreeSubscription

func (s Sale) IsFreeSubscription() bool

IsFreeSubscription returns true if the amount was 0, which indicates a free license

func (Sale) String

func (s Sale) String() string

type Sales

type Sales []Sale

Sales is a slice of sales. It offers a wide range of methods to aggregate the data.

func (Sales) After

func (s Sales) After(date time.Time) Sales

func (Sales) AtOrAfter

func (s Sales) AtOrAfter(date time.Time) Sales

func (Sales) Before

func (s Sales) Before(date time.Time) Sales

func (Sales) ByAccountType

func (s Sales) ByAccountType(subscription AccountType) Sales

func (Sales) ByAnnualSubscription

func (s Sales) ByAnnualSubscription() Sales

func (Sales) ByCustomer

func (s Sales) ByCustomer(c Customer) Sales

func (Sales) ByDateRange

func (s Sales) ByDateRange(begin, end YearMonthDay) Sales

ByDateRange returns a new Sales slice, which contains all items bought in the given date range (inclusive)

func (Sales) ByDay

func (s Sales) ByDay(date time.Time) Sales

ByDay returns a new Sales slice, which contains all items bought at this particular day

func (Sales) ByFreeSubscription

func (s Sales) ByFreeSubscription() Sales

func (Sales) ByMonth

func (s Sales) ByMonth(year int, month time.Month) Sales

func (Sales) ByMonthlySubscription

func (s Sales) ByMonthlySubscription() Sales

func (Sales) ByNewCustomers

func (s Sales) ByNewCustomers(allPreviousSales Sales, referenceDate time.Time) Sales

func (Sales) ByReturnedCustomers added in v0.6.0

func (s Sales) ByReturnedCustomers(previouslyChurned ChurnedCustomerList) Sales

func (Sales) ByWeek

func (s Sales) ByWeek(year int, isoWeek int) Sales

ByWeek returns a new Sales slice, which contains all items bought in the week of the year

func (Sales) ByYear

func (s Sales) ByYear(year int) Sales

func (Sales) ByYearMonth

func (s Sales) ByYearMonth(month YearMonth) Sales

ByYearMonth returns a new Sales slice, which contains all items bought in the particular month

func (Sales) ByYearMonthDay

func (s Sales) ByYearMonthDay(day YearMonthDay) Sales

ByYearMonthDay returns a new Sales slice, which contains all items bought at this particular day

func (Sales) CountrySales

func (s Sales) CountrySales() []*CountrySales

func (Sales) CustomerCount

func (s Sales) CustomerCount() int

func (Sales) CustomerSales

func (s Sales) CustomerSales() []*CustomerSales

func (Sales) CustomerSalesMap

func (s Sales) CustomerSalesMap() CustomerSalesMap

func (Sales) CustomerTypeSales

func (s Sales) CustomerTypeSales() []GroupedSales

func (Sales) Customers

func (s Sales) Customers() Customers

Customers returns a unique set of customers found in the sales

func (Sales) CustomersFirstPurchase

func (s Sales) CustomersFirstPurchase() CustomerDateMap

func (Sales) CustomersLastPurchase

func (s Sales) CustomersLastPurchase() CustomerDateMap

func (Sales) CustomersMap

func (s Sales) CustomersMap() CustomersMap

func (Sales) FeeSumUSD

func (s Sales) FeeSumUSD() Amount

func (Sales) FilterBy

func (s Sales) FilterBy(keep func(Sale) bool) Sales

FilterBy returns a new Sales slice, which contains all items, were the keep function returned true

func (Sales) GroupByCurrency

func (s Sales) GroupByCurrency() []*CurrencySales

sales in currencies, sorted by USD

func (Sales) GroupByDate

func (s Sales) GroupByDate(newestDateFirst bool) []DateGroupedSales

sales, grouped by year-month-day

func (Sales) GroupByWeekday

func (s Sales) GroupByWeekday() []GroupedSales

func (Sales) PaidOutUSD

func (s Sales) PaidOutUSD() Amount

func (Sales) Reversed

func (s Sales) Reversed() Sales

func (Sales) SortedByDate

func (s Sales) SortedByDate() Sales

func (Sales) SubscriptionSales

func (s Sales) SubscriptionSales() []GroupedSales

func (Sales) TotalSumUSD

func (s Sales) TotalSumUSD() Amount

type ScreenshotInfo

type ScreenshotInfo struct {
	ID              int    `json:"id"`
	MarketplacePath string `json:"url"`
}

type Subscription

type Subscription string

Subscription is either an Annual or a Monthly subscription

func (Subscription) Abbrev

func (s Subscription) Abbrev() string

type Tag

type Tag struct {
	ID              int    `json:"ID"`
	Name            string `json:"name"`
	Privileged      bool   `json:"privileged"`
	Searchable      bool   `json:"searchable"`
	MarketplacePath string `json:"link"`
}

type Transaction added in v0.8.0

type Transaction struct {
	// ReferenceID is a unique ID of this transaction
	ReferenceID string `json:"ref"`
	// Date, depends on source. Either the day, when the sale was mode or when the trial expires.
	Date YearMonthDay `json:"date"`
	// Customer defines the customer, who paid for the license
	Customer Customer `json:"customer"`
}

Transaction contains basic information about a transaction

func NewTransaction added in v0.8.0

func NewTransaction(refId string, date YearMonthDay, customer Customer) Transaction

type Transactions added in v0.8.0

type Transactions []Transaction

func (Transactions) Before added in v0.8.0

func (t Transactions) Before(date time.Time) Transactions

func (Transactions) ByYearMonth added in v0.8.0

func (t Transactions) ByYearMonth(month YearMonth) Transactions

ByYearMonth returns a new Transactions slice, which contains all items bought in the particular month

func (Transactions) FilterBy added in v0.8.0

func (t Transactions) FilterBy(keep func(transaction Transaction) bool) Transactions

FilterBy returns a new Sales slice, which contains all items, were the keep function returned true

func (Transactions) GroupByCountry added in v0.8.0

func (t Transactions) GroupByCountry() []CountryTransactions

GroupByCountry returns transactions, grouped by customer's country. The result is sorted by number of transactions

func (Transactions) GroupByCustomer added in v0.8.0

func (t Transactions) GroupByCustomer() CustomerTransactionMap

func (Transactions) GroupByDate added in v0.8.0

func (t Transactions) GroupByDate(newestDateFirst bool) []DateGroupedTransactions

GroupByDate groups transactions by date

func (Transactions) SortedByDate added in v0.8.0

func (t Transactions) SortedByDate() Transactions

type Vendor

type Vendor struct {
	ID                  int      `json:"vendorId"`
	Name                string   `json:"name"`
	PublicName          string   `json:"publicName"`
	Email               string   `json:"email"`
	CountryCode         string   `json:"countryCode"`
	Country             string   `json:"country"`
	City                string   `json:"city"`
	ZipCode             string   `json:"zipCode"`
	URL                 string   `json:"url"`
	MarketplacePath     string   `json:"link"`
	TotalPlugins        int      `json:"totalPlugins"`
	TotalUsers          int      `json:"totalUsers"`
	Verified            bool     `json:"isVerified"`
	ServicesDescription []string `json:"servicesDescription"`
}

type YearMonth

type YearMonth [2]int

YearMonth represents year, month

func NewYearMonth

func NewYearMonth(year int, month time.Month) YearMonth

func NewYearMonthByDate

func NewYearMonthByDate(date time.Time) YearMonth

func (YearMonth) Add

func (y YearMonth) Add(years, months, days int) YearMonth

func (YearMonth) AsDate

func (y YearMonth) AsDate() time.Time

func (YearMonth) ContainsDate

func (y YearMonth) ContainsDate(date time.Time) bool

func (YearMonth) Equals

func (y YearMonth) Equals(o YearMonth) bool

func (YearMonth) IsAfter

func (y YearMonth) IsAfter(o YearMonth) bool

func (YearMonth) Month

func (y YearMonth) Month() time.Month

func (YearMonth) NextMonth

func (y YearMonth) NextMonth() YearMonth

func (YearMonth) PreviousMonth

func (y YearMonth) PreviousMonth() YearMonth

func (YearMonth) String

func (y YearMonth) String() string

func (YearMonth) Year

func (y YearMonth) Year() int

type YearMonthDay

type YearMonthDay [3]int

YearMonthDay represents year, month, day

func NewYearMonthDay

func NewYearMonthDay(year, month, day int) YearMonthDay

func NewYearMonthDayByDate

func NewYearMonthDayByDate(date time.Time) YearMonthDay

func (YearMonthDay) Add

func (d YearMonthDay) Add(years, months, days int) YearMonthDay

func (YearMonthDay) AddDays

func (d YearMonthDay) AddDays(days int) YearMonthDay

func (YearMonthDay) AsDate

func (d YearMonthDay) AsDate() time.Time

func (YearMonthDay) AsYearMonth

func (d YearMonthDay) AsYearMonth() YearMonth

func (YearMonthDay) Day

func (d YearMonthDay) Day() int

func (YearMonthDay) Equals

func (d YearMonthDay) Equals(o YearMonthDay) bool

func (YearMonthDay) IsAfter

func (d YearMonthDay) IsAfter(o YearMonthDay) bool

func (YearMonthDay) IsBefore

func (d YearMonthDay) IsBefore(o YearMonthDay) bool

func (YearMonthDay) Month

func (d YearMonthDay) Month() time.Month

func (YearMonthDay) NextDay

func (d YearMonthDay) NextDay() YearMonthDay

func (YearMonthDay) String

func (d YearMonthDay) String() string

func (YearMonthDay) Year

func (d YearMonthDay) Year() int

Jump to

Keyboard shortcuts

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