Skip to content

Commit

Permalink
Merge pull request #55 from tada-team/tariff-correction
Browse files Browse the repository at this point in the history
Tariff correction
  • Loading branch information
igo95862 authored Nov 11, 2021
2 parents 95a5711 + 1467e14 commit b99c3cc
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 55 deletions.
117 changes: 62 additions & 55 deletions billing_tariff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,82 @@ package tdproto

import "time"

// TariffStatus is status of tariff
type TariffStatus string
// TariffBilling struct of billing api
type TariffBilling struct {
// Date of closing tariff
CloseDate *time.Time `json:"close_date,omitempty"`

const (
// ActiveTariff is active tariff status
ActiveTariff TariffStatus = "Active"
// Cost of one workplace
CostWorkplace string `json:"cost_workplace"`

// ArchiveTariff is archive tariff status
ArchiveTariff TariffStatus = "Archive"
)
// Currency of tariff
Currency Currency `json:"currency"`

// TariffBilling struct of billing api
type TariffBilling struct {
// Disk space limit per user
DiskSpaceQuota string `json:"disk_space_quota"`

// Count of free workspaces
FreeWorkplace int32 `json:"free_workplace"`

// Flag of availability of free seats when exceeding FreeWorkplace
IsBillingFree bool `json:"billing_free"`

// Flag of accounting without looking at the number of days before the billing period
IsBillingFullTime bool `json:"billing_full_time"`

// Default tariff flag that is set when registering an account
IsDefaultTariff bool `json:"default_tariff"`

// Flag for accounting for unspent days when switching to a new tariff
IsRecalcChangeTariff bool `json:"recalc_change_tariff"`

// Maximum count of users in voice conference
MaxVoiceUser int32 `json:"max_voice_user"`

// Maximum count of users in video conference
MaxVideoUser int32 `json:"max_video_user"`

// Date of opening tariff
OpenDate *time.Time `json:"open_date"`

// Number of paid days
PeriodDays int32 `json:"period_days"`

// Status of tariff
Status TariffStatus `json:"status"`

// Tariff id
TariffId int64 `json:"tariff_id,omitempty"`
TariffId int64 `json:"tariff_id"`

// Name of tariff
TariffName string `json:"tariff_name,omitempty"`
TariffName string `json:"tariff_name"`
}

// Count of free workspaces
FreeWorkplace int32 `json:"free_workplace,omitempty"`
// CreateTariffRequest request on create tariff
type CreateTariffRequest struct {
// Date of closing tariff
CloseDate *time.Time `json:"close_date,omitempty"`

// Cost of one workplace
CostWorkplace string `json:"cost_workplace,omitempty"`

// Currency of tariff
Currency Currency `json:"currency"`

// Disk space limit per user
DiskSpaceQuota string `json:"disk_space_quota,omitempty"`

// Count of free workspaces
FreeWorkplace int32 `json:"free_workplace,omitempty"`

// Flag of availability of free seats when exceeding FreeWorkplace
IsBillingFree bool `json:"billing_free,omitempty"`

// Flag of accounting without looking at the number of days before the billing period
IsBillingFullTime bool `json:"billing_full_time,omitempty"`

// Number of paid days
PeriodDays int32 `json:"period_days,omitempty"`

// Cost of one workplace
CostWorkplace string `json:"cost_workplace,omitempty"`

// Currency of tariff in ISO
Currency string `json:"currency,omitempty"`
// Default tariff flag that is set when registering an account
IsDefaultTariff bool `json:"default_tariff,omitempty"`

// Flag for accounting for unspent days when switching to a new tariff
IsRecalcChangeTariff bool `json:"recalc_change_tariff,omitempty"`
Expand All @@ -52,37 +88,14 @@ type TariffBilling struct {
// Maximum count of users in video conference
MaxVideoUser int32 `json:"max_video_user,omitempty"`

// Default tariff flag that is set when registering an account
IsDefaultTariff bool `json:"default_tariff,omitempty"`

// Date of opening tariff
OpenDate *time.Time `json:"open_date,omitempty"`

// Date of closing tariff
CloseDate *time.Time `json:"close_date,omitempty"`

// Status of tariff
Status TariffStatus `json:"status,omitempty"`
}

// CreateTariffRequest request on create tariff
type CreateTariffRequest struct {
TariffBilling
}

// CreateTariffResponse response on create tariff
type CreateTariffResponse struct {
TariffBilling
}

// GetTariffByIdRequest request on get tariff by ID
type GetTariffByIdRequest struct {
Id int64 `json:"id,omitempty"`
}
// Number of paid days
PeriodDays int32 `json:"period_days"`

// GetTariffByIdResponse response on get tariff by ID
type GetTariffByIdResponse struct {
TariffBilling
// Name of tariff
TariffName string `json:"tariff_name"`
}

// GetTariffsListResponse response on get tariffs list
Expand All @@ -97,7 +110,6 @@ type GetActiveTariffsListResponse struct {

// CloseTariffRequest request on close(archive) tariff
type CloseTariffRequest struct {
TariffId int64 `json:"tariff_id,omitempty"`
CloseDate time.Time `json:"close_date,omitempty"`
}

Expand All @@ -106,11 +118,6 @@ type CloseTariffResponse struct {
Success bool `json:"success"`
}

// SetTariffAsDefaultRequest request on set tariff as default
type SetTariffAsDefaultRequest struct {
TariffId int64 `json:"tariff_id,omitempty"`
}

// SetTariffAsDefaultResponse response on set tariff as default
type SetTariffAsDefaultResponse struct {
Success bool `json:"success"`
Expand Down
15 changes: 15 additions & 0 deletions currency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package tdproto

// ISO 4217 currency code
type Currency string

const (
// Euro
EUR Currency = "EUR"

// Russian ruble
RUB Currency = "RUB"

// United States dollar
USD Currency = "USD"
)
12 changes: 12 additions & 0 deletions tariff_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package tdproto

// Tariff status
type TariffStatus string

const (
// Tariff is active
ActiveTariff TariffStatus = "Active"

// Tariff in archive
ArchiveTariff TariffStatus = "Archive"
)

0 comments on commit b99c3cc

Please sign in to comment.