Class: Fastly::BillingApi
- Inherits:
-
Object
- Object
- Fastly::BillingApi
- Defined in:
- lib/fastly/api/billing_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#get_invoice(opts = {}) ⇒ BillingResponse
Get an invoice Get the invoice for a given year and month.
-
#get_invoice_by_id(opts = {}) ⇒ BillingResponse
Get an invoice Get the invoice for the given invoice_id.
-
#get_invoice_by_id_with_http_info(opts = {}) ⇒ Array<(BillingResponse, Integer, Hash)>
Get an invoice Get the invoice for the given invoice_id.
-
#get_invoice_mtd(opts = {}) ⇒ BillingEstimateResponse
Get month-to-date billing estimate Get the current month-to-date estimate.
-
#get_invoice_mtd_with_http_info(opts = {}) ⇒ Array<(BillingEstimateResponse, Integer, Hash)>
Get month-to-date billing estimate Get the current month-to-date estimate.
-
#get_invoice_with_http_info(opts = {}) ⇒ Array<(BillingResponse, Integer, Hash)>
Get an invoice Get the invoice for a given year and month.
-
#initialize(api_client = ApiClient.default) ⇒ BillingApi
constructor
A new instance of BillingApi.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ BillingApi
Returns a new instance of BillingApi.
17 18 19 |
# File 'lib/fastly/api/billing_api.rb', line 17 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
15 16 17 |
# File 'lib/fastly/api/billing_api.rb', line 15 def api_client @api_client end |
Instance Method Details
#get_invoice(opts = {}) ⇒ BillingResponse
Get an invoice Get the invoice for a given year and month. Can be any month from when the Customer was created to the current month.
25 26 27 28 |
# File 'lib/fastly/api/billing_api.rb', line 25 def get_invoice(opts = {}) data, _status_code, _headers = get_invoice_with_http_info(opts) data end |
#get_invoice_by_id(opts = {}) ⇒ BillingResponse
Get an invoice Get the invoice for the given invoice_id.
95 96 97 98 |
# File 'lib/fastly/api/billing_api.rb', line 95 def get_invoice_by_id(opts = {}) data, _status_code, _headers = get_invoice_by_id_with_http_info(opts) data end |
#get_invoice_by_id_with_http_info(opts = {}) ⇒ Array<(BillingResponse, Integer, Hash)>
Get an invoice Get the invoice for the given invoice_id.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/fastly/api/billing_api.rb', line 105 def get_invoice_by_id_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice_by_id ...' end # unbox the parameters from the hash customer_id = opts[:'customer_id'] invoice_id = opts[:'invoice_id'] # verify the required parameter 'customer_id' is set if @api_client.config.client_side_validation && customer_id.nil? fail ArgumentError, "Missing the required parameter 'customer_id' when calling BillingApi.get_invoice_by_id" end # verify the required parameter 'invoice_id' is set if @api_client.config.client_side_validation && invoice_id.nil? fail ArgumentError, "Missing the required parameter 'invoice_id' when calling BillingApi.get_invoice_by_id" end # resource path local_var_path = '/billing/v2/account_customers/{customer_id}/invoices/{invoice_id}'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s)).sub('{' + 'invoice_id' + '}', CGI.escape(invoice_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/pdf']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'BillingResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] = opts.merge( :operation => :"BillingApi.get_invoice_by_id", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BillingApi#get_invoice_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_invoice_mtd(opts = {}) ⇒ BillingEstimateResponse
Get month-to-date billing estimate Get the current month-to-date estimate. This endpoint has two different responses. Under normal circumstances, it generally takes less than 5 seconds to generate but in certain cases can take up to 60 seconds. Once generated the month-to-date estimate is cached for 4 hours, and is available the next request will return the JSON representation of the month-to-date estimate. While a report is being generated in the background, this endpoint will return a ‘202 Accepted` response. The full format of which can be found in detail in our [billing calculation guide](docs.fastly.com/en/guides/how-we-calculate-your-bill). There are certain accounts for which we are unable to generate a month-to-date estimate. For example, accounts who have parent-pay are unable to generate an MTD estimate. The parent accounts are able to generate a month-to-date estimate but that estimate will not include the child accounts amounts at this time.
166 167 168 169 |
# File 'lib/fastly/api/billing_api.rb', line 166 def get_invoice_mtd(opts = {}) data, _status_code, _headers = get_invoice_mtd_with_http_info(opts) data end |
#get_invoice_mtd_with_http_info(opts = {}) ⇒ Array<(BillingEstimateResponse, Integer, Hash)>
Get month-to-date billing estimate Get the current month-to-date estimate. This endpoint has two different responses. Under normal circumstances, it generally takes less than 5 seconds to generate but in certain cases can take up to 60 seconds. Once generated the month-to-date estimate is cached for 4 hours, and is available the next request will return the JSON representation of the month-to-date estimate. While a report is being generated in the background, this endpoint will return a `202 Accepted` response. The full format of which can be found in detail in our [billing calculation guide](docs.fastly.com/en/guides/how-we-calculate-your-bill). There are certain accounts for which we are unable to generate a month-to-date estimate. For example, accounts who have parent-pay are unable to generate an MTD estimate. The parent accounts are able to generate a month-to-date estimate but that estimate will not include the child accounts amounts at this time.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/fastly/api/billing_api.rb', line 177 def get_invoice_mtd_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice_mtd ...' end # unbox the parameters from the hash customer_id = opts[:'customer_id'] # verify the required parameter 'customer_id' is set if @api_client.config.client_side_validation && customer_id.nil? fail ArgumentError, "Missing the required parameter 'customer_id' when calling BillingApi.get_invoice_mtd" end # resource path local_var_path = '/billing/v2/account_customers/{customer_id}/mtd_invoice'.sub('{' + 'customer_id' + '}', CGI.escape(customer_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'month'] = opts[:'month'] if !opts[:'month'].nil? query_params[:'year'] = opts[:'year'] if !opts[:'year'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'BillingEstimateResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] = opts.merge( :operation => :"BillingApi.get_invoice_mtd", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BillingApi#get_invoice_mtd\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#get_invoice_with_http_info(opts = {}) ⇒ Array<(BillingResponse, Integer, Hash)>
Get an invoice Get the invoice for a given year and month. Can be any month from when the Customer was created to the current month.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/fastly/api/billing_api.rb', line 35 def get_invoice_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: BillingApi.get_invoice ...' end # unbox the parameters from the hash month = opts[:'month'] year = opts[:'year'] # verify the required parameter 'month' is set if @api_client.config.client_side_validation && month.nil? fail ArgumentError, "Missing the required parameter 'month' when calling BillingApi.get_invoice" end # verify the required parameter 'year' is set if @api_client.config.client_side_validation && year.nil? fail ArgumentError, "Missing the required parameter 'year' when calling BillingApi.get_invoice" end # resource path local_var_path = '/billing/v2/year/{year}/month/{month}'.sub('{' + 'month' + '}', CGI.escape(month.to_s)).sub('{' + 'year' + '}', CGI.escape(year.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/pdf']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'BillingResponse' # auth_names auth_names = opts[:debug_auth_names] || ['token'] = opts.merge( :operation => :"BillingApi.get_invoice", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: BillingApi#get_invoice\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |