123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- //
- // XYDeliveryAPIManager.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/8/11.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYDeliveryAPIManager.h"
- static NSString * const COMMON_GET_AREA_LIST = @"api-common/v1/data/getAreaList"; //获取区域列表
- static NSString * const COMMON_ADD_DELIVERY = @"api-common/v1/delivery/addDelivery"; //创建收货地址
- static NSString * const COMMON_GET_DELIVERY_LIST = @"api-common/v1/delivery/getDeliveryList"; //获取收货地址列表
- static NSString * const COMMON_GET_DEFAULT_DELIVERY = @"api-common/v1/delivery/getDefaultDelivery"; //获取默认收货地址
- static NSString * const COMMON_DELETE_DELIVERY = @"api-common/v1/delivery/delDelivery"; //删除收货地址
- static NSString * const COMMON_SET_DEFAULT_DELIVERY = @"api-common/v1/delivery/setDefaultDelivery"; //设默认收货地址
- static NSString * const COMMON_MODIFY_DELIVERY = @"api-common/v1/delivery/modifyDelivery"; //编辑收货地址
- @implementation XYDeliveryAPIManager
- /**
- 获取区域列表
- @param parentId 父区域id 不传则说明是省级列表
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)getAreaListWithParentId:(NSString *)parentId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_GET_AREA_LIST];
- config.instructions = @"获取区域列表";
- config.requestType = ZYLNetworkRequestTypeGet;
- if (StringIsNotEmpty(parentId)) {
- config.requestParameters = @{@"parentId":parentId};
- }
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /**
- 创建收货地址
- @param deliveryContactName 收件人
- @param deliveryContactPhone 手机号
- @param areaId 区域id
- @param deliveryAddress 详细地址
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)addDeliveryWithDeliveryContactName:(NSString *)deliveryContactName deliveryContactPhone:(NSString *)deliveryContactPhone areaId:(NSString *)areaId deliveryAddress:(NSString *)deliveryAddress successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_ADD_DELIVERY];
- config.instructions = @"创建收货地址";
- config.requestParameters = @{@"deliveryContactName":deliveryContactName, @"deliveryContactPhone":deliveryContactPhone, @"areaId":areaId, @"deliveryAddress":deliveryAddress};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /**
- 获取收货地址列表
- @param pageIndex 页码
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)getDeliveryListPageIndex:(NSInteger)pageIndex successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_GET_DELIVERY_LIST];
- config.instructions = @"获取收货地址列表";
- config.requestParameters = @{@"pageIndex":@(pageIndex)};
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /**
- 获取默认收货地址
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)getDefaultDeliverySuccessHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_GET_DEFAULT_DELIVERY];
- config.instructions = @"获取默认收货地址";
- config.requestType = ZYLNetworkRequestTypeGet;
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /**
- 删除收货地址
- @param deliveryId 要删除的收货地址id
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)deleteDeliveryWithDeliveryId:(NSString *)deliveryId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_DELETE_DELIVERY];
- config.instructions = @"删除收货地址";
- config.requestParameters = @{@"deliveryId":deliveryId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /**
- 设置默认收货地址
- @param deliveryId 收货地址id
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)setDefaultDeliveryWithDeliveryId:(NSString *)deliveryId successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_SET_DEFAULT_DELIVERY];
- config.instructions = @"设置默认收货地址";
- config.requestParameters = @{@"deliveryId":deliveryId};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- /**
- 编辑收货地址
- @param deliveryId 收货地址id
- @param deliveryContactName 收件人
- @param deliveryContactPhone 联系电话
- @param areaId 区域id
- @param deliveryAddress 详细地址
- @param successHandler 请求成功回调
- @param failureHandler 请求失败回调
- @return 请求标示
- */
- - (NSNumber *)modifyDeliveryWithDeliveryId:(NSString *)deliveryId deliveryContactName:(NSString *)deliveryContactName deliveryContactPhone:(NSString *)deliveryContactPhone areaId:(NSString *)areaId deliveryAddress:(NSString *)deliveryAddress successHandler:(ZYLNetworkTaskSuccessHandler)successHandler failureHandler:(ZYLNetworkTaskFailureHandler)failureHandler {
-
- ZYLDataAPIConfiguration *config = [ZYLDataAPIConfiguration new];
- config.urlPath = [NSString stringWithFormat:@"%@%@", [ZYLService currentService].mallBaseUrl, COMMON_MODIFY_DELIVERY];
- config.instructions = @"编辑收货地址";
- config.requestParameters = @{@"deliveryId":deliveryId,
- @"deliveryContactName":deliveryContactName,
- @"deliveryContactPhone":deliveryContactPhone,
- @"areaId":areaId,
- @"deliveryAddress":deliveryAddress};
-
- return [super dispatchDataTaskWithConfiguration:config successHandler:successHandler failureHandler:failureHandler];
- }
- @end
|