Search in sources :

Example 66 with MediaType

use of com.reprezen.kaizen.oasparser.model3.MediaType in project olvid-android by olvid-io.

the class OkHttpSardine method put.

@Override
public void put(String url, File localFile, String contentType, boolean expectContinue, String lockToken) throws IOException {
    MediaType mediaType = contentType == null ? null : MediaType.parse(contentType);
    RequestBody requestBody = RequestBody.create(mediaType, localFile);
    Headers.Builder headersBuilder = new Headers.Builder();
    if (expectContinue) {
        headersBuilder.add("Expect", "100-Continue");
    }
    if (!TextUtils.isEmpty(lockToken)) {
        addLockTokenToHeaders(headersBuilder, url, lockToken);
    }
    put(url, requestBody, headersBuilder.build());
}
Also used : Headers(okhttp3.Headers) MediaType(okhttp3.MediaType) RequestBody(okhttp3.RequestBody)

Example 67 with MediaType

use of com.reprezen.kaizen.oasparser.model3.MediaType in project tbdex-protocol by TBD54566975.

the class RealCircleClient method transfer.

@Override
public void transfer(TransferRequest transferRequest) throws Exception {
    OkHttpClient client = new OkHttpClient();
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, gson.toJson(transferRequest));
    Request request = requestBuilder.url("https://api-sandbox.circle.com/v1/transfers").post(body).build();
    client.newCall(request).execute();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) TransferRequest(com.squareup.protos.tbd.pfi.TransferRequest) PayoutRequest(com.squareup.protos.tbd.pfi.PayoutRequest) CreateWirePaymentRequest(com.squareup.protos.tbd.pfi.CreateWirePaymentRequest) CreateBankAccountRequest(com.squareup.protos.tbd.pfi.CreateBankAccountRequest) MediaType(okhttp3.MediaType) RequestBody(okhttp3.RequestBody)

Example 68 with MediaType

use of com.reprezen.kaizen.oasparser.model3.MediaType in project tbdex-protocol by TBD54566975.

the class RealCircleClient method createBankAccount.

@Override
public BankAccount createBankAccount(CreateBankAccountRequest createBankAccountRequest) throws Exception {
    OkHttpClient client = new OkHttpClient();
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, gson.toJson(createBankAccountRequest));
    Request request = requestBuilder.url("https://api-sandbox.circle.com/v1/businessAccount/banks/wires").post(body).build();
    Response response = client.newCall(request).execute();
    JSONObject data = new JSONObject(response.body().string()).getJSONObject("data");
    return new BankAccount.Builder().trackingRef(data.getString("trackingRef")).id(data.getString("id")).build();
}
Also used : Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) JSONObject(org.json.JSONObject) Request(okhttp3.Request) TransferRequest(com.squareup.protos.tbd.pfi.TransferRequest) PayoutRequest(com.squareup.protos.tbd.pfi.PayoutRequest) CreateWirePaymentRequest(com.squareup.protos.tbd.pfi.CreateWirePaymentRequest) CreateBankAccountRequest(com.squareup.protos.tbd.pfi.CreateBankAccountRequest) MediaType(okhttp3.MediaType) BankAccount(com.squareup.protos.tbd.pfi.BankAccount) RequestBody(okhttp3.RequestBody)

Example 69 with MediaType

use of com.reprezen.kaizen.oasparser.model3.MediaType in project tbdex-protocol by TBD54566975.

the class RealCircleClient method createWirePayment.

@Override
public void createWirePayment(CreateWirePaymentRequest createWirePaymentRequest) throws Exception {
    OkHttpClient client = new OkHttpClient();
    MediaType mediaType = MediaType.parse("application/json");
    RequestBody body = RequestBody.create(mediaType, gson.toJson(createWirePaymentRequest));
    Request request = requestBuilder.url("https://api-sandbox.circle.com/v1/mocks/payments/wire").post(body).build();
    client.newCall(request).execute();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) TransferRequest(com.squareup.protos.tbd.pfi.TransferRequest) PayoutRequest(com.squareup.protos.tbd.pfi.PayoutRequest) CreateWirePaymentRequest(com.squareup.protos.tbd.pfi.CreateWirePaymentRequest) CreateBankAccountRequest(com.squareup.protos.tbd.pfi.CreateBankAccountRequest) MediaType(okhttp3.MediaType) RequestBody(okhttp3.RequestBody)

Example 70 with MediaType

use of com.reprezen.kaizen.oasparser.model3.MediaType in project student-manager by SYYANI.

the class CourseSelectFragment method initCourseSelectList.

private void initCourseSelectList() throws JSONException, IOException {
    MediaType JSON = MediaType.parse("application/json;charset=utf-8");
    JSONObject json = new JSONObject();
    json.put("cid", courseSelectFragmentBinding.selectCourseFragmentInputClassNumber.getText().toString());
    json.put("cname", courseSelectFragmentBinding.selectCourseFragmentCourseName.getText().toString());
    json.put("tid", courseSelectFragmentBinding.selectCourseFragmentTeacherNumberTid.getText().toString());
    json.put("tname", courseSelectFragmentBinding.selectCourseFragmentTeacherNameTname.getText().toString());
    json.put("tFuzzy", courseSelectFragmentBinding.selectCourseCheckboxIsFuzzy.isChecked());
    json.put("cFuzzy", courseSelectFragmentBinding.selectCourseCheckboxIsFuzzy.isChecked());
    Log.d(TAG, "initCourseSelectList: " + json.toString());
    new Thread() {

        @Override
        public void run() {
            super.run();
            OkHttpClient client = new OkHttpClient().newBuilder().build();
            MediaType mediaType = MediaType.parse("application/json");
            RequestBody body = RequestBody.create(JSON, json.toString());
            Request request = new Request.Builder().url("http://101.35.20.64:10086/courseTeacher/findCourseTeacherInfo").method("POST", body).addHeader("Content-Type", "application/json").build();
            Response response = null;
            try {
                response = client.newCall(request).execute();
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (response.isSuccessful()) {
                ArrayList<CourseStudent> tlist = null;
                try {
                    // Log.d(TAG, "run: "+response.body().string());
                    tlist = new Gson().fromJson(response.body().string(), new TypeToken<ArrayList<CourseStudent>>() {
                    }.getType());
                    // mlist.addAll(tlist);
                    courseSelectViewModel.setMutableLiveData_student_select_course_list(tlist);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }.start();
}
Also used : OkHttpClient(okhttp3.OkHttpClient) Request(okhttp3.Request) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) IOException(java.io.IOException) Response(okhttp3.Response) JSONObject(org.json.JSONObject) TypeToken(com.google.gson.reflect.TypeToken) CourseStudent(com.shu.studentmanager.entity.CourseStudent) MediaType(okhttp3.MediaType) RequestBody(okhttp3.RequestBody)

Aggregations

MediaType (okhttp3.MediaType)297 RequestBody (okhttp3.RequestBody)186 Request (okhttp3.Request)179 Response (okhttp3.Response)158 IOException (java.io.IOException)137 ResponseBody (okhttp3.ResponseBody)71 OkHttpClient (okhttp3.OkHttpClient)68 Charset (java.nio.charset.Charset)50 Buffer (okio.Buffer)50 Headers (okhttp3.Headers)48 JSONObject (org.json.JSONObject)38 BufferedSource (okio.BufferedSource)36 MultipartBody (okhttp3.MultipartBody)34 HttpUrl (okhttp3.HttpUrl)30 Map (java.util.Map)24 BufferedSink (okio.BufferedSink)23 File (java.io.File)22 InputStream (java.io.InputStream)21 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)21