@Override public void onRun() throws Throwable { long timestamp = mFeedModel.getLatestTimestamp(mUserId); final Call<FeedResponse> feed; if (mUserId == null) { feed = mApiService.feed(timestamp); } else { feed = mApiService.userFeed(mUserId, timestamp); } Response<FeedResponse> response = feed.execute(); if (response.isSuccess()) { Post oldest = handleResponse(response.body()); mEventBus.post(new FetchedFeedEvent(true, mUserId, oldest)); } else { throw new NetworkException(response.code()); } }
public Response<CommentResponse> getCommentsOfIssue(String issue) throws IOException { return jiraEndPoints.getCommentsOfIssue(issue).execute(); }
public Response<Map<String, Object>> serverInfo() throws IOException { return jiraEndPoints.serverInfo().execute(); }
public Response<Object> getIssue(String issue) throws IOException { return jiraEndPoints.getIssue(issue).execute(); }
@Override public void onRun() throws Throwable { Post post = mPostModel.loadByClientIdAndUserId(mClientId, mUserId); if (post != null && !post.isPending()) { // looks like post probably arrived from somewhere else. Good Job! mEventBus.post(new UpdatedPostEvent(post)); return; } Response<NewPostResponse> response = mApiService.sendPost(mText, mClientId, mUserId) .execute(); if (response.isSuccess()) { NewPostResponse body = response.body(); body.getPost().setPending(false); mPostModel.save(body.getPost()); mUserModel.save(body.getUser()); mEventBus.post(new UpdatedPostEvent(body.getPost())); } else { throw new NetworkException(response.code()); } }
public Response<Comment> commentIssue(String issue, Comment comment) throws IOException { return jiraEndPoints.commentIssue(issue, comment).execute(); }
private String updateAuthenticationParams() throws IOException { sessionId = dexcomShareApi.getSessionId(new ShareAuthenticationBody(password, username).toMap()).execute().body(); dexcomShareApi.authenticatePublisherAccount(sessionId, serialNumber, new ShareAuthenticationBody(password, username).toMap()).execute().body(); dexcomShareApi.StartRemoteMonitoringSession(sessionId, serialNumber).execute(); String assignment = dexcomShareApi.checkMonitorAssignment(sessionId, serialNumber).execute().body(); if ((assignment != null) && (!assignment.equals("AssignedToYou"))) { dexcomShareApi.updateMonitorAssignment(sessionId, serialNumber).execute(); } return sessionId; }
private String updateAuthenticationParams() throws IOException { sessionId = dexcomShareApi.getSessionId(new ShareAuthenticationBody(password, username).toMap()).execute().body(); dexcomShareApi.authenticatePublisherAccount(sessionId, serialNumber, new ShareAuthenticationBody(password, username).toMap()).execute().body(); dexcomShareApi.StartRemoteMonitoringSession(sessionId, serialNumber).execute(); String assignment = dexcomShareApi.checkMonitorAssignment(sessionId, serialNumber).execute().body(); if ((assignment != null) && (!assignment.equals("AssignedToYou"))) { dexcomShareApi.updateMonitorAssignment(sessionId, serialNumber).execute(); } return sessionId; }
public Response<User> getUser(Long id) throws IOException { return gitLabEndPoints.getUser(id, gitLabConfiguration.getPrivateToken()).execute(); }
public Response<User> getLoggedUser() throws IOException { return gitLabEndPoints.getLoggedUser(gitLabConfiguration.getPrivateToken()).execute(); }
public boolean transitionOnIssue(String issue, TransitionInput transitionInput) { try { Response<Void> response = jiraEndPoints.transitionsOnIssue(issue, transitionInput).execute(); if(response.isSuccess()) { log.info("Transition {} has been made on {}", transitionInput, issue); return true; } else { log.error("Bad response received <" + response.code() + ">, " + "unable to make the transition <{}> on <{}>, received message : " + response.message(), issue, transitionInput); try { log.error("Response body received : {}", response.errorBody().string()); } catch (IOException e) { log.error("Unable to read response body", e); } } } catch (IOException e) { log.error("Unable to perform transition <{}> on <{}>", transitionInput, issue); } return false; }
@Override public List<Contact> obtainContacts() throws NetworkException { try { ApiContactsResponse apiContactsResponse = apiService.obtainUsers(100).execute().body(); List<ApiContactResult> results = apiContactsResponse.getResults(); List<Contact> contacts = new ArrayList<>(); if (results != null) { for (ApiContactResult apiContact : results) { contacts.add(mapper.map(apiContact.getUser())); } } return contacts; } catch (Throwable e) { throw new NetworkException(); } } }
@Override protected String doInBackground(String... params) { try { Boolean isActive = null; if (params[0] != null) isActive = dexcomShareApi.checkSessionActive(params[0]).execute().body(); if (isActive == null || !isActive) { return updateAuthenticationParams(); } else return params[0]; } catch (IOException e) { return null; } catch (RuntimeException e) { UserError.Log.wtf(TAG, "Painful exception processing response in updateAuthenticationParams " + e); return null; } }
@Override protected String doInBackground(String... params) { try { Boolean isActive = null; if (params[0] != null) isActive = dexcomShareApi.checkSessionActive(params[0]).execute().body(); if (isActive == null || !isActive) { return updateAuthenticationParams(); } else return params[0]; } catch (IOException e) { return null; } catch (RuntimeException e) { UserError.Log.wtf(TAG, "Painful exception processing response in updateAuthenticationParams " + e); return null; } }
@Override public void call(final Subscriber<? super Response<T>> subscriber) { // Since Call is a one-shot type, clone it for each new subscriber. final Call<T> call = originalCall.clone(); // Attempt to cancel the call if it is still in-flight on unsubscription. subscriber.add(Subscriptions.create(new Action0() { @Override public void call() { call.cancel(); } })); if (subscriber.isUnsubscribed()) { return; } try { Response<T> response = call.execute(); if (!subscriber.isUnsubscribed()) { subscriber.onNext(response); } } catch (Throwable t) { Exceptions.throwIfFatal(t); if (!subscriber.isUnsubscribed()) { subscriber.onError(t); } return; } if (!subscriber.isUnsubscribed()) { subscriber.onCompleted(); } } }