Giter VIP home page Giter VIP logo

p2p-supervise-sdk's Introduction

p2p-supervise-sdk

P2P网贷机构实时数据接入平台 (互联网应急中心)sdk retrofit封装。非常方便的集成到spring里面

maven 配置

<dependencies>

    <dependency>
        <groupId>com.open.sdk</groupId>
        <artifactId>p2p-supervise-sdk</artifactId>
        <version>1.0</version>
    </dependency>

</dependencies>

<repositories>

    <repository>
        <id>maven-repo</id>
        <url>https://raw.githubusercontent.com/fanlushuai/maven-repo/master/</url>
    </repository>

</repositories>

使用

参见test代码。配置自家apikey和sourceCode。即可使用。

@Value("${app.profile}")
private String profile;

@Value("${cncrt.apiKey}")
private String apiKey;

@Value("${cncrt.sourceCode}")
private String sourceCode;

@Value("${cncrt.host}")
private String host;

@Value("${cncrt.version}")
private String version;

@Bean
public ConfigStorage configStorage() {
    return ConfigStorage.builder().apiKey(apiKey).host(host).sourceCode(sourceCode).version(version)
            .cncrtEnv(CNCRTEnv.TEST)//环境自己看着配置
            .build();
}

@Bean
public Retrofit retrofit(ConfigStorage configStorage) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();

    builder.connectTimeout(60, TimeUnit.SECONDS) //链接超时
            .writeTimeout(60, TimeUnit.SECONDS)   //写超时
            .readTimeout(60, TimeUnit.SECONDS)    //响应超时
            .retryOnConnectionFailure(false);     //取消重试

    builder.addInterceptor(new ApiKeyGenerateInterceptor(configStorage));

    if (!configStorage.getCncrtEnv().equals(CNCRTEnv.ONLINE_PRODUCT)) {
        //非线上正式环境都打印http日志
        builder.addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY));
    }

    OkHttpClient client = builder.build();

    return new Retrofit.Builder()
            .baseUrl(configStorage.getHost())
            .addConverterFactory(GsonConverterFactory.create(configStorage.getCncrtEnv()))
            .client(client)
            .build();
}

@Bean
public UploadService uploadService(Retrofit retrofit) {
    return retrofit.create(UploadService.class);
}

@Bean
public ReconciliationService reconciliationService(Retrofit retrofit) {
    return retrofit.create(ReconciliationService.class);
}

p2p-supervise-sdk's People

Contributors

fanlushuai avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.