LoginResponse.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package response
  2. import (
  3. "encoding/xml"
  4. "log"
  5. )
  6. type Header struct {
  7. Status string `xml:"header>status"`
  8. }
  9. type AccountDetails struct {
  10. XMLName xml.Name `xml:"res"`
  11. Header
  12. Username string `xml:"body>username"`
  13. Currency string `xml:"body>currency"`
  14. AccountId int64 `xml:"body>accountId"`
  15. AccountType string `xml:"body>accountType"`
  16. ProductType string `xml:"body>productType"`
  17. RegistrationLegalEntity string `xml:"body>registrationLegalEntity"`
  18. DisplayLocale string `xml:"body>displayLocale"`
  19. FundingDisallowed bool `xml:"body>fundingDisallowed"`
  20. AvailableAccounts []AccountItem `xml:"body>availableAccounts>account"`
  21. AvailableSchemes string `xml:"body>availableSchemes"`
  22. UserPreferences
  23. }
  24. type AccountItem struct {
  25. AccountId string `xml:"accountId"`
  26. AccountName string `xml:"accountName"`
  27. }
  28. type UserPreferences struct {
  29. Version string `xml:"body>userPreferences>version"`
  30. Categories []PreferencesCategory `xml:"body>userPreferences>category"`
  31. }
  32. type PreferencesCategory struct {
  33. Name string `xml:"name"`
  34. Items []PreferencesItem `xml:"item"`
  35. }
  36. type PreferencesItem struct {
  37. Id string `xml:"id"`
  38. Value string `xml:"value"`
  39. }
  40. func NewAccountDetails(data string) *AccountDetails {
  41. r := AccountDetails{}
  42. err := xml.Unmarshal([]byte(data), &r)
  43. if err != nil {
  44. log.Println(err)
  45. return nil
  46. }
  47. return &r
  48. }