github.com/decred/politeia@v1.4.0/politeiawww/cmd/cmswww/invoiceexchangerate.go (about) 1 // Copyright (c) 2017-2019 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package main 6 7 import ( 8 "github.com/decred/politeia/politeiawww/api/cms/v1" 9 "github.com/decred/politeia/politeiawww/cmd/shared" 10 ) 11 12 // NewInvoiceCmd submits a new invoice. 13 type InvoiceExchangeRateCmd struct { 14 Args struct { 15 Month uint `positional-arg-name:"month"` // Invoice Month 16 Year uint `positional-arg-name:"year"` // Invoice Year 17 } `positional-args:"true" optional:"true"` 18 } 19 20 // Execute executes the new invoice command. 21 func (cmd *InvoiceExchangeRateCmd) Execute(args []string) error { 22 month := cmd.Args.Month 23 year := cmd.Args.Year 24 25 ier := &v1.InvoiceExchangeRate{ 26 Month: month, 27 Year: year, 28 } 29 30 // Print request details 31 err := shared.PrintJSON(ier) 32 if err != nil { 33 return err 34 } 35 36 // Send request 37 ierr, err := client.InvoiceExchangeRate(ier) 38 if err != nil { 39 return err 40 } 41 42 // Print response details 43 return shared.PrintJSON(ierr) 44 } 45 46 const invoiceExchangeRateHelpMsg = `invoiceexchangerate [flags]" 47 48 Request an USD/DCR exchange rate for a given month. 49 50 Arguments: 51 1. month (string, required) Month (MM, 01-12) 52 2. year (string, required) Year (YYYY) 53 54 55 Result: 56 { 57 "exchangerate": (float64) Calculated rate 58 }`