Method PostConsumptionHistoryAll

Summary

Consumption History All Service Codes

Remarks

Returns a usage history showing how much of a utility service the customer used each billing cycle. It gives a daily and total amount for each billing period. It does not give the dollar amount billed.

Usage:

This method retrieves usage information as recorded from a given meter assigned to the customer. If a customer has more than one meter, you would have to call this method for each meter separately to retrieve all the usage history for the utility service. You would also have to call this method separately for each type of utility service, such as water or electricity.

  1. Get the customer number and lcoation number using one of the Account Search methods.

It returns the following information:

Common uses:

Input Parameters

NameTypeLengthDescription
customerNumber numeric 9 [Required] Customer Number. See Account Search methods.
locationNumber numeric 9 [Required] Location Number. See Account Search methods.
Sequence numeric 3 3 digit sequence, starting at 000 indentifying the meter. See the Sequence field returned by the GetMeterDetail method.

Example

POST http://localhost/FusionServices/v3/Naviline/Utilities/ConsumptionHistoryAll

Return Values

NameDescription
Service Two letter code indicating the type of utility service. Example: WA for water
Sequence The three digit sequence number assigned to the meter. This is the order in which the meter reader reads the meter within her route. This is used to identify the meter internally.
BillingPeriod Date of the (monthly) billing period the meter read was taken. Format: MMYYYY
DaysInBillingPeriod Number of days in the billing period
DailyPeriodUsage Calculated daily usage during the billing period.
TotalPeriodUsage Total usage during the billing period.
DemandDailyPeriodUsage Calculated daily overage demand used during the billing period.
DemandTotalPeriodUsage Total overage demand usage during the billing period. Demand is the amount of usage over a set limit that may occur additional charges or a higher billing rate.

Sample Responses

Sample Code

using System.Net;
using Newtonsoft.Json.Linq;

public void MethodName(parms)
{
   string uri = "http://localhost/FusionServices/v3/Naviline/Utilities/ConsumptionHistoryAll";
   System.Collections.Specialized.NameValueCollection postParms = 
     new System.Collections.Specialized.NameValueCollection(); 
   // Set paramater values
   postParms.Add("customerNumber",System.Web.HttpUtility.UrlEncode("101"));
   postParms.Add("locationNumber",System.Web.HttpUtility.UrlEncode("33028"));

   WebClient req = new WebClient();
   wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
   wc.Headers.Set("X-APPID", "YOURID");
   wc.Headers.Set("X-APPKEY", "YOURKEY");

   byte[] responseBytes = wc.UploadValues(new Uri(uri), "POST", postParms);
   string stringResult = Encoding.UTF8.GetString(responseBytes); 
   JObject response = JObject.Parse(stringResult);
   string error = response["OutputParms"]["ErrorCode"].ToString();
   if (error == "0000")
   {
        JArray jRows = (JArray)response["Rows"];
        foreach (JObject row in jRows)
        {
             string Service = row["Service"].ToString();
             string Sequence = row["Sequence"].ToString();
             string BillingPeriod = row["BillingPeriod"].ToString();
             string DaysInBillingPeriod = row["DaysInBillingPeriod"].ToString();
             string DailyPeriodUsage = row["DailyPeriodUsage"].ToString();
             string TotalPeriodUsage = row["TotalPeriodUsage"].ToString();
             string DemandDailyPeriodUsage = row["DemandDailyPeriodUsage"].ToString();
             string DemandTotalPeriodUsage = row["DemandTotalPeriodUsage"].ToString();
             // TODO - YOUR CODE HERE
        }
   }
}

C# Razor MVC Sample Code

using System;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Collections.Specialized;
using FusionServiceHelper.Models;

// NOTE: Use the namespace generated when you add the class, so that it is correct.
namespace FusionRazor.Models
{
   public class PostConsumptionHistoryAll
   {
       // Add property for each input param in order to map a field to it
       [Required(ErrorMessage = "Required")]
       [RegularExpression("[0-9]{0,9}", ErrorMessage = "Numeric values only. Must be 9 digits or less. ")]
       public string customerNumber{get; set;}

       [Required(ErrorMessage = "Required")]
       [RegularExpression("[0-9]{0,9}", ErrorMessage = "Numeric values only. Must be 9 digits or less. ")]
       public string locationNumber{get; set;}

       [RegularExpression("[0-9]{0,3}", ErrorMessage = "Numeric values only. Must be 3 digits or less. ")]
       public string Sequence{get; set;}

       public PostConsumptionHistoryAll()
       {
           //Set any defaults here
       }
   }
}
@* NOTE: Use Add->View to add the View. *@
@* NOTE: Check the 'Create strongly-typed view checkbox, and select the PostConsumptionHistoryAll class. *@
@* NOTE: Select Edit as the Scaffold template. *@
@* NOTE: Use the @model line that is generated at the top.  Replace the rest with the lines below.
@model FusionRazor.Models.PostConsumptionHistoryAll

@{
   ViewBag.Title = "PostConsumptionHistoryAll";
}

<h2>PostConsumptionHistoryAll</h2>
@using (Html.BeginForm()) {
   @Html.AntiForgeryToken()
   @Html.ValidationSummary(true)
   <fieldset>
   <legend>PostConsumptionHistoryAll</legend>
       <div class="editor-label">
           @Html.LabelFor(model => model.customerNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.customerNumber)
           @Html.ValidationMessageFor(model => model.customerNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.locationNumber)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.locationNumber)
           @Html.ValidationMessageFor(model => model.locationNumber)
       </div>
       <div class="editor-label">
           @Html.LabelFor(model => model.Sequence)
       </div>
       <div class="editor-field">
           @Html.EditorFor(model => model.Sequence)
           @Html.ValidationMessageFor(model => model.Sequence)
       </div>
       <p>
       <input type="submit" value="Submit"/>
       </p>
   </fieldset>

}

@section Scripts {
   @Scripts.Render("~/bundles/jqueryval")
}
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FusionServiceHelper.Models;

// NOTE: Replace 'MyController' with the name of your controller.

// 
// GET: /MyController/PostConsumptionHistoryAll
public ActionResult PostConsumptionHistoryAll()
{
   // Create a new instance of the model to pick up any default values.
   PostConsumptionHistoryAll model =  new PostConsumptionHistoryAll();

   // pass model to set to default values
   // NOTE: Change 'MyFolderPath' to the path to the .cshtml file.
   return View("~/Views/MyFolderPath/PostConsumptionHistoryAll.cshtml", model);
}

// 
// POST: /MyController/PostConsumptionHistoryAll
[HttpPost]
public ActionResult PostConsumptionHistoryAll(FormCollection collection)
{
   string url = "v3/Naviline/Utilities/ConsumptionHistoryAll";
   // Get the value from each input field
   NameValueCollection inputParms = new NameValueCollection();
   inputParms.Add("customerNumber", collection["customerNumber"]);
   inputParms.Add("locationNumber", collection["locationNumber"]);
   inputParms.Add("Sequence", collection["Sequence"]);

   try
   {
       // Send the request
       FusionServiceRequest request = new FusionServiceRequest();
       FusionServiceResult result = request.Post(url, inputParms);

       return View("Result", result);
   }
   catch(Exception e)
   {
       HandleErrorInfo info = new HandleErrorInfo(e, "MyController", "PostConsumptionHistoryAll");
       return View("Error", info);
   }
}