PageRenderTime 49ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/net/suddenelfilio/ws/tag/DialerTag.java

https://bitbucket.org/suddenelfilio/mstagjavalib
Java | 129 lines | 102 code | 27 blank | 0 comment | 23 complexity | f8e6d4dd2fc98e494f944a755452ef4f MD5 | raw file
  1. package net.suddenelfilio.ws.tag;
  2. import java.net.URL;
  3. import java.util.HashMap;
  4. import java.util.Map;
  5. public final class DialerTag extends Tag
  6. {
  7. public DialerTag()
  8. {
  9. TagStatus = Status.Active;
  10. Types = ImageTypes.Jpeg;
  11. }
  12. public String PhoneNumber;
  13. public String Password;
  14. public String CurrentTitle;
  15. public URL ToURL(URLType type) throws Exception
  16. {
  17. if (MSTagService.SVCAPITOKEN == null || MSTagService.SVCAPITOKEN.equals(""))
  18. throw new Exception("Did you forget to set the MSTagService.SVCAPITOKEN with your token?");
  19. Map<String, String> mp = new HashMap<String, String>();
  20. mp.put("at", MSTagService.SVCAPITOKEN);
  21. switch (type)
  22. {
  23. case CREATE :
  24. if (IsNullOrEmpty(CategoryName))
  25. throw new Exception("The CategoryName cannot be null or empty when creating a Tag.");
  26. else
  27. mp.put("cn", CategoryName);
  28. if (IsNullOrEmpty(InteractionNote))
  29. mp.put("in", "");
  30. else
  31. mp.put("in", InteractionNote);
  32. if (IsNullOrEmpty(PhoneNumber))
  33. throw new Exception("The PhoneNumber cannot be null or empty when creating a Tag.");
  34. else
  35. mp.put("pn", PhoneNumber);
  36. if (IsNullOrEmpty(Password))
  37. mp.put("p", "");
  38. else
  39. mp.put("p", Password);
  40. if (TagStatus == null)
  41. mp.put("ts", "");
  42. else
  43. mp.put("ts", TagStatus.toString());
  44. if (IsNullOrEmpty(Title))
  45. throw new Exception("The Title cannot be null or empty when creating a Tag.");
  46. else
  47. mp.put("t", Title);
  48. if (IsNullOrEmpty(UTCEndDate))
  49. mp.put("ued", "");
  50. else
  51. mp.put("ued", UTCEndDate);
  52. if (IsNullOrEmpty(UTCStartDate))
  53. mp.put("usd", "");
  54. else
  55. mp.put("usd", UTCStartDate);
  56. return new URL(GenerateURL(mp, "CreateDialerTag"));
  57. case EDIT :
  58. if (IsNullOrEmpty(CurrentTitle))
  59. throw new Exception("The CurrentTile cannot be null or empty when editing a Tag.");
  60. else
  61. mp.put("ct", CurrentTitle);
  62. if (IsNullOrEmpty(CategoryName))
  63. mp.put("cn", "");
  64. else
  65. mp.put("cn", CategoryName);
  66. if (IsNullOrEmpty(InteractionNote))
  67. mp.put("in", "");
  68. else
  69. mp.put("in", InteractionNote);
  70. if (IsNullOrEmpty(PhoneNumber))
  71. throw new Exception("The PhoneNumber cannot be null or empty when editing a Tag.");
  72. else
  73. mp.put("pn", PhoneNumber);
  74. if (IsNullOrEmpty(Password))
  75. mp.put("p", "");
  76. else
  77. mp.put("p", Password);
  78. if (TagStatus == null)
  79. mp.put("ts", "");
  80. else
  81. mp.put("ts", TagStatus.toString());
  82. if (IsNullOrEmpty(Title))
  83. mp.put("t", "");
  84. else
  85. mp.put("t", Title);
  86. if (IsNullOrEmpty(UTCEndDate))
  87. mp.put("ued", "");
  88. else
  89. mp.put("ued", UTCEndDate);
  90. if (IsNullOrEmpty(UTCStartDate))
  91. mp.put("usd", "");
  92. else
  93. mp.put("usd", UTCStartDate);
  94. return new URL(GenerateURL(mp, "EditDialerTag"));
  95. case ACTIVE :
  96. return Activate();
  97. case PAUSE :
  98. return Pause();
  99. }
  100. return null;
  101. }
  102. }