//
//  GMServerDomains.m
//  GMAlpha
//
//  Created by Q14 on 2018/11/5.
//  Copyright © 2018年 Gengmei. All rights reserved.
//

#import "GMServerDomains.h"

@implementation GMServerDomains
+ (NSString *)domain {
    NSString *string = @"://";
    NSArray *array = [self.apiHost componentsSeparatedByString:string];
    NSString *domain = [array lastObject];
    return domain;
}

+ (NSString *)apiHost {
    
    NSString *apiHost = @"";
#if defined DEBUG
    NSString *host = [[NSUserDefaults standardUserDefaults] objectForKey:@"apihost"];
    if ([host isNonEmpty]) {
        apiHost = host;
    } else {
//        apiHost = @"http://earth.igengmei.com";
//        apiHost = @"http://earth.gmeiapp.com";
//        return @"http://earth.igengmei.com";
        return @"http://earth.gmeiapp.com";
    }
#elif APPSTORE
    apiHost = @"https://earth.gmeiapp.com";
#elif defined UNITTEST
    apiHost = @"http://earth.igengmei.com";
#elif defined RELEASE
    apiHost = [[NSUserDefaults standardUserDefaults] objectForKey:@"apihost"] ?:@"http://earth.igengmei.com";
#else
    apiHost = @"http://earth.igengmei.com";
#endif
    return [[NSUserDefaults standardUserDefaults] objectForKey:kBackupDomin] ?:apiHost;
}
@end
