Skip to content

Commit

Permalink
Merge pull request #52 from tada-team/billing
Browse files Browse the repository at this point in the history
refactor: change omitempty params
  • Loading branch information
igo95862 authored Nov 11, 2021
2 parents b20bb1d + 26e9b12 commit 95a5711
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
38 changes: 30 additions & 8 deletions billing_personal_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,31 @@ package tdproto

import "time"

// PersonalAccountStatus is status of personal account
type PersonalAccountStatus string

const (
// ActiveAccount is active account status
ActiveAccount PersonalAccountStatus = "Active"

// SuspendedAccount is financial blocking account status
SuspendedAccount PersonalAccountStatus = "Suspended"

// BlockedAccount is account administrative blocking status
BlockedAccount PersonalAccountStatus = "Blocked"
)

// PersonalAccountBilling struct of billing api
type PersonalAccountBilling struct {

// PersonalAccountBilling ID
PersonalAccountId int64 `json:"personal_account_id"`
PersonalAccountId int64 `json:"personal_account_id,omitempty"`

// Full name of owner personal account
FullName string `json:"full_name,omitempty"`

// Phone number of owner account
Phone string `json:"phone,omitempty"`

// ID User who owns this personal account
OwnerUuid string `json:"owner_uuid"`
Expand All @@ -24,7 +44,7 @@ type PersonalAccountBilling struct {
DiscountAmount int32 `json:"discount_amount"`

// Status of personal account
Status string `json:"status"`
Status PersonalAccountStatus `json:"status"`

// Date of next debiting funds
NextBillingDate time.Time `json:"next_billing_date"`
Expand All @@ -48,6 +68,8 @@ type PersonalAccountBilling struct {
// CreatePersonalAccountRequest request on create personal account
type CreatePersonalAccountRequest struct {
OwnerUuid string `json:"owner_uuid"`
FullName string `json:"full_name,omitempty"`
Phone string `json:"phone,omitempty"`
TeamUuid string `json:"team_uuid"`
}

Expand All @@ -58,7 +80,7 @@ type CreatePersonalAccountResponse struct {

// GetPersonalAccountByIDRequest request on get personal account by ID
type GetPersonalAccountByIDRequest struct {
PersonalAccountId int64 `json:"personal_account_id"`
PersonalAccountId int64 `json:"personal_account_id,omitempty"`
}

// GetPersonalAccountByIDResponse response on get personal account by ID
Expand All @@ -80,12 +102,12 @@ type Options struct {

// GetPersonalAccountsListResponse response on get list of personal accounts
type GetPersonalAccountsListResponse struct {
PersonalAccounts []PersonalAccountBilling `json:"personal_accounts"`
PersonalAccounts []PersonalAccountBilling `json:"personal_accounts,omitempty"`
}

// ActivatePersonalAccountRequest request on activate suspended personal account
type ActivatePersonalAccountRequest struct {
PersonalAccountId int64 `json:"personal_account_id"`
PersonalAccountId int64 `json:"personal_account_id,omitempty"`
}

// ActivatePersonalAccountResponse response on activate suspended personal account
Expand All @@ -95,7 +117,7 @@ type ActivatePersonalAccountResponse struct {

// BlockPersonalAccountRequest request on block unblocked personal account
type BlockPersonalAccountRequest struct {
PersonalAccountId int64 `json:"personal_account_id"`
PersonalAccountId int64 `json:"personal_account_id,omitempty"`
}

// BlockPersonalAccountResponse response on block unblocked personal account
Expand All @@ -105,7 +127,7 @@ type BlockPersonalAccountResponse struct {

// UnblockPersonalAccountRequest request on unblock blocked personal account
type UnblockPersonalAccountRequest struct {
PersonalAccountId int64 `json:"personal_account_id"`
PersonalAccountId int64 `json:"personal_account_id,omitempty"`
}

// UnblockPersonalAccountResponse response on unblock blocked personal account
Expand All @@ -115,7 +137,7 @@ type UnblockPersonalAccountResponse struct {

// SuspendPersonalAccountRequest request on suspend active personal account
type SuspendPersonalAccountRequest struct {
PersonalAccountId int64 `json:"personal_account_id"`
PersonalAccountId int64 `json:"personal_account_id,omitempty"`
}

// SuspendPersonalAccountResponse response on suspend active personal account
Expand Down
21 changes: 16 additions & 5 deletions billing_tariff.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,22 @@ package tdproto

import "time"

// TariffStatus is status of tariff
type TariffStatus string

const (
// ActiveTariff is active tariff status
ActiveTariff TariffStatus = "Active"

// ArchiveTariff is archive tariff status
ArchiveTariff TariffStatus = "Archive"
)

// TariffBilling struct of billing api
type TariffBilling struct {

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

// Name of tariff
TariffName string `json:"tariff_name,omitempty"`
Expand Down Expand Up @@ -51,7 +62,7 @@ type TariffBilling struct {
CloseDate *time.Time `json:"close_date,omitempty"`

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

// CreateTariffRequest request on create tariff
Expand All @@ -66,7 +77,7 @@ type CreateTariffResponse struct {

// GetTariffByIdRequest request on get tariff by ID
type GetTariffByIdRequest struct {
Id int64 `json:"id"`
Id int64 `json:"id,omitempty"`
}

// GetTariffByIdResponse response on get tariff by ID
Expand All @@ -86,7 +97,7 @@ type GetActiveTariffsListResponse struct {

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

Expand All @@ -97,7 +108,7 @@ type CloseTariffResponse struct {

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

// SetTariffAsDefaultResponse response on set tariff as default
Expand Down

0 comments on commit 95a5711

Please sign in to comment.