﻿'=========================================================================='
'                                                                          '
'                    (C) Copyright 2018 Devil7 Softwares.                  '
'                                                                          '
' Licensed under the Apache License, Version 2.0 (the "License");          '
' you may not use this file except in compliance with the License.         '
' You may obtain a copy of the License at                                  '
'                                                                          '
'                http://www.apache.org/licenses/LICENSE-2.0                '
'                                                                          '
' Unless required by applicable law or agreed to in writing, software      '
' distributed under the License is distributed on an "AS IS" BASIS,        '
' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. '
' See the License for the specific language governing permissions and      '
' limitations under the License.                                           '
'                                                                          '
' Contributors :                                                           '
'     Dineshkumar T                                                        '
'=========================================================================='

Imports System.Xml

Public Class Response

#Region "Properties/Fields"
        Property Data As String = ""
        Property Status As Boolean = False
        Property Created As Integer = -1
#End Region

#Region "Constructors"
        Sub New(ByVal Data As String)
            Me.Data = Data
            Try
                ReadXML(Data)
            Catch ex As Exception

            End Try
        End Sub

        Sub New(ByVal Data As String, ByVal Status As Boolean)
            Me.Status = True
            Me.Data = Data
            Try
                ReadXML(Data)
            Catch ex As Exception

            End Try
        End Sub
#End Region

#Region "Subs"
        Private Sub ReadXML(ByVal XML As String)
            Dim Doc As New XmlDocument()
            Doc.LoadXml(XML)

            'Status
            For Each i As XmlNode In Doc.GetElementsByTagName("STATUS")
                If Not String.IsNullOrEmpty(i.InnerText) Then Integer.TryParse(i.InnerText, Status)
            Next

            'No of Ledgers Created
            For Each i As XmlNode In Doc.GetElementsByTagName("CREATED")
                If Not String.IsNullOrEmpty(i.InnerText) Then Integer.TryParse(i.InnerText, Created)
            Next
        End Sub
#End Region

End Class