retrofit.http.Header Java Examples

The following examples show how to use retrofit.http.Header. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MockAuthWebService.java    From divide with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<Void> sendUserData(@Header("Authorization") String authToken, @Path("userId") final String userId, @Body final Map<String, ?> data) {
    verifyAuthToken(authToken);
    return Observable.create(new Observable.OnSubscribe<Void>() {
        @Override
        public void call(Subscriber<? super Void> subscriber) {
            try {
                System.err.println("Saving: " + userId + ", " + data);
                authServerLogic.recieveUserData(userId, data);
                subscriber.onNext(null);
            } catch (DAO.DAOException e) {
                subscriber.onError(e);
            }
        }
    });
}
 
Example #2
Source File: MockAuthWebService.java    From divide with Apache License 2.0 6 votes vote down vote up
@Override
public Observable<Map<String,Object>> getUserData(@Header("Authorization") final String authToken, final String userId) {
    verifyAuthToken(authToken);
    return Observable.create(new Observable.OnSubscribe<Map<String,Object>>() {
        @Override
        public void call(Subscriber<? super Map<String,Object>> subscriber) {
            try {
                Credentials x = authServerLogic.getUserById(userId);
                TransientObject to = ObjectUtils.get1stOrNull(x);
                if(to!=null){
                    subscriber.onNext(authServerLogic.sendUserData(userId));
                } else {
                    subscriber.onNext(null);
                }
            } catch (DAO.DAOException e) {
                subscriber.onError(e);
            }
        }
    });

}
 
Example #3
Source File: DatadogRemoteService.java    From kayenta with Apache License 2.0 5 votes vote down vote up
@GET("/api/v1/query")
DatadogTimeSeries getTimeSeries(
    @Header("DD-API-KEY") String apiKey,
    @Header("DD-APPLICATION-KEY") String applicationKey,
    @Query("from") int startTimestamp,
    @Query("to") int endTimestamp,
    @Query("query") String query);
 
Example #4
Source File: MockDataWebService.java    From divide with Apache License 2.0 5 votes vote down vote up
@Override
public <B extends BackendObject> Observable<Void> save(@Header("Authorization") String authToken, final @Body Collection<B> objects) {
    verifyAuthToken(authToken);
    return Observable.create(new Observable.OnSubscribe<Void>() {
        @Override
        public void call(Subscriber<? super Void> subscriber) {
            try {
                dao.save((B[]) objects.toArray());
                subscriber.onNext(null);
            } catch (DAO.DAOException e) {
                subscriber.onError(e);
            };
        }
    });
}
 
Example #5
Source File: UserService.java    From hacker-news-android with Apache License 2.0 5 votes vote down vote up
@FormUrlEncoded
@POST("/comment")
Observable<Object> postComment(@Header("Cookie") String cookie,
                               @Field("goto") String gotoParam,
                               @Field("hmac") String hmac,
                               @Field("parent") Long parentId,
                               @Field("text") String text);
 
Example #6
Source File: PagesService.java    From Android-REST-API-Explorer with MIT License 5 votes vote down vote up
/**
 * Creates a new page in a section specified by section title
 *
 * @param version
 * @param name
 * @param content
 * @param callback
 */
@POST("/{version}/me/notes/pages")
void postPagesInSection(
        @Header("Content-type") String contentTypeHeader,
        @Path("version") String version,
        @Query("sectionName") String name,
        @Body TypedString content,
        Callback<Envelope<Page>> callback
);
 
Example #7
Source File: BitlyRetrofitService.java    From android-auth-manager with Apache License 2.0 5 votes vote down vote up
@Headers({ACCEPT_JSON_HEADER})
@FormUrlEncoded
@POST("/oauth/access_token")
BitlyOAuthToken getToken(@Header("Authorization") String authorizationHeader,
                                 @Field("grant_type") String grantType,
                                 @Field("username") String username,
                                 @Field("password") String password);
 
Example #8
Source File: PagesService.java    From Android-REST-API-Explorer with MIT License 5 votes vote down vote up
/**
 * @param version
 * @param id
 * @param callback
 */
