<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="../notes.xsl"?>
<Documentation>
	<Title code="0310">ReportStandard</Title>
	<Overview>
			<p>Schema to supply full details of messages sent as specified by a time-period and filtering options.</p>
	</Overview>
	<Request schema="0310_RequestReportStandard.xsd">
		<p>The 'UserID' and 'Password' elements identify the account.
			The 'ServiceName' element must be set to 'ReportStandard'.
			The 'SoftwareVersion' element is for internal 2SMS use only and should not be set.</p>
        <p>The 'ServiceDetail' element may have an optional boolean 'reportError' attribute. If this
            is set to 'true' then any additional information on message progress reported by the SMS
            network will be included along with the 'Status' information.</p>
		<p>The 'ServiceDetail' element may contain a variety of elements to set date range and filtering options for the report.
			The different options can be classified by the name of the first element.</p>
			<h3>1. An initial 'DateRange' element.</h3>
			<p>The 'DateRange' element determines the time period for the report according to one of three options:</p>
			<ul>
				<li>With 'StartDate' and 'EndDate' children it returns a report for an explicitly specified time-period (up to 31 days).
					The DateTime information must be supplied in one of these ISO-8601 formats:
					<ul>
						<li>yyyy-MM-dd'T'HH:mm:ss.SSS in the time-zone registered with the account.</li>
						<li>yyyy-MM-dd'T'HH:mm:ss.SSS'Z' in coordinated universal time (the 'useUTC' attribute must be set to true).</li>
					</ul></li>
				<li>With a 'RelativeName' child it runs a report for a relative time period described by one of the enumerated values:
					'Today'; 'Yesterday'; 'This Month'; or 'Last Month'.
					This is evaluated with respect to the time-zone registered with the account.</li>
				<li>With a 'RecentDays' child it runs a report for the specified period of days (up to 14)
					in the time-zone registered with the account.
					E.g. a value of two would cover the time period from the start of the previous day until the current time.</li>
			</ul>
			<p>The 'RelativeName' and 'RecentDays' elements may be followed by a 'SavedReport' element.
				This stores the report generating information for use with code <a href="./0360_documentation.xml"> 0360</a> requests.
				The 'SavedReport' element must contain the following children:</p>
				<ul>
					<li>A 'Name' element containing the name to identify the report in future.</li>
					<li>A 'Format' element containing any additional information useful to the client application (e.g. format for results).</li>
				</ul>
			<p>The remaining XML nodes that accompany a 'DateRange' element are as follows:</p>
			<ul>
				<li>An optional 'useUTC' attribute set to true if date input and output is to be in coordinated universal time.</li>
				<li>An optional 'Status' element to filter results with a specific delivery status (e.g. Success, WithNetwork or Failed).</li>
				<li>An optional 'Destination' element to filter results sent to a specific destination.</li>
				<li>An optional 'GUID' element to filter results with a specific GUID reference value.</li>
				<li>A compulsory 'Paging' element whose 'ItemsPerPage' attribute determines the number of items on the report's first page.</li>
			</ul>
			<h3>2. An initial 'ReportPage' element.</h3>
			<p>This method is used to extract subsequent pages of data from a previously run report.
				Reports are retained for at least 20 minutes since the last request for a page from the report.
				The following child nodes are supplied:</p>
				<ul>
					<li>A compulsory 'ReportID' element identifies the report (obtained from the previous XML report response).</li>
					<li>A compulsory 'Page' element determines the page of results for the given number of ItemsPerPage.</li>
					<li>A compulsory 'ItemsPerPage' element determines the number of items on the returned page.</li>
					<li>An optional 'useUTC' attribute set to true if date output is to be in coordinated universal time.</li>
				</ul>
			<h3>3. An initial 'Batch' element.</h3>
			<p>This method returns results for a specific batch (see code <a href="./0350_documentation.xml">0350</a> for a definition).
				The following child elements may be supplied:</p>
				<ul>
					<li>A 'GUID' element (the original GUID reference of the batch).</li>
					<li>A 'DateID' element (an integer timestamp based on when the initial message request was received).</li>
					<li>An optional 'useUTC' attribute set to true if date output is to be in coordinated universal time.</li>
				</ul>
				<p>The 'GUID' and 'DateID' for a batch may be obtained from a call to ReportRecentBatches
					(code <a href="./0350_documentation.xml">0350</a>)
					or extracted from a response to a SendMessage request (code <a href="./0410_documentation.xml">0410</a>).</p>
			<h3>4. An initial 'LoggedReport' element.</h3>
			<p>This method covers two report types whose results depend on when the report was last run:</p>
			<ul>
				<li>With the text content 'messagesSinceLastRequest' the method returns all messages sent
					since this report was last run (provided they fall within the current or previous month).</li>
				<li>With the text content 'messageStatusChanges' the method returns all messages either sent, or whose 'Status'
					has changed, since this report was last run (provided this occurred within the last four days).</li>
				<li>The optional 'useUTC' attribute should be set to true if date output is to be in coordinated universal time.</li>
			</ul>
			<h3>5. Deprecated methods.</h3>
			<p>A number of additional options appear in the schema to support legacy applications with non ISO-8601 DateTime formats.
				They should not be used in new applications as support may be removed in future.</p>
			<ul>
				<li>A 'ReportName' element: use 'DateRange' with 'RelativeName' or 'LoggedReport' child instead.</li>
				<li>A 'GUID' and 'ReportName' element: use appropriate 'DateRange' method with filtering by the 'GUID' element.</li>
				<li>A 'StartDate', 'EndDate' and 'ReportName' element: use 'DateRange' with 'StartDate' and 'EndDate' children instead.</li>
			</ul>
	</Request>
	<Response schema="0310_ResponseReportStandard.xsd">
		<p>This method returns a successful "00/OK" response if the report is successfully retrieved.
			The 'Result' element contains the number of 'Record' elements.
			The 'Detail' element contains a 'ReportTitle' element which describes the report,
			and a set of 'Record' elements, each of which describes a single SMS or email message.
			Each record contains the following children:</p>
			<ul>
				<li>The 'Destination' element contains the email or SMS number of the message's recipient.</li>
				<li>The 'Status' element contains information on whether the submission failed, was successful, or is still awaiting confirmation.</li>
                <li>When requested the 'Error' element contains any additional information on message progress reported by the SMS network.</li>
                <li>The 'GUID' element contains the GUID reference value for the message.</li>
				<li>The 'DateSubmitted' element contains the time at which 2SMS received the message from the client application.</li>
				<li>The 'DateToSend' contains the time at which the message was scheduled to be sent to its destination.
					The element will be empty if the message was requested to be sent as soon as received by 2SMS.</li>
				<li>The 'DateSent' element contains the date at which 2SMS received acknowledgement that our SMS network
					connection had received the message and accepted it (not supplied for deprecated methods).</li>
				<li>The 'DateReceived' element contains the date at which 2SMS last received a 'delivery receipt' for the message from our
					SMS network connection (this covers various options including, but not limited to message delivery to the handset).</li>
				<li>The 'Message' element contains the actual text of the SMS message. Components of a long SMS 
					message commence with 'part number/total parts:' string (e.g. '1/2:')</li>
				<li>The 'ID' element contains a unique message ID that can be used in correspondence with 2SMS.</li>
			</ul>
		<p>Times are returned in ISO-8601 format (except for deprecated methods).
			They are in the time-zone registered with the user's account unless the 'useUTC' attribute was set to true,
			in which case they are in coordinated universal time.</p>
		<p>All 'DateRange' methods and the 'ReportPage' method also return a 'ReportPage' element with the following children:</p>
			<ul>
				<li>The 'ReportID' element identifies the report for the retrieval of further pages.</li>
				<li>The 'ItemsPerPage' element is the requested number of items per page.</li>
				<li>The 'Page' element is the current page index of the report.</li>
				<li>The 'TotalItems' element is the total number of records in the entire report.</li>
			</ul>
	</Response>
</Documentation>
