227 lines
10 KiB
Objective-C
227 lines
10 KiB
Objective-C
//
|
|
// HBNetWorkingUtility+Services.m
|
|
// QinJiuTV
|
|
//
|
|
// Created by HI_LOSER on 2024/5/28.
|
|
//
|
|
|
|
#import "HBNetWorkingUtility+Services.h"
|
|
|
|
@implementation HBNetWorkingUtility (Commom)
|
|
|
|
+ (void)commom_deviceRegister {
|
|
|
|
if([NSUserDefaults boolForKey:HBCustomerLoginSuccessKey]) return;
|
|
|
|
NSError * error = nil;
|
|
NSString * identifierForVendor = [SAMKeychain passwordForService:[UIDevice bundleIdentifier] account:HBIdentifierForVendorKey error:&error];
|
|
if ([NSString empty:identifierForVendor] || error) {
|
|
identifierForVendor = [UIDevice identifierForVendor];
|
|
[SAMKeychain setPassword:identifierForVendor forService:[UIDevice bundleIdentifier] account:HBIdentifierForVendorKey];
|
|
}
|
|
|
|
|
|
NSDictionary * headers = @{
|
|
@"Authorization": @"",
|
|
@"device-id": identifierForVendor,
|
|
@"system-type": @"ios",
|
|
@"model":[UIDevice model],
|
|
@"system-version": [UIDevice systemVersion],
|
|
@"brand": @"ios",
|
|
@"app-version": [UIDevice appVersion]
|
|
};
|
|
|
|
|
|
[HBNetWorkingUtility requestWithHTTPMethod:HTTPMethodPost
|
|
api:@"customer/register"
|
|
headers:headers
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (result.success) {
|
|
[NSUserDefaults setObject:result.data[@"token"] forKey:HBNetWorkingTokenKey];
|
|
[NSUserDefaults setObject:result.data[@"customer_id"] forKey:HBCustomerIdKey];
|
|
} else {
|
|
|
|
}
|
|
}];
|
|
}
|
|
|
|
+ (void)commom_fetchBannersWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"getBanners"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
+ (void)common_searchVideosWithKey:(NSString *) key complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"videoList"
|
|
parameters:@{@"search":key}
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation HBNetWorkingUtility (home)
|
|
|
|
+ (void)home_fetchCategoriesWithComplateBlock:(HBResponseComplateBlock)complateBlock{
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"getHomeCategories"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
@end
|
|
|
|
|
|
|
|
@implementation HBNetWorkingUtility (Customer)
|
|
+ (void)customer_thirdLoginWithParams:(NSDictionary *) params complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodPost
|
|
api:@"customer/login"
|
|
parameters:params
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
|
|
}
|
|
|
|
+ (void)customer_logoutWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodPost
|
|
api:@"customer/signout"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) {
|
|
[NSUserDefaults setObject:result.data[@"token"] forKey:HBNetWorkingTokenKey];
|
|
[NSUserDefaults setObject:result.data[@"customer_id"] forKey:HBCustomerIdKey];
|
|
complateBlock(result.success,result.data,result.message);
|
|
}
|
|
}];
|
|
}
|
|
|
|
+ (void)customer_signoutWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodPost
|
|
api:@"customer/logoff"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (result.success) [HBNetWorkingUtility commom_deviceRegister];
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
|
|
+ (void)customer_fetchUserInfoWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"customer/info"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
+ (void)customer_favoriteWithVideoId:(NSInteger )vId complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodPost
|
|
api:@"collect"
|
|
parameters:@{@"short_video_id" : @(vId)}
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
+ (void)customer_unFavoriteWithVideoId:(NSInteger )vId complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodPost
|
|
api:@"cancelCollect"
|
|
parameters:@{@"short_video_id" : @(vId)}
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
+ (void)customer_fetchFavoriteListWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"myCollections"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation HBNetWorkingUtility (videos)
|
|
+ (void)videos_fetchCategoriesWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"getCategories"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
|
|
+ (void)videos_fetchCategoryVideosWithId:(NSInteger)cid complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"videoList"
|
|
parameters:@{@"category_id":@(cid)}
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
|
|
}
|
|
|
|
+ (void)videos_fetchVideoDetailsWithSid:(NSInteger)sId complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"getVideoDetails"
|
|
parameters:@{@"short_video_id":@(sId)}
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
|
|
}
|
|
|
|
+ (void)videos_uploadPlayHistoryWithSid:(NSInteger)sId vId:(NSInteger)vId complateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodPost
|
|
api:@"createHistory"
|
|
parameters:@{@"short_video_id":@(sId),@"video_id":@(vId)}
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
|
|
}
|
|
|
|
+ (void)videos_fetchVisitTopWithComplateBlock:(HBResponseComplateBlock)complateBlock {
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"getVisitTop"
|
|
parameters:nil
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation HBNetWorkingUtility (Discover)
|
|
+ (void)discover_fetchRecommandsWithPage:(NSInteger)page
|
|
size:(NSInteger)size
|
|
complateBlock:(HBResponseComplateBlock) complateBlock {
|
|
NSDictionary * parmes = @{@"page_size":@(size),
|
|
@"current_page":@(page)};
|
|
|
|
[HBNetWorkingUtility tokenRequestWithHTTPMethod:HTTPMethodGet
|
|
api:@"getRecommands"
|
|
parameters:parmes
|
|
response:^(HBNetWorkingUtilityResult * _Nullable result) {
|
|
if (complateBlock) complateBlock(result.success,result.data,result.message);
|
|
}];
|
|
}
|
|
@end
|