├── .gitignore
├── .idea
├── caches
│ └── build_file_checksums.ser
├── checkstyle-idea.xml
├── codeStyles
│ └── Project.xml
├── encodings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── LICENSE
├── README.md
├── Requestor
├── .gitignore
├── build.gradle
├── requestor_dependencies.gradle
└── src
│ └── main
│ └── java
│ └── com
│ └── artshell
│ └── requestor
│ ├── ApiService.java
│ ├── Converter.java
│ ├── JsonConverter.java
│ ├── MapperProvider.java
│ ├── Protocol.java
│ ├── RxRequestor.java
│ ├── XmlConverter.java
│ ├── package-info.java
│ └── utils
│ ├── ClassExclude.java
│ ├── Numbers.java
│ ├── Objects.java
│ ├── Provider.java
│ └── Validates.java
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── artshell
│ │ └── examples
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── artshell
│ │ │ └── examples
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── artshell
│ └── examples
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/artshell/RxRequestor/e3cc3722f4f259441247841b46bd879e3e091923/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/.idea/checkstyle-idea.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
15 |
16 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### Introduction
2 | General http request encapsulate base on Retrofit, OkHttp and RxJava, support for [`java`](https://docs.oracle.com/javase/tutorial/index.html) and [`Android`](https://developer.android.com/index.html). Support result types:`coutom type`, [`ResponseBody`](http://square.github.io/okhttp/3.x/okhttp/okhttp3/RequestBody.html), [`Byte arrays`](https://docs.oracle.com/javase/8/docs/api/java/lang/Byte.html), [`Reader`](https://docs.oracle.com/javase/8/docs/api/java/io/Reader.html), [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html), [`String`](https://docs.oracle.com/javase/8/docs/api/java/lang/String.html), [`Void`](https://docs.oracle.com/javase/8/docs/api/java/lang/Void.html). Data protocol includes `json` and `xml`
3 |
4 | ### Getting started
5 | ##### Add dependencies
6 | ```java
7 | implementation 'com.artshell:RxRequestor:1.0.6'
8 | ```
9 |
10 | ##### Simple Usage
11 | ```java
12 | import com.artshell.requestor.Protocol;
13 | import com.artshell.requestor.RxRequestor;
14 |
15 | import java.io.InputStream;
16 | import java.io.Reader;
17 | import java.util.concurrent.TimeUnit;
18 |
19 | import io.reactivex.Flowable;
20 | import okhttp3.OkHttpClient;
21 | import okhttp3.ResponseBody;
22 | import retrofit2.Retrofit;
23 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
24 |
25 | public class Test {
26 |
27 | public static void main(String[] args) {
28 |
29 | OkHttpClient client = new OkHttpClient.Builder()
30 | .connectTimeout(5 * 1000, TimeUnit.MILLISECONDS)
31 | .readTimeout(30 * 1000, TimeUnit.MILLISECONDS)
32 | .writeTimeout(30 * 1000, TimeUnit.MILLISECONDS)
33 | .retryOnConnectionFailure(true)
34 | /* more settings */
35 | .build();
36 |
37 | Retrofit retrofit = new Retrofit.Builder()
38 | .baseUrl("http://www.github.com") /* Your server address */
39 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
40 | .validateEagerly(true)
41 | .client(client)
42 | /* more settings */
43 | .build();
44 |
45 | RxRequestor requestor = new RxRequestor.Builder()
46 | .setRetrofit(retrofit)
47 | .supportBy(Protocol.JSON)
48 | .build();
49 |
50 |
51 | // Example A
52 | // login whith user_id and password
53 | Map pairs = new HashMap<>();
54 | pairs.put("user_id", "artshell");
55 | pairs.put("password", "123456");
56 | /*
57 | * {
58 | * "code": "1000",
59 | * "msg" : "success",
60 | * "data" : "welcome artshell"
61 | * }
62 | */
63 | Flowable loginSource = requestor.postFields(LoginEntity.class, "user/login", pairs);
64 |
65 |
66 | // Example B
67 | /*
68 | * {
69 | * "code": "1000",
70 | * "msg" : "success",
71 | * "data" : "hello world"
72 | * }
73 | */
74 | // Custom type (JSON entity), eg.
75 | Flowable helloSource = requestor.get(HelloEntity.class, "index/welcome");
76 |
77 | // ResponseBody
78 | Flowable bodySource = requestor.get(ResponseBody.class, "index/welcome");
79 |
80 | // Byte arrays
81 | Flowable byteSource = requestor.get(Byte[].class, "index/welcome");
82 |
83 | // Reader
84 | Flowable readerSource = requestor.get(Reader.class, "index/welcome");
85 |
86 | // InputStream
87 | Flowable streamSource = requestor.get(InputStream.class, "index/welcome");
88 |
89 | // String
90 | Flowable stringSource = requestor.get(String.class, "index/welcome");
91 |
92 | // Void
93 | Flowable ignoreSource = requestor.get(Void.class, "index/welcome");
94 |
95 | }
96 | }
97 | ```
98 | Other methods details see [`RxRquestor`](https://github.com/artshell/RxRequestor/blob/master/Requestor/src/main/java/com/artshell/requestor/RxRequestor.java)
99 |
100 | ##### Especially Usage
101 | Custom converter, for more detail see [`JsonConverter`](https://github.com/artshell/RxRequestor/blob/master/Requestor/src/main/java/com/artshell/requestor/JsonConverter.java) and [`XmlConverter`](https://github.com/artshell/RxRequestor/blob/master/Requestor/src/main/java/com/artshell/requestor/XmlConverter.java)
102 | ```java
103 | RxRequestor requestor = new RxRequestor.Builder()
104 | .setRetrofit(retrofit)
105 | .supportBy(Protocol.JSON)
106 | .customConverter(xxxJsonConverter) /* your custom converter */
107 | .build();
108 | ```
109 |
--------------------------------------------------------------------------------
/Requestor/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Requestor/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | apply plugin: 'com.novoda.bintray-release'
3 | apply plugin: 'net.ltgt.errorprone'
4 | apply plugin: 'net.ltgt.apt'
5 |
6 | apply from: 'requestor_dependencies.gradle'
7 |
8 | dependencies {
9 | implementation fileTree(dir: 'libs', include: ['*.jar'])
10 | implementation "com.squareup.okhttp3:okhttp:${versions.okhttp}"
11 | implementation "com.squareup.okio:okio:${versions.okio}"
12 | implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
13 | implementation "com.squareup.retrofit2:adapter-rxjava2:${versions.retrofit}"
14 | implementation "io.reactivex.rxjava2:rxjava:${versions.rxjava}"
15 | implementation "com.google.code.gson:gson:${versions.gson}"
16 | implementation "org.simpleframework:simple-xml:${versions.simple_xml}"
17 | errorprone "com.google.errorprone:error_prone_core:${versions.errorprone}"
18 | compileOnly "com.google.errorprone:error_prone_annotations:${versions.errorprone}"
19 | compileOnly "com.uber.javaxextras:javax-extras:${versions.uber_javax_extras}"
20 | api "com.google.code.findbugs:jsr305:${versions.findbugs_jsr305}"
21 | }
22 |
23 | sourceCompatibility = versions.compatVersion
24 | targetCompatibility = versions.compatVersion
25 |
26 | tasks.withType(Javadoc) {
27 | options {
28 | encoding "UTF-8"
29 | charSet "UTF-8"
30 | links "http://docs.oracle.com/javase/8/docs/api"
31 | }
32 | }
33 |
34 | publish {
35 | userOrg = 'artshell'
36 | groupId = push.groupId
37 | artifactId = push.artifactId
38 | publishVersion = push.publishName
39 | desc = 'General http request encapsulate base Retrofit, OkHttp and RxJava'
40 | website = push.url
41 | }
42 |
--------------------------------------------------------------------------------
/Requestor/requestor_dependencies.gradle:
--------------------------------------------------------------------------------
1 | ext.versions = [
2 | compatVersion : '1.7',
3 | okhttp : '3.9.1',
4 | okio : '1.13.0',
5 | retrofit : '2.3.0',
6 | rxjava : '2.1.16',
7 | gson : '2.8.2',
8 | simple_xml : '2.7.1',
9 | errorprone : '2.1.2',
10 | errorprone_plugin : '0.0.13',
11 | apt_plugin : '0.13',
12 | uber_javax_extras : '0.1.0',
13 | findbugs_jsr305 : '3.0.2',
14 | ]
15 |
16 | ext.push = [
17 | groupId : 'com.artshell',
18 | artifactId : 'RxRequestor',
19 | publishCode : 106,
20 | publishName : '1.0.6',
21 | url : 'https://github.com/artshell/RxRequestor'
22 | ]
--------------------------------------------------------------------------------
/Requestor/src/main/java/com/artshell/requestor/ApiService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 artshell. https://github.com/artshell
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.artshell.requestor;
18 |
19 | import java.util.List;
20 | import java.util.Map;
21 |
22 | import io.reactivex.Flowable;
23 | import okhttp3.MultipartBody;
24 | import okhttp3.RequestBody;
25 | import okhttp3.ResponseBody;
26 | import retrofit2.http.Body;
27 | import retrofit2.http.FieldMap;
28 | import retrofit2.http.FormUrlEncoded;
29 | import retrofit2.http.GET;
30 | import retrofit2.http.HeaderMap;
31 | import retrofit2.http.Multipart;
32 | import retrofit2.http.POST;
33 | import retrofit2.http.Part;
34 | import retrofit2.http.PartMap;
35 | import retrofit2.http.QueryMap;
36 | import retrofit2.http.QueryName;
37 | import retrofit2.http.Url;
38 |
39 | /**
40 | * @author artshell on 25/11/2017
41 | */
42 |
43 | public interface ApiService {
44 |
45 | /**
46 | * @param url an instance of {@link String}
47 | * @return an instance of {@link Flowable}
48 | */
49 | @GET
50 | Flowable get(@Url String url);
51 |
52 | /**
53 | * @param url an instance of {@link String}
54 | * @param headers {@link Map}, defer to {@link HeaderMap}
55 | * @return an instance of {@link Flowable}
56 | */
57 | @GET
58 | Flowable getWithHeaders(
59 | @Url String url,
60 | @HeaderMap Map headers
61 | );
62 |
63 | /**
64 | * @param url an instance of {@link String}
65 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
66 | * @return an instance of {@link Flowable}
67 | */
68 | @GET
69 | Flowable getWithParameters(
70 | @Url String url,
71 | @QueryMap Map queryPairs
72 | );
73 |
74 | /**
75 | * @param url an instance of {@link String}
76 | * @param headers {@link Map}, defer to {@link HeaderMap}
77 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
78 | * @return an instance of {@link Flowable}
79 | */
80 | @GET
81 | Flowable getWithEntirety(
82 | @Url String url,
83 | @QueryMap Map queryPairs,
84 | @HeaderMap Map headers
85 | );
86 |
87 | /**
88 | * @param url an instance of {@link String}
89 | * @param queryNames eg. String[] queryNames = {"price=12", "count=56"};
90 | * @return an instance of {@link Flowable}
91 | */
92 | @GET
93 | Flowable getWithQueryNames(
94 | @Url String url,
95 | @QueryName String[] queryNames
96 | );
97 |
98 | /**
99 | * @param url an instance of {@link String}
100 | * @param queryNames eg. String[] queryNames = {"price=12", "count=56"}
101 | * @param headers {@link Map}, defer to {@link HeaderMap}
102 | * @return an instance of {@link Flowable}
103 | */
104 | @GET
105 | Flowable getWithEntirety(
106 | @Url String url,
107 | @QueryName String[] queryNames,
108 | @HeaderMap Map headers
109 | );
110 |
111 | /**
112 | * @param url an instance of {@link String}
113 | * @param queryNames eg. List queryNames = new ArrayList<>(); queryNames.add("price=12")
114 | * @return an instance of {@link Flowable}
115 | */
116 | @GET
117 | Flowable getWithQueryNames(
118 | @Url String url,
119 | @QueryName List queryNames
120 | );
121 |
122 | /**
123 | * @param url an instance of {@link String}
124 | * @param queryNames eg. List queryNames = new ArrayList<>(); queryNames.add("price=12")
125 | * @param headers {@link Map}, defer to {@link HeaderMap}
126 | * @return an instance of {@link Flowable}
127 | */
128 | @GET
129 | Flowable getWithEntirety(
130 | @Url String url,
131 | @QueryName List queryNames,
132 | @HeaderMap Map headers
133 | );
134 |
135 | /**
136 | * @param url an instance of {@link String}
137 | * @return an instance of {@link Flowable}
138 | */
139 | @POST
140 | Flowable post(@Url String url);
141 |
142 | /**
143 | * @param url an instance of {@link String}
144 | * @param headers {@link Map}, defer to {@link HeaderMap}
145 | * @return an instance of {@link Flowable}
146 | */
147 | @POST
148 | Flowable postWithHeaders(
149 | @Url String url,
150 | @HeaderMap Map headers
151 | );
152 |
153 | /**
154 | * @param url an instance of {@link String}
155 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
156 | * @return an instance of {@link Flowable}
157 | */
158 | @POST
159 | Flowable postWithParameters(
160 | @Url String url,
161 | @QueryMap Map queryPairs
162 | );
163 |
164 | /**
165 | * @param url an instance of {@link String}
166 | * @param couples {@link Map}, defer to {@link FieldMap}
167 | * @return an instance of {@link Flowable}
168 | */
169 | @FormUrlEncoded
170 | @POST
171 | Flowable postCouples(
172 | @Url String url,
173 | @FieldMap Map couples
174 | );
175 |
176 | /**
177 | * @param url an instance of {@link String}
178 | * @param headers {@link Map}, defer to {@link HeaderMap}
179 | * @param fields {@link Map}, defer to {@link FieldMap}
180 | * @return an instance of {@link Flowable}
181 | */
182 | @FormUrlEncoded
183 | @POST
184 | Flowable postWithHeaders(
185 | @Url String url,
186 | @HeaderMap Map headers,
187 | @FieldMap Map fields
188 | );
189 |
190 | /**
191 | * @param url an instance of {@link String}
192 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
193 | * @param fields {@link Map}, defer to {@link FieldMap}
194 | * @return an instance of {@link Flowable}
195 | */
196 | @FormUrlEncoded
197 | @POST
198 | Flowable postWithParameters(
199 | @Url String url,
200 | @QueryMap Map queryPairs,
201 | @FieldMap Map fields
202 | );
203 |
204 | /**
205 | * @param url an instance of {@link String}
206 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
207 | * @param headers {@link Map}, defer to {@link HeaderMap}
208 | * @param fields {@link Map}, defer to {@link FieldMap}
209 | * @return an instance of {@link Flowable}
210 | */
211 | @FormUrlEncoded
212 | @POST
213 | Flowable postWithEntirety(
214 | @Url String url,
215 | @QueryMap Map queryPairs,
216 | @HeaderMap Map headers,
217 | @FieldMap Map fields
218 | );
219 |
220 | /**
221 | * @param url an instance of {@link String}
222 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part}
223 | * @return an instance of {@link Flowable}
224 | */
225 | @Multipart
226 | @POST
227 | Flowable postPart(
228 | @Url String url,
229 | @Part MultipartBody.Part part
230 | );
231 |
232 | /**
233 | * @param url an instance of {@link String}
234 | * @param headers {@link Map}, defer to {@link HeaderMap}
235 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part}
236 | * @return an instance of {@link Flowable}
237 | */
238 | @Multipart
239 | @POST
240 | Flowable postPartWithHeaders(
241 | @Url String url,
242 | @HeaderMap Map headers,
243 | @Part MultipartBody.Part part
244 | );
245 |
246 | /**
247 | * @param url an instance of {@link String}
248 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
249 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part}
250 | * @return an instance of {@link Flowable}
251 | */
252 | @Multipart
253 | @POST
254 | Flowable postPartWithParameters(
255 | @Url String url,
256 | @QueryMap Map queryPairs,
257 | @Part MultipartBody.Part part
258 | );
259 |
260 | /**
261 | * @param url an instance of {@link String}
262 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
263 | * @param headers {@link Map}, defer to {@link HeaderMap}
264 | * @param part an instance of {@link MultipartBody.Part}, defer to {@link Part}
265 | * @return an instance of {@link Flowable}
266 | */
267 | @Multipart
268 | @POST
269 | Flowable postPartWithEntirety(
270 | @Url String url,
271 | @QueryMap Map queryPairs,
272 | @HeaderMap Map headers,
273 | @Part MultipartBody.Part part
274 | );
275 |
276 |
277 | /**
278 | * @param url an instance of {@link String}
279 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part}
280 | * @return an instance of {@link Flowable}
281 | */
282 | @Multipart
283 | @POST
284 | Flowable postParts(
285 | @Url String url,
286 | @Part MultipartBody.Part[] parts
287 | );
288 |
289 | /**
290 | * @param url an instance of {@link String}
291 | * @param headers {@link Map}, defer to {@link HeaderMap}
292 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part}
293 | * @return an instance of {@link Flowable}
294 | */
295 | @Multipart
296 | @POST
297 | Flowable postPartsWithHeaders(
298 | @Url String url,
299 | @HeaderMap Map headers,
300 | @Part MultipartBody.Part[] parts
301 | );
302 |
303 | /**
304 | * @param url an instance of {@link String}
305 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
306 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part}
307 | * @return an instance of {@link Flowable}
308 | */
309 | @Multipart
310 | @POST
311 | Flowable postPartsWithParameters(
312 | @Url String url,
313 | @QueryMap Map queryPairs,
314 | @Part MultipartBody.Part[] parts
315 | );
316 |
317 | /**
318 | * @param url an instance of {@link String}
319 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
320 | * @param headers {@link Map}, defer to {@link HeaderMap}
321 | * @param parts an array instance of {@link MultipartBody.Part}, defer to {@link Part}
322 | * @return an instance of {@link Flowable}
323 | */
324 | @Multipart
325 | @POST
326 | Flowable postPartsWithEntirety(
327 | @Url String url,
328 | @QueryMap Map queryPairs,
329 | @HeaderMap Map headers,
330 | @Part MultipartBody.Part[] parts
331 | );
332 |
333 | /**
334 | * @param url an instance of {@link String}
335 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part}
336 | * @return an instance of {@link Flowable}
337 | */
338 | @Multipart
339 | @POST
340 | Flowable postParts(
341 | @Url String url,
342 | @Part List parts
343 | );
344 |
345 | /**
346 | * @param url an instance of {@link String}
347 | * @param headers {@link Map}, defer to {@link HeaderMap}
348 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part}
349 | * @return an instance of {@link Flowable}
350 | */
351 | @Multipart
352 | @POST
353 | Flowable postPartsWithHeaders(
354 | @Url String url,
355 | @HeaderMap Map headers,
356 | @Part List parts
357 | );
358 |
359 | /**
360 | * @param url an instance of {@link String}
361 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
362 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part}
363 | * @return an instance of {@link Flowable}
364 | */
365 | @Multipart
366 | @POST
367 | Flowable postPartsWithParameters(
368 | @Url String url,
369 | @QueryMap Map queryPairs,
370 | @Part List parts
371 | );
372 |
373 | /**
374 | * @param url an instance of {@link String}
375 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
376 | * @param headers {@link Map}, defer to {@link HeaderMap}
377 | * @param parts a {@link List} instance of {@link MultipartBody.Part}, defer to {@link Part}
378 | * @return an instance of {@link Flowable}
379 | */
380 | @Multipart
381 | @POST
382 | Flowable postPartsWithEntirety(
383 | @Url String url,
384 | @QueryMap Map queryPairs,
385 | @HeaderMap Map headers,
386 | @Part List parts
387 | );
388 |
389 | /**
390 | * @param url an instance of {@link String}
391 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap}
392 | * @return an instance of {@link Flowable}
393 | */
394 | @Multipart
395 | @POST
396 | Flowable postParts(
397 | @Url String url,
398 | @PartMap Map parts
399 | );
400 |
401 | /**
402 | * @param url an instance of {@link String}
403 | * @param headers {@link Map}, defer to {@link HeaderMap}
404 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap}
405 | * @return an instance of {@link Flowable}
406 | */
407 | @Multipart
408 | @POST
409 | Flowable postPartsWithHeaders(
410 | @Url String url,
411 | @HeaderMap Map headers,
412 | @PartMap Map parts
413 | );
414 |
415 | /**
416 | * @param url an instance of {@link String}
417 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
418 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap}
419 | * @return an instance of {@link Flowable}
420 | */
421 | @Multipart
422 | @POST
423 | Flowable postPartsWithParameters(
424 | @Url String url,
425 | @QueryMap Map queryPairs,
426 | @PartMap Map parts
427 | );
428 |
429 | /**
430 | * @param url an instance of {@link String}
431 | * @param headers {@link Map}, defer to {@link HeaderMap}
432 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
433 | * @param parts {@link String}/{@link RequestBody} pairs, defer to {@link PartMap}
434 | * @return an instance of {@link Flowable}
435 | */
436 | @Multipart
437 | @POST
438 | Flowable postPartsWithEntirety(
439 | @Url String url,
440 | @QueryMap Map queryPairs,
441 | @HeaderMap Map headers,
442 | @PartMap Map parts
443 | );
444 |
445 | /**
446 | * @param url an instance of {@link String}
447 | * @param body an instance of {@link RequestBody}, defer to {@link Body}
448 | * @return an instance of {@link Flowable}
449 | */
450 | @POST
451 | Flowable postBody(
452 | @Url String url,
453 | @Body RequestBody body
454 | );
455 |
456 | /**
457 | * @param url an instance of {@link String}
458 | * @param headers {@link Map}, defer to {@link HeaderMap}
459 | * @param body an instance of {@link RequestBody}, defer to {@link Body}
460 | * @return an instance of {@link Flowable}
461 | */
462 | @POST
463 | Flowable postBodyWithHeaders(
464 | @Url String url,
465 | @HeaderMap Map headers,
466 | @Body RequestBody body
467 | );
468 |
469 | /**
470 | * @param url an instance of {@link String}
471 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
472 | * @param body an instance of {@link RequestBody}, defer to {@link Body}
473 | * @return an instance of {@link Flowable}
474 | */
475 | @POST
476 | Flowable postBodyWithParameters(
477 | @Url String url,
478 | @QueryMap Map queryPairs,
479 | @Body RequestBody body
480 | );
481 |
482 | /**
483 | * @param url an instance of {@link String}
484 | * @param headers {@link Map}, defer to {@link HeaderMap}
485 | * @param queryPairs {@link Map}, defer to {@link QueryMap}
486 | * @param body an instance of {@link RequestBody}, defer to {@link Body}
487 | * @return an instance of {@link Flowable}
488 | */
489 | @POST
490 | Flowable postBodyWithEntirety(
491 | @Url String url,
492 | @QueryMap Map queryPairs,
493 | @HeaderMap Map headers,
494 | @Body RequestBody body
495 | );
496 | }
497 |
--------------------------------------------------------------------------------
/Requestor/src/main/java/com/artshell/requestor/Converter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 artshell. https://github.com/artshell
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.artshell.requestor;
18 |
19 | import java.io.IOException;
20 |
21 | import okhttp3.ResponseBody;
22 |
23 | /**
24 | * @author artshell on 02/12/2017
25 | */
26 |
27 | public interface Converter {
28 | /**
29 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
30 | * {@link java.io.InputStream}, {@link String}
31 | * @param body
32 | * @param
33 | * @return
34 | * @throws IOException
35 | */
36 | T apply(Class target, ResponseBody body) throws IOException;
37 | }
38 |
--------------------------------------------------------------------------------
/Requestor/src/main/java/com/artshell/requestor/JsonConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 artshell. https://github.com/artshell
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.artshell.requestor;
18 |
19 | import com.google.gson.Gson;
20 |
21 | import java.io.IOException;
22 |
23 | import okhttp3.ResponseBody;
24 |
25 | /**
26 | * @author artshell on 02/12/2017
27 | */
28 |
29 | public final class JsonConverter implements Converter {
30 | private Gson gson = new Gson();
31 |
32 | public static JsonConverter create() {
33 | return new JsonConverter();
34 | }
35 |
36 | @Override
37 | public T apply(Class target, ResponseBody body) throws IOException {
38 | try {
39 | return gson.fromJson(body.charStream(), target);
40 | } finally {
41 | body.close();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Requestor/src/main/java/com/artshell/requestor/MapperProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 artshell. https://github.com/artshell
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.artshell.requestor;
18 |
19 | import org.reactivestreams.Publisher;
20 |
21 | import java.io.InputStream;
22 | import java.io.Reader;
23 |
24 | import io.reactivex.Flowable;
25 | import io.reactivex.functions.Function;
26 | import okhttp3.ResponseBody;
27 |
28 | /**
29 | * @author artshell on 02/12/2017
30 | */
31 |
32 | final class MapperProvider {
33 | private Converter mConverter;
34 |
35 | public MapperProvider(Converter converter) {
36 | mConverter = converter;
37 | }
38 |
39 | public Converter getConverter() {
40 | return mConverter;
41 | }
42 |
43 | public Function> converterFor(Class target) {
44 | return new PublisherFunction<>(mConverter, target);
45 | }
46 |
47 | private static class PublisherFunction implements Function> {
48 | private Converter mConverter;
49 | private Class clazz;
50 |
51 | PublisherFunction(Converter converter, Class target) {
52 | this.mConverter = converter;
53 | this.clazz = target;
54 | }
55 |
56 | @SuppressWarnings("unchecked")
57 | @Override
58 | public Publisher extends T> apply(ResponseBody body) throws Exception {
59 | // Fix for http status's code 204,205
60 | if (body == null) return Flowable.empty();
61 |
62 | if (clazz == ResponseBody.class) {
63 | return Flowable.just((T) body);
64 | } else if (clazz == Byte[].class) {
65 | byte[] bts = body.bytes();
66 | Byte[] copy = new Byte[bts.length];
67 | for (int i = 0; i < bts.length; i++) {
68 | copy[i] = bts[i];
69 | }
70 | return Flowable.just((T) copy);
71 | } else if (clazz == Reader.class) {
72 | return Flowable.just((T) body.charStream());
73 | } else if (clazz == InputStream.class) {
74 | return Flowable.just((T) body.byteStream());
75 | } else if (clazz == String.class) {
76 | return Flowable.just((T) body.string());
77 | } else if (clazz == void.class || clazz == Void.TYPE) {
78 | return Flowable.empty();
79 | } else {
80 | return Flowable.just(mConverter.apply(clazz, body));
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Requestor/src/main/java/com/artshell/requestor/Protocol.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 artshell. https://github.com/artshell
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.artshell.requestor;
18 |
19 | /**
20 | * @author artshell on 11/01/2018
21 | */
22 |
23 | public enum Protocol {
24 | JSON, XML
25 | }
26 |
--------------------------------------------------------------------------------
/Requestor/src/main/java/com/artshell/requestor/RxRequestor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 artshell. https://github.com/artshell
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.artshell.requestor;
18 |
19 | import com.artshell.requestor.utils.ClassExclude;
20 | import com.artshell.requestor.utils.Objects;
21 | import com.artshell.requestor.utils.Validates;
22 |
23 | import java.util.List;
24 | import java.util.Map;
25 |
26 | import io.reactivex.Flowable;
27 | import okhttp3.HttpUrl;
28 | import okhttp3.MultipartBody;
29 | import okhttp3.RequestBody;
30 | import okhttp3.ResponseBody;
31 | import retrofit2.CallAdapter;
32 | import retrofit2.Retrofit;
33 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
34 | import retrofit2.http.FieldMap;
35 | import retrofit2.http.HeaderMap;
36 | import retrofit2.http.QueryMap;
37 |
38 | /**
39 | * @author artshell on 25/11/2017
40 | */
41 |
42 | public class RxRequestor {
43 | private Retrofit mRetrofit;
44 | private ApiService mDelegate;
45 | private Protocol mType;
46 | private MapperProvider mProvider;
47 |
48 | private RxRequestor(Retrofit retrofit, ApiService delegate, Protocol type, MapperProvider provider) {
49 | mRetrofit = retrofit;
50 | mDelegate = delegate;
51 | mType = type;
52 | mProvider = provider;
53 | }
54 |
55 | /**
56 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
57 | * {@link java.io.InputStream}, {@link String}, {@link Void}
58 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
59 | * @param a class
60 | * @return an instance of {@link Flowable}
61 | */
62 | public Flowable get(Class target, String url) {
63 | ClassExclude.exclude(target);
64 | return mDelegate.get(url).flatMap(mProvider.converterFor(target));
65 | }
66 |
67 | /**
68 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
69 | * {@link java.io.InputStream}, {@link String}, {@link Void}
70 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
71 | * @param headers refer to {@link HeaderMap}
72 | * @param a class
73 | * @return an instance of {@link Flowable}
74 | */
75 | public Flowable getWithHeaders(Class target, String url, Map headers) {
76 | Validates.check(target, headers);
77 | return mDelegate.getWithHeaders(url, headers).flatMap(mProvider.converterFor(target));
78 | }
79 |
80 | /**
81 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
82 | * {@link java.io.InputStream}, {@link String}, {@link Void}
83 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
84 | * @param queryPairs refer to {@link QueryMap}
85 | * @param a class
86 | * @return an instance of {@link Flowable}
87 | */
88 | public Flowable getWithParameters(Class target, String url, Map queryPairs) {
89 | Validates.check(target, queryPairs);
90 | return mDelegate.getWithParameters(url, queryPairs).flatMap(mProvider.converterFor(target));
91 | }
92 |
93 | /**
94 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
95 | * {@link java.io.InputStream}, {@link String}, {@link Void}
96 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
97 | * @param queryPairs refer to {@link QueryMap}
98 | * @param headers refer to {@link HeaderMap}
99 | * @param a class
100 | * @return an instance of {@link Flowable}
101 | */
102 | public Flowable getWithEntirety(Class target, String url, Map queryPairs, Map headers) {
103 | Validates.check(target, queryPairs, headers);
104 | return mDelegate.getWithEntirety(url, queryPairs, headers).flatMap(mProvider.converterFor(target));
105 | }
106 |
107 | /**
108 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
109 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
110 | * @param queryNames key/value pairs of {@link String}, {@link Void} array
111 | * @param a class
112 | * @return an instance of {@link Flowable}
113 | */
114 | public Flowable getWithQueryNames(Class target, String url, String[] queryNames) {
115 | Validates.check(target, queryNames);
116 | return mDelegate.getWithQueryNames(url, queryNames).flatMap(mProvider.converterFor(target));
117 | }
118 |
119 | /**
120 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
121 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
122 | * @param queryNames key/value pairs of {@link String}, {@link Void} of array
123 | * @param headers refer to {@link HeaderMap}
124 | * @param a class
125 | * @return an instance of {@link Flowable}
126 | */
127 | public Flowable getWithEntirety(Class target, String url, String[] queryNames, Map headers) {
128 | Validates.check(target, queryNames, headers);
129 | return mDelegate.getWithEntirety(url, queryNames, headers).flatMap(mProvider.converterFor(target));
130 | }
131 |
132 | /**
133 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
134 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
135 | * @param queryNames key/value pairs of {@link String}, {@link Void} of Array
136 | * @param a class
137 | * @return an instance of {@link Flowable}
138 | */
139 | public Flowable getWithQueryNames(Class target, String url, List queryNames) {
140 | Validates.check(target, queryNames);
141 | return mDelegate.getWithQueryNames(url, queryNames).flatMap(mProvider.converterFor(target));
142 | }
143 |
144 | /**
145 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
146 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
147 | * @param queryNames key/value pairs of {@link String}, {@link Void} of {@link List}
148 | * @param headers refer to {@link HeaderMap}
149 | * @param a class
150 | * @return an instance of {@link Flowable}
151 | */
152 | public Flowable getWithEntirety(Class target, String url, List queryNames, Map headers) {
153 | Validates.check(target, queryNames, headers);
154 | return mDelegate.getWithEntirety(url, queryNames, headers).flatMap(mProvider.converterFor(target));
155 | }
156 |
157 | /**
158 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
159 | * {@link java.io.InputStream}, {@link String}, {@link Void}
160 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
161 | * @param a class
162 | * @return an instance of {@link Flowable}
163 | */
164 | public Flowable post(Class target, String url) {
165 | ClassExclude.exclude(target);
166 | return mDelegate.post(url).flatMap(mProvider.converterFor(target));
167 | }
168 |
169 | /**
170 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
171 | * {@link java.io.InputStream}, {@link String}, {@link Void}
172 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
173 | * @param headers refer to {@link HeaderMap}
174 | * @param a class
175 | * @return an instance of {@link Flowable}
176 | */
177 | public Flowable postWithHeaders(Class target, String url, Map headers) {
178 | Validates.check(target, headers);
179 | return mDelegate.postWithHeaders(url, headers).flatMap(mProvider.converterFor(target));
180 | }
181 |
182 | /**
183 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
184 | * {@link java.io.InputStream}, {@link String}, {@link Void}
185 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
186 | * @param queryPairs refer to {@link QueryMap}
187 | * @param a class
188 | * @return an instance of {@link Flowable}
189 | */
190 | public Flowable postWithParameters(Class target, String url, Map queryPairs) {
191 | Validates.check(target, queryPairs);
192 | return mDelegate.postWithParameters(url, queryPairs).flatMap(mProvider.converterFor(target));
193 | }
194 |
195 | /**
196 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
197 | * {@link java.io.InputStream}, {@link String}, {@link Void}
198 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
199 | * @param couples refer to {@link FieldMap}
200 | * @param a class
201 | * @return an instance of {@link Flowable}
202 | */
203 | public Flowable postCouples(Class target, String url, Map couples) {
204 | Validates.check(target, couples);
205 | return mDelegate.postCouples(url, couples).flatMap(mProvider.converterFor(target));
206 | }
207 |
208 | /**
209 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
210 | * {@link java.io.InputStream}, {@link String}, {@link Void}
211 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
212 | * @param headers refer to {@link HeaderMap}
213 | * @param fields refer to {@link FieldMap}
214 | * @param a class
215 | * @return an instance of {@link Flowable}
216 | */
217 | public Flowable postWithHeaders(Class target, String url, Map headers, Map fields) {
218 | Validates.check(target, headers, fields);
219 | return mDelegate.postWithHeaders(url, headers, fields).flatMap(mProvider.converterFor(target));
220 | }
221 |
222 | /**
223 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
224 | * {@link java.io.InputStream}, {@link String}, {@link Void}
225 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
226 | * @param queryPairs refer to {@link QueryMap}
227 | * @param fields refer to {@link FieldMap}
228 | * @param a class
229 | * @return an instance of {@link Flowable}
230 | */
231 | public Flowable postWithParameters(Class target, String url, Map queryPairs, Map fields) {
232 | Validates.check(target, queryPairs, fields);
233 | return mDelegate.postWithParameters(url, queryPairs, fields).flatMap(mProvider.converterFor(target));
234 | }
235 |
236 | /**
237 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
238 | * {@link java.io.InputStream}, {@link String}, {@link Void}
239 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
240 | * @param queryPairs refer to {@link QueryMap}
241 | * @param headers refer to {@link HeaderMap}
242 | * @param fields refer to {@link FieldMap}
243 | * @param a class
244 | * @return an instance of {@link Flowable}
245 | */
246 | public Flowable postWithEntirety(Class target, String url, Map queryPairs, Map headers, Map fields) {
247 | Validates.check(target, queryPairs, headers, fields);
248 | return mDelegate.postWithEntirety(url, queryPairs, headers, fields).flatMap(mProvider.converterFor(target));
249 | }
250 |
251 | /**
252 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
253 | * {@link java.io.InputStream}, {@link String}, {@link Void}
254 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
255 | * @param part refer to {@link MultipartBody.Part}
256 | * @param a class
257 | * @return an instance of {@link Flowable}
258 | */
259 | public Flowable postPart(Class target, String url, MultipartBody.Part part) {
260 | ClassExclude.exclude(target);
261 | return mDelegate.postPart(url, part).flatMap(mProvider.converterFor(target));
262 | }
263 |
264 | /**
265 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
266 | * {@link java.io.InputStream}, {@link String}, {@link Void}
267 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
268 | * @param headers refer to {@link HeaderMap}
269 | * @param part refer to {@link MultipartBody.Part}
270 | * @param a class
271 | * @return an instance of {@link Flowable}
272 | */
273 | public Flowable postPartWithHeaders(Class target, String url, Map headers, MultipartBody.Part part) {
274 | Validates.check(target, headers);
275 | return mDelegate.postPartWithHeaders(url, headers, part).flatMap(mProvider.converterFor(target));
276 | }
277 |
278 | /**
279 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
280 | * {@link java.io.InputStream}, {@link String}, {@link Void}
281 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
282 | * @param queryPairs refer to {@link QueryMap}
283 | * @param part refer to {@link MultipartBody.Part}
284 | * @param a class
285 | * @return an instance of {@link Flowable}
286 | */
287 | public Flowable postPartWithParameters(Class target, String url, Map queryPairs, MultipartBody.Part part) {
288 | Validates.check(target, queryPairs);
289 | return mDelegate.postPartWithParameters(url, queryPairs, part).flatMap(mProvider.converterFor(target));
290 | }
291 |
292 | /**
293 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
294 | * {@link java.io.InputStream}, {@link String}, {@link Void}
295 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
296 | * @param queryPairs refer to {@link QueryMap}
297 | * @param headers refer to {@link HeaderMap}
298 | * @param part refer to {@link MultipartBody.Part}
299 | * @param a class
300 | * @return an instance of {@link Flowable}
301 | */
302 | public Flowable postPartWithEntirety(Class target, String url, Map queryPairs, Map headers, MultipartBody.Part part) {
303 | Validates.check(target, queryPairs, headers);
304 | return mDelegate.postPartWithEntirety(url, queryPairs, headers, part).flatMap(mProvider.converterFor(target));
305 | }
306 |
307 | /**
308 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
309 | * {@link java.io.InputStream}, {@link String}, {@link Void}
310 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
311 | * @param parts refer to {@link MultipartBody.Part}
312 | * @param a class
313 | * @return an instance of {@link Flowable}
314 | */
315 | public Flowable postParts(Class target, String url, MultipartBody.Part[] parts) {
316 | Validates.check(target, parts);
317 | return mDelegate.postParts(url, parts).flatMap(mProvider.converterFor(target));
318 | }
319 |
320 | /**
321 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
322 | * {@link java.io.InputStream}, {@link String}, {@link Void}
323 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
324 | * @param headers refer to {@link HeaderMap}
325 | * @param parts refer to {@link MultipartBody.Part}
326 | * @param a class
327 | * @return an instance of {@link Flowable}
328 | */
329 | public Flowable postPartsWithHeaders(Class target, String url, Map headers, MultipartBody.Part[] parts) {
330 | Validates.check(target, headers, parts);
331 | return mDelegate.postPartsWithHeaders(url, headers, parts).flatMap(mProvider.converterFor(target));
332 | }
333 |
334 | /**
335 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
336 | * {@link java.io.InputStream}, {@link String}, {@link Void}
337 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
338 | * @param queryPairs refer to {@link QueryMap}
339 | * @param parts refer to {@link MultipartBody.Part}
340 | * @param a class
341 | * @return an instance of {@link Flowable}
342 | */
343 | public Flowable postPartsWithParameters(Class target, String url, Map queryPairs, MultipartBody.Part[] parts) {
344 | Validates.check(target, queryPairs, parts);
345 | return mDelegate.postPartsWithParameters(url, queryPairs, parts).flatMap(mProvider.converterFor(target));
346 | }
347 |
348 | /**
349 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
350 | * {@link java.io.InputStream}, {@link String}, {@link Void}
351 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
352 | * @param queryPairs refer to {@link QueryMap}
353 | * @param headers refer to {@link HeaderMap}
354 | * @param parts refer to {@link MultipartBody.Part}
355 | * @param a class
356 | * @return an instance of {@link Flowable}
357 | */
358 | public Flowable postPartsWithEntirety(Class target, String url, Map queryPairs, Map headers, MultipartBody.Part[] parts) {
359 | Validates.check(target, queryPairs, headers, parts);
360 | return mDelegate.postPartsWithEntirety(url, queryPairs, headers, parts).flatMap(mProvider.converterFor(target));
361 | }
362 |
363 | /**
364 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
365 | * {@link java.io.InputStream}, {@link String}, {@link Void}
366 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
367 | * @param parts refer to {@link MultipartBody.Part}
368 | * @param a class
369 | * @return an instance of {@link Flowable}
370 | */
371 | public Flowable postParts(Class target, String url, List parts) {
372 | Validates.check(target, parts);
373 | return mDelegate.postParts(url, parts).flatMap(mProvider.converterFor(target));
374 | }
375 |
376 | /**
377 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
378 | * {@link java.io.InputStream}, {@link String}, {@link Void}
379 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
380 | * @param headers refer to {@link HeaderMap}
381 | * @param parts refer to {@link MultipartBody.Part}
382 | * @param a class
383 | * @return an instance of {@link Flowable}
384 | */
385 | public Flowable postPartsWithHeaders(Class target, String url, Map headers, List parts) {
386 | Validates.check(target, headers, parts);
387 | return mDelegate.postPartsWithHeaders(url, headers, parts).flatMap(mProvider.converterFor(target));
388 | }
389 |
390 | /**
391 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
392 | * {@link java.io.InputStream}, {@link String}, {@link Void}
393 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
394 | * @param queryPairs refer to {@link QueryMap}
395 | * @param parts refer to {@link MultipartBody.Part}
396 | * @param a class
397 | * @return an instance of {@link Flowable}
398 | */
399 | public Flowable postPartsWithParameters(Class target, String url, Map queryPairs, List parts) {
400 | Validates.check(target, queryPairs, parts);
401 | return mDelegate.postPartsWithParameters(url, queryPairs, parts).flatMap(mProvider.converterFor(target));
402 | }
403 |
404 | /**
405 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
406 | * {@link java.io.InputStream}, {@link String}, {@link Void}
407 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
408 | * @param queryPairs refer to {@link QueryMap}
409 | * @param headers refer to {@link HeaderMap}
410 | * @param parts refer to {@link MultipartBody.Part}
411 | * @param a class
412 | * @return an instance of {@link Flowable}
413 | */
414 | public Flowable postPartsWithEntirety(Class target, String url, Map queryPairs, Map headers, List parts) {
415 | Validates.check(target, queryPairs, headers, parts);
416 | return mDelegate.postPartsWithEntirety(url, queryPairs, headers, parts).flatMap(mProvider.converterFor(target));
417 | }
418 |
419 | /**
420 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
421 | * {@link java.io.InputStream}, {@link String}, {@link Void}
422 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
423 | * @param parts refer to {@link MultipartBody.Part}
424 | * @param a class
425 | * @return an instance of {@link Flowable}
426 | */
427 | public Flowable postParts(Class target, String url, Map parts) {
428 | Validates.check(target, parts);
429 | return mDelegate.postParts(url, parts).flatMap(mProvider.converterFor(target));
430 | }
431 |
432 | /**
433 | * @param target custom type, {@link ResponseBody}, {@link Byte} arrays, {@link java.io.Reader}
434 | * {@link java.io.InputStream}, {@link String}, {@link Void}
435 | * @param url {@link retrofit2.http.Url}, {@link Retrofit.Builder#baseUrl(HttpUrl)}
436 | * @param headers refer to {@link HeaderMap}
437 | * @param parts refer to {@link MultipartBody.Part}
438 | * @param a class
439 | * @return an instance of {@link Flowable}
440 | */
441 | public Flowable postPartsWithHeaders(Class