@Override protected ParamConverterManager getParamConverterManager() { ParamConverterManager manager = super.getParamConverterManager(); manager.registerConverter(ClassName.get(Size.class), new IgnoreConverter()); manager.registerConverter( ClassName.get(CustomAnnotation.class), new ParamConverter() { @Override public AnnotatedParam convert(AnnotatedParam param) { Map<String, Object> args = new HashMap<>(); args.put("value", "\"myHeader\""); return new AnnotatedParam( ClassName.get(String.class), ClassName.get(Header.class), args); } }); return manager; }
@GET("/api/mps/{topic}/messages/?expand=author&ordering=-pubdate") Call<ListPrivateMessage> list( @Header("Authorization") String authorization, @Header("X-Data-Format") String format, @Path("topic") int topic, @Query("page") int page, @Query("page_size") int pageSize );
/** * Returns an instance of this manager which is preconfigured with a number of converters, * e.g. {@link javax.ws.rs.PathParam} to {@link retrofit.http.Path}. */ public static ParamConverterManager getDefaultInstance() { ParamConverterManager manager = new ParamConverterManager(); manager.registerConverter( ClassName.get(HeaderParam.class), new MappingConverter(ClassName.get(Header.class))); manager.registerConverter( ClassName.get(PathParam.class), new MappingConverter(ClassName.get(Path.class))); manager.registerConverter( ClassName.get(QueryParam.class), new MappingConverter(ClassName.get(Query.class))); manager.registerConverter( ClassName.get(Void.class), new MappingConverter(ClassName.get(Body.class))); return manager; }
@PUT("/api/customer/modify/") public void putCustomer( @Header("token") String token, @Header("QR_CODE_DATA") String hash, @Body Customer customer, Callback<CustomerModificationResponse> cb );
@POST("/api/ewallet/recharge/{hash}/{coupon_code}/") public void rechargeWalletWithCoupon( @Header("token") String token, @Path("hash") String hash, @Path("coupon_code") String couponCode, Callback<ParkItError> cb );
@DELETE(METADATA_BASE_PATH + "/{metadata_key}" + V1) Response removeUserMetadata( @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token, @Path(USER_STORE_VARIABLE) ResourceIdentifier userStore, @Path(USER_UUID_VARIABLE) UUID userUuid, @Path("metadata_key") String metadataKey ) throws HodErrorException;
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; }
@GET(Constants.GOOGLE_API_BASE_URL + "/drive/v3/files") Call<DriveSearchResult> searchFiles(@Header("Authorization") String authorization, @Query("q") String searchQuery);
@Test @SuppressWarnings("unchecked") public void testParamToHeaderConversion() throws Exception { Method headerMethod = clientClass.getDeclaredMethod("convertAnnotation", String.class); Annotation[][] annotations = headerMethod.getParameterAnnotations(); Assert.assertEquals(1, annotations.length); Assert.assertEquals(1, annotations[0].length); Assert.assertEquals(Header.class, annotations[0][0].annotationType()); }
@FormUrlEncoded @POST("/api/mps/") Call<PrivateTopic> create( @Header("Authorization") String authorization, @Field("title") String title, @Field("subtitle") String subtitle, @Field("participants") List<Integer> participants, @Field("text") String text );
@PATCH(METADATA_BASE_PATH + V1) @Multipart Response addUserMetadata( @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token, @Path(USER_STORE_VARIABLE) ResourceIdentifier userStore, @Path(USER_UUID_VARIABLE) UUID userUuid, @Part("metadata") List<Metadata<?>> metadata ) throws HodErrorException;
/** * @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 );
/** * Query HP Haven OnDemand for documents using query text in a file using the given token * @param token The token to use to authenticate the request * @param file A file containing the query text * @param params Additional parameters to be sent as part of the request * @return A list of documents that match the query text */ @Multipart @POST(URL) Response queryTextIndexWithFile( @Header("token") AuthenticationToken<?, ?> token, @Part("file") TypedOutput file, @PartMap Map<String, Object> params ) throws HodErrorException;
/** * Finds similar documents to the text in a file using the given token * @param token The token to use to authenticate the request * @param file A file containing the query text * @param params Additional parameters to be sent as part of the request * @return A list of documents that are similar to the query text */ @Multipart @POST(URL) Response findSimilarDocumentsToFile( @Header("token") AuthenticationToken<?, ?> token, @Part("file") TypedOutput file, @PartMap Map<String, Object> params ) throws HodErrorException;
@POST("/2/authenticate/developer") @Multipart Response authenticateDeveloper( @Header("apiKey") ApiKey apiKey, @Part("tenant") String tenant, @Part("email") String email ) throws HodErrorException;
@GET(COMBINED_PATH) Response authenticateCombinedGet( @Header("cmb_sso_tkn") AuthenticationToken<EntityType.CombinedSso, TokenType.Simple> combinedSsoToken, @Header("token") String signature, @Header("origin") String origin, @Query(ALLOWED_ORIGINS_PARAMETER) String allowedOrigin, @Query(NONCE_PARAMETER) String nonce ) throws HodErrorException;
@PUT(URL + V1) @Multipart Response updateQueryProfile( @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token, @Path(PROFILE_VARIABLE) ResourceIdentifier queryProfile, @Part(INDEX_PART) String queryManipulationIndex, @PartMap Map<String, Object> params ) throws HodErrorException;
@POST(BASE_PATH + V1) @Multipart Response create( @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token, @Path(USER_STORE_VARIABLE) ResourceIdentifier userStore, @Part("group_name") String name, @PartMap Map<String, Object> hierarchyParameters ) throws HodErrorException;
@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);
@DELETE(BASE_PATH + "/{parent_group_name}/link" + V1) Response unlink( @Header(TOKEN_HEADER) AuthenticationToken<?, ?> token, @Path(USER_STORE_VARIABLE) ResourceIdentifier userStore, @Path("parent_group_name") String parent, @Query("child_group_name") String child ) throws HodErrorException;
@POST("/2/developer/{" + DEVELOPER_UUID_VARIABLE + "}/authentication") @Multipart AddDeveloperAuthenticationResponse addAuthentication( @Header("token") String signature, @Path(DEVELOPER_UUID_VARIABLE) UUID developerUuid, @Part(AUTH_MODE_PART) String mode ) throws HodErrorException;
@GET("/jokes/random/10") Observable<Response> getItems(@Query("firstName") String firstName, @Query("lastName") String lastName, @Header("pageNumber") int pageNumberIgnored);
@GET(Constants.GOOGLE_API_BASE_URL + "/drive/v2/about") Call<AccountData> getUserInfo(@Query("fields") String fields, @Header("Authorization") String authorization);
@POST(Constants.GOOGLE_API_BASE_URL + "/upload/drive/v2/files") Call<DriveFile> uploadGooogleFile(@Query("uploadType") String uploadType, @Query("fields") String fields, @Header("Content-Type") String contentType, @Header("Content-Length") long length, @Header("Authorization") String authorization, @Body RequestBody data);
@PUT(Constants.GOOGLE_API_BASE_URL + "/drive/v2/files/{fileId}") Call<DriveFile> setFileFolder(@Path("fileId") String fileId, @Query("fields") String fields, @Header("Authorization") String authorization, @Body RequestBody data);
@POST(Constants.GOOGLE_API_BASE_URL + "/drive/v2/files") Call<DriveFile> createFolder(@Header("Content-Type") String contentType, @Query("fields") String fields, @Header("Authorization") String authorization, @Body RequestBody data);
@GET("alpha/fixtures") Observable<Fixture.Response> getFixtures( @Header("X-Auth-Token") String apiKey, @Query("timeFrame") String timeFrame );
@GET("alpha/soccerseasons/{league_id}/teams") Observable<Team.Response> getTeamsInfoFromLeague( @Header("X-Auth-Token") String apiKey, @Path("league_id") String leagueId );
@GET("alpha/soccerseasons/") Observable<List<League>> getLeagueInfo( @Header("X-Auth-Token") String apiKey );
@POST("/api/checkout/") Call<Order> placeOrder(@Header("Authorization") String authToken, @Body Order order);
@GET("/api/user/{email}") Call<CustomerLogin> getUserDetails(@Header("Authorization") String authToken, @Path("email") String email);
@GET("/api/products/{hash}") Call<Product> getProductDetails(@Header("Authorization") String authToken, @Path("hash") String hash);
@GET("/api/wallet/{userid}") Call<wallet> getAmount(@Header("Authorization") String authToken,@Path("userid") Long id);
@POST("/api/recharge/") Call<Recharge> rechargeCounpon(@Header("Authorization") String authToken, @Body Recharge recharge );
@GET("/api/orders/{order_id}") Call<Order> getOrderById(@Header("Authorization") String authToken, @Path("order_id") String orderId);
@POST("/api/pay/") Call<ShopsterGenericResponse> payForOrder(@Header("Authorization") String authToken, @Body PaymentDetails paymentDetails);
@POST("/api/delivery/") Call<ShopsterGenericResponse> setDeliveryPreference(@Header("Authorization") String authToken, @Body DeliverySpecification deliverySpecification);
@GET("/api/user/{user_email}/") Call<Customer> getUserByEmail(@Header("Authorization") String authToken, @Path("user_email") String userEmail);
@GET("/api/deliveryrequest/{user_id}/") Call<Delivery> checkDeliveryAssignment(@Header("Authorization") String authToken, @Path("user_id") String userId);