/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.zuoxiaolong.blog.sdk;

import com.google.gson.reflect.TypeToken;
import com.zuoxiaolong.blog.model.persistent.ArticleCategory;

import java.lang.reflect.Type;
import java.util.List;

/**
 * API种类
 * 没增加一种API的调用支持,就需要在这里添加一个枚举示例
 *
 * @author Xiaolong Zuo
 * @since 1.0.0
 */
public enum ApiType {

    example1("/example1", "GET", new TypeToken<List<ArticleCategory>>(){}.getType()),
    example2("/example2", "GET", ArticleCategory.class),
    example4("/example4", "GET")
    ;

    private String url;

    private String method;

    private Type resultType;

    ApiType(String url, String method) {
        this.url = url;
        this.method = method;
    }

    ApiType(String url, String method, Type resultType) {
        this.url = url;
        this.method = method;
        this.resultType = resultType;
    }

    public String getUrl(String serverUrl) {
        return serverUrl + url;
    }

    public String getMethod() {
        return method;
    }

    public Type getResultType() {
        return resultType;
    }

}

@@ -830,9 +830,14 @@
 %0A * 
-%E6%B2%A1
+NOTE:%E6%AF%8F
 %E5%A2%9E%E5%8A%A0%E4%B8%80%E7%A7%8D
@@ -947,21 +947,8 @@
 le1(
-%22/example1%22, 
 %22GET
@@ -1020,21 +1020,8 @@
 le2(
-%22/example2%22, 
 %22GET
@@ -1064,21 +1064,8 @@
 le4(
-%22/example4%22, 
 %22GET
@@ -1172,36 +1172,24 @@
 Type(String 
-url, String 
 method) %7B%0A  
@@ -1202,114 +1202,277 @@
 this
-.url = url
+(method, null)
 ;%0A    
+%7D%0A%0A
     
-this.method = method
+ApiType(String method, Type resultType) %7B%0A        String%5B%5D names = toString().split(%22_%22)
 ;%0A    
-%7D%0A%0A
     
-ApiType(String url, String method, Type resultType) %7B
+StringBuffer url = new StringBuffer();%0A        for (int i = 0; i %3C names.length ; i++) %7B%0A            url.append(%22/%22).append(names%5Bi%5D);%0A        %7D
 %0A   
@@ -1486,24 +1486,35 @@
 is.url = url
+.toString()
 ;%0A        th

添加SDK和Fast框架.