github.com/sacloud/iaas-api-go@v1.12.0/naked/bill.go (about)

     1  // Copyright 2022-2023 The sacloud/iaas-api-go Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package naked
    16  
    17  import (
    18  	"time"
    19  
    20  	"github.com/sacloud/iaas-api-go/types"
    21  )
    22  
    23  // Bill 請求情報
    24  type Bill struct {
    25  	ID             types.ID   `json:"BillID,omitempty" yaml:"bill_id,omitempty" structs:",omitempty"`    // 請求ID
    26  	Amount         int64      `json:",omitempty" yaml:"amount,omitempty" structs:",omitempty"`           // 金額
    27  	Date           *time.Time `json:",omitempty" yaml:"date,omitempty" structs:",omitempty"`             // 請求日
    28  	MemberID       string     `json:",omitempty" yaml:"member_id,omitempty" structs:",omitempty"`        // 会員ID
    29  	Paid           bool       `yaml:"paid"`                                                              // 支払済フラグ
    30  	PayLimit       *time.Time `json:",omitempty" yaml:"pay_limit,omitempty" structs:",omitempty"`        // 支払い期限
    31  	PaymentClassID types.ID   `json:",omitempty" yaml:"payment_class_id,omitempty" structs:",omitempty"` // 支払いクラスID
    32  }
    33  
    34  // BillDetail 支払い明細情報
    35  type BillDetail struct {
    36  	ID               types.ID   `json:"ContractID,omitempty" yaml:"contract_id,omitempty" structs:",omitempty"` // 契約ID
    37  	Amount           int64      `json:",omitempty" yaml:"amount,omitempty" structs:",omitempty"`                // 金額
    38  	Description      string     `yaml:"description"`                                                            // 説明
    39  	Index            int        `json:",omitempty" yaml:"index,omitempty" structs:",omitempty"`                 // インデックス
    40  	ServiceClassID   types.ID   `json:",omitempty" yaml:"service_class_id,omitempty" structs:",omitempty"`      // サービスクラスID
    41  	ServiceClassPath string     `json:",omitempty" yaml:"service_class_path,omitempty" structs:",omitempty"`    // サービスクラスパス
    42  	Usage            int64      `json:",omitempty" yaml:"usage,omitempty" structs:",omitempty"`                 // 利用量(秒数など)
    43  	FormattedUsage   string     `json:",omitempty" yaml:"formatted_usage,omitempty" structs:",omitempty"`       // 利用量(フォーマット済)
    44  	ServiceUsagePath string     `json:",omitempty" yaml:"service_class_path,omitempty" structs:",omitempty"`    // サービス利用量の種類
    45  	Zone             string     `json:",omitempty" yaml:"zone,omitempty" structs:",omitempty"`                  // ゾーン
    46  	ContractEndAt    *time.Time `json:",omitempty" yaml:"contract_end_at,omitempty" structs:",omitempty"`       // 契約終了日時
    47  }
    48  
    49  // IsContractEnded 支払済か判定
    50  func (d *BillDetail) IsContractEnded(t time.Time) bool {
    51  	return d.ContractEndAt != nil && d.ContractEndAt.Before(t)
    52  }
    53  
    54  // BillDetailCSV 請求明細CSVレスポンス
    55  type BillDetailCSV struct {
    56  	// Count 件数
    57  	Count int `json:",omitempty"`
    58  	// ResponsedAt 応答日時
    59  	ResponsedAt *time.Time `json:",omitempty"`
    60  	// Filename ファイル名
    61  	Filename string `json:",omitempty"`
    62  	// RawBody ボディ(未加工)
    63  	RawBody string `json:"Body,omitempty"`
    64  	// HeaderRow ヘッダ行
    65  	HeaderRow []string
    66  	// BodyRows ボディ(各行/各列での配列)
    67  	BodyRows [][]string
    68  }