Retrieve account configuration from my.jbidwatcher.com.
| 927 | 934 | |
|---|---|---|
| 5 | 5 | import com.jbidwatcher.util.Parameters; |
| 6 | 6 | import com.jbidwatcher.util.StringTools; |
| 7 | 7 | import com.jbidwatcher.util.Constants; |
| 8 | import com.jbidwatcher.util.ZoneDate; | |
| 8 | 9 | import com.jbidwatcher.util.html.JHTML; |
| 9 | 10 | import com.jbidwatcher.util.queue.MQFactory; |
| 10 | 11 | import com.jbidwatcher.util.queue.MessageQueue; |
| --- | --- | |
| 21 | 22 | import java.io.IOException; |
| 22 | 23 | import java.net.URLEncoder; |
| 23 | 24 | import java.net.HttpURLConnection; |
| 25 | import java.util.Date; | |
| 24 | 26 | |
| 25 | 27 | /** |
| 26 | 28 | * Created by IntelliJ IDEA. |
| --- | --- | |
| 37 | 39 | private static final String ITEM_UPLOAD_URL = "http://my.jbidwatcher.com/upload/listing"; |
| 38 | 40 | private String mSyncQueueURL = null; |
| 39 | 41 | private String mReportQueueURL = null; |
| 42 | private boolean mUseSSL = false; | |
| 43 | private boolean mUploadHTML = false; | |
| 44 | private boolean mUseServerParser = false; | |
| 45 | private boolean mGixen = false; | |
| 46 | private boolean mReadSnipesFromServer = false; | |
| 47 | private ZoneDate mExpiry; | |
| 40 | 48 | |
| 41 | 49 | private Http http() { |
| 42 | 50 | if(mNet == null) { |
| --- | --- | |
| 193 | 201 | }); |
| 194 | 202 | } |
| 195 | 203 | |
| 204 | public void getAccountInfo() { | |
| 205 | StringBuffer sb = http().get("http://my.jbidwatcher.com/services/account"); | |
| 206 | XMLElement xml = new XMLElement(); | |
| 207 | xml.parseString(sb.toString()); | |
| 208 | XMLElement sync = xml.getChild("syncq"); | |
| 209 | XMLElement expires = xml.getChild("expiry"); | |
| 210 | XMLElement listingsRemaining = xml.getChild("listings"); | |
| 211 | XMLElement categoriesRemaining = xml.getChild("categories"); | |
| 212 | XMLElement reporting = xml.getChild("reportingq"); | |
| 213 | XMLElement snipesListen = xml.getChild("snipes"); | |
| 214 | XMLElement ssl = xml.getChild("ssl"); | |
| 215 | XMLElement uploadHTML = xml.getChild("uploadhtml"); | |
| 216 | XMLElement serverParser = xml.getChild("parser"); | |
| 217 | XMLElement gixen = xml.getChild("gixen"); | |
| 218 | ||
| 219 | if(expires != null) { | |
| 220 | String date = expires.getContents(); | |
| 221 | mExpiry = StringTools.figureDate(date, "yyyy-MM-dd'T'HH:mm:ss.SSSZ"); | |
| 222 | if(mExpiry.getDate().after(new Date())) { | |
| 223 | JConfig.setConfiguration("my.jbidwatcher.enabled", "false"); | |
| 224 | } | |
| 225 | } | |
| 226 | ||
| 227 | mSyncQueueURL = sync.getContents(); | |
| 228 | mReportQueueURL = reporting.getContents(); | |
| 229 | mUseSSL = getBoolean(ssl); | |
| 230 | mReadSnipesFromServer = getBoolean(snipesListen); | |
| 231 | mUploadHTML = getBoolean(uploadHTML); | |
| 232 | mUseServerParser = getBoolean(serverParser); | |
| 233 | mGixen = getBoolean(gixen); | |
| 234 | } | |
| 235 | ||
| 236 | private boolean getBoolean(XMLElement x) { | |
| 237 | boolean rval = false; | |
| 238 | if(x != null) { | |
| 239 | String contents = x.getContents(); | |
| 240 | if(contents != null) { | |
| 241 | rval = contents.equals("true"); | |
| 242 | } | |
| 243 | } | |
| 244 | ||
| 245 | return rval; | |
| 246 | } | |
| 247 | ||
| 196 | 248 | public boolean createAccount(String email, String password) { |
| 197 | 249 | // TODO - GET http://my.jbidwatcher.com/users/new |
| 198 | 250 | // POST http://my.jbidwatcher.com/users with user[email]={email}&user[password]={password}&user[password_confirmation]={password} |