@GET("/{version}/me/notes/pages/{id}/content")
void getPageContentById(
        @Path("version") String version,
        @Path("id") String id,
        @Header("Accept") String acceptType,
        Callback<Response> callback
);
 
Example #9
Source File: RestMethodInfo.java    From android-discourse with Apache License 2.0 5 votes vote down vote up
private List<retrofit.client.Header> parseHeaders(String[] headers) {
    List<retrofit.client.Header> headerList = new ArrayList<retrofit.client.Header>();
    for (String header : headers) {
        int colon = header.indexOf(':');
        if (colon == -1 || colon == 0 || colon == headers.length - 1) {
            throw new IllegalStateException("Header must be in the form 'Name: Value': " + header);
        }
        headerList.add(new retrofit.client.Header(header.substring(0, colon), header.substring(colon + 1).trim()));
    }
    return headerList;
}
 
Example #10
Source File: WavefrontRemoteService.java    From kayenta with Apache License 2.0 5 votes vote down vote up
@GET("/api/v2/chart/api")
WavefrontTimeSeries fetch(
    @Header("Authorization") String authorization,
    @Query("n") String name,
    @Query("q") String query,
    @Query("s") Long startTime,
    @Query("e") Long endTime,
    @Query("g") String granularity,
    @Query("summarization") String summarization,
    @Query("listMode") boolean listMode,
    @Query("strict") boolean strict,
    @Query("sorted") boolean sorted);
 
Example #11
Source File: GitHubService.java    From hello-pinnedcerts with MIT License 4 votes vote down vote up
/**
 * Fetches public information about a user.
 *
 * @param user Github username
 * @param callback callback to notify the results as User object
 */
@GET("/users/{user}")
@Headers("User-Agent: hello-pinnedcerts")
void getUser(
        @Path("user") String user,
        @Header("Authorization") String authorizationHeader,
        Callback<User> callback

);
 
Example #12
Source File: GithubService.java    From WeGit with Apache License 2.0 4 votes vote down vote up
@POST("authorizations")
Observable<Response<Token>> createToken(@Body Token token, @Header("Authorization") String authorization) ;
 
Example #13
Source File: UserService.java    From hacker-news-android with Apache License 2.0 4 votes vote down vote up
@GET("/vote")
Observable<Object> vote(@Header("Cookie") String cookie,
                        @Query("for") Long parentId,
                        @Query("dir") String direction,
                        @Query("auth") String auth,
                        @Query("goto") String gotoParam);
 
Example #14
Source File: GithubService.java    From WeGit with Apache License 2.0 4 votes vote down vote up
@DELETE("authorizations/{id}")
Observable<Response<Empty>> removeToken(@Header("Authorization") String authorization, @Path("id") String id) ;
 
Example #15
Source File: GithubService.java    From WeGit with Apache License 2.0 4 votes vote down vote up
@GET("authorizations")
Observable<Response<List<Token>>> listToken(@Header("Authorization") String authorization) ;
 
Example #16
Source File: INsRestApi.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@GET("/api/v1/entries.json?find[type][$eq]=sgv")
Call<List<NightscoutBg>> getSgv(
        @Header("api-secret") String key,
        @Query("find[date][$gt]") long date,
        @Query("count") long count
);
 
Example #17
Source File: INsRestApi.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@GET("/api/v1/entries.json?find[type][$eq]=mbg")
Call<List<NightscoutMbg>> getMbg(
        @Header("api-secret") String key,
        @Query("find[date][$gte]") long date,
        @Query("count") long count
);
 
Example #18
Source File: INsRestApi.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@GET("/api/v1/entries.json?find[type][$eq]=sensor")
Call<List<NightscoutSensor>> getSensor(
        @Header("api-secret") String key,
        @Query("find[date][$gte]") long date,
        @Query("count") long count
);
 
Example #19
Source File: NightscoutUploader.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("entries")
Call<ResponseBody> upload(@Header("api-secret") String secret, @Body RequestBody body);
 
Example #20
Source File: NightscoutUploader.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("devicestatus")
Call<ResponseBody> uploadDeviceStatus(@Header("api-secret") String secret, @Body RequestBody body);
 
Example #21
Source File: MockDataWebService.java    From divide with Apache License 2.0 4 votes vote down vote up
@Override
public Response get(@Header("Authorization") String authToken, @EncodedPath("objectType") String objectType, @Body Collection<String> keys) {
    verifyAuthToken(authToken);
    try {
        Collection<TransientObject> got = dao.get(objectType, keys.toArray(new String[keys.size()]));
        return new GsonResponse("",200,"",null, got).build();
    } catch (DAO.DAOException e) {
        return new GsonResponse("",e.getStatusCode(),e.getMessage(), null, null).build();
    }
}
 
Example #22
Source File: MockDataWebService.java    From divide with Apache License 2.0 4 votes vote down vote up
@Override
public Observable<Integer> count(@Header("Authorization") String authToken, @EncodedPath("objectType") String objectType) {
    verifyAuthToken(authToken);
    return Observable.from(dao.count(objectType));
}
 
Example #23
Source File: WorkingWithRetrofitTest.java    From rxsnappy with Apache License 2.0 4 votes vote down vote up
@POST("/{brand}")
Observable<DummyData> getDummyData(@Header("Auth") String token, @Body DummyData requestData);
 
Example #24
Source File: HockeyApp.java    From foam with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/api/2/apps")
void getApps(@Header("X-HockeyAppToken") String apiKey,
             Callback<HockeyAppsDTO> callback
);
 
Example #25
Source File: Version11xServerApi.java    From apiman-cli with Apache License 2.0 4 votes vote down vote up
@PUT("/organizations/{orgName}/services/{serviceName}/versions/{version}/definition")
Response setDefinition(@Path("orgName") String orgName, @Path("serviceName") String serviceName,
                       @Path("version") String version, @Header("Content-Type") String type, @Body TypedString content);
 
Example #26
Source File: Version12xServerApi.java    From apiman-cli with Apache License 2.0 4 votes vote down vote up
@PUT("/organizations/{orgName}/apis/{serviceName}/versions/{version}/definition")
Response setDefinition(@Path("orgName") String orgName, @Path("serviceName") String serviceName,
                   @Path("version") String version, @Header("Content-Type") String type, @Body TypedString content);
 
Example #27
Source File: CallApi.java    From talk-android with MIT License 4 votes vote down vote up
@GET("/2013-12-26/Accounts/{accountSid}/CallResult")
Observable<CallResultRes> getCallResult(@Header("authorization") String authorization, @Path("accountSid") String accountSid, @Query("sig") String signature, @Query("callsid") String callSid);
 
Example #28
Source File: CallApi.java    From talk-android with MIT License 4 votes vote down vote up
@POST("/2013-12-26/Accounts/{accountSid}/ivr/conf")
Observable<Object> quitCallMeeting(@Header("authorization") String authorization, @Path("accountSid") String accountSid, @Query("sig") String signature, @Query("confid") String confid, @Body QuitCallMeeting data);
 
Example #29
Source File: CallApi.java    From talk-android with MIT License 4 votes vote down vote up
@POST("/2013-12-26/Accounts/{accountSid}/ivr/conf")
Observable<InviteJoinCallMeeting> inviteJoinCallMeeting(@Header("authorization") String authorization, @Path("accountSid") String accountSid, @Query("sig") String signature, @Query("confid") String confid, @Body InviteJoinCallMeetingData data);
 
Example #30
Source File: CallApi.java    From talk-android with MIT License 4 votes vote down vote up
@POST("/2013-12-26/Accounts/{accountSid}/ivr/createconf?maxmember=300")
Observable<CreateCallMeeting> createCallMeeting(@Header("authorization") String authorization, @Path("accountSid") String accountSid, @Query("sig") String signature, @Body CreateCallMeetingData data);