コード例 #1
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def retrieve_raw_keyword_bidrec(self, profile_id,
                                 adgroup_id, raw_keyword_col):
     seller_profile = SellerProfile.objects. \
         filter(profile_id=profile_id).first()
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     return api_manager.retrieve_raw_keyword_bidrec(
         profile_id, adgroup_id, raw_keyword_col)
コード例 #2
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def update_campaign(self, profile_id, data):
     seller_profile = SellerProfile.objects \
         .filter(profile_id=profile_id).first()
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     result, campaign_ids = [], []
     for is_success, data in api_manager.operate_entity(
             profile_id, 'campaigns', True, data):
         if is_success:
             campaign_ids.append(data)
         result.append({is_success: data})
     api_manager.retrieve_entity(profile_id, 'campaigns',
                                 campaign_id_filter=campaign_ids)
     return result
コード例 #3
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def create_adgroup(self, profile_id, data):
     seller_profile = SellerProfile.objects \
         .filter(profile_id=profile_id).first()
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     result, adgroup_ids = [], []
     for is_success, data in api_manager.operate_entity(
             profile_id, 'adGroups', False, data):
         if is_success:
             adgroup_ids.append(data)
         result.append({is_success: data})
     api_manager.retrieve_entity(profile_id, 'adGroups',
                                 adgroup_id_filter=adgroup_ids)
     return result
コード例 #4
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def add_campaign_negative_keywords(self, profile_id, data):
     seller_profile = SellerProfile.objects.get(profile_id=profile_id)
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     result, keyword_ids = [], []
     # add campaigns.
     for is_success, data in api_manager.operate_entity(
             profile_id, 'campaignNegativeKeywords', False, data):
         if is_success:
             keyword_ids.append(data)
         result.append({is_success: data})
     api_manager.retrieve_entity(profile_id, 'campaignNegativeKeywords',
                                 keyword_id_filter=keyword_ids)
     return result
コード例 #5
0
ファイル: tasks.py プロジェクト: tompig666/amazonads
def retrieve_profiles():
    sellers = CustomerSeller.objects.all()
    for seller in sellers:
        APIManager(seller_uuid=seller.seller_uuid).retrieve_profile_dict()
        logger.info('celery retrieve_profiles of customer %s' %
                    seller.customer_id)
    return 'ok'
コード例 #6
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def delete_adgroup_negative_keywords(self, profile_id, data):
     """
     About data format:
     [{keyword_id: 123,}]
     """
     seller_profile = SellerProfile.objects.get(profile_id=profile_id)
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     delete_data = [{**item, **{'state': 'archived'}} for item in data]
     result = []
     for is_success, data in api_manager.operate_entity(
             profile_id, 'negativeKeywords', True, delete_data):
         if is_success:
             AdgroupNegativeKeyword().put(
                 AdgroupNegativeKeyword.generate_rowkey(profile_id, data),
                 {'state': 'deleted'}
             )
         result.append({is_success: data})
     return result
コード例 #7
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def archive_campaign_negative_keyword(self, profile_id, keyword_id):
     seller_profile = SellerProfile.objects.get(profile_id=profile_id)
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     api_manager.archive_single_entity(profile_id,
                                       'campaignNegativeKeywords',
                                       keyword_id)
     APIManager.retrieve_entity(profile_id,
                                'campaignNegativeKeywords',
                                 keyword_id_filter=keyword_id
                             )
     return True
コード例 #8
0
ファイル: views.py プロジェクト: tompig666/amazonads
 def get(self, request):
     code = request.GET.get('code')
     if not code:
         return JsonResponse({'code': 1, 'msg': 'code can not be null'})
     state = request.GET.get('state')
     if not state:
         return JsonResponse({'code': 1, 'msg': 'state can not be null'})
     info = base64.b64decode(state).decode().split(',')
     email = info[0]
     client_id = info[1]
     res = APIManager.auth(email, code, client_id)
     if res:
         # status=0字段,表示没有授权过
         return redirect(settings.FRONT_AUTH_SUCCESS_URL + '?status=0')
     else:
         # status = 1 字段表示已经授权过
         return redirect(settings.FRONT_AUTH_SUCCESS_URL + '?status=1')
コード例 #9
0
ファイル: views.py プロジェクト: tompig666/amazonads
    def get(self, request):
        email = request.GET.get('name')
        if not email:
            return JsonResponse({'code': 1, 'msg': 'name can not be null'})

        authorization = request.META['HTTP_AUTHORIZATION']
        logger.info('authUrl api start to get client_id')
        client_id = get_client_id(authorization)
        logger.info('authUrl api get client_id success')
        info = email + ',' + client_id
        state = base64.b64encode(info.encode('utf-8'))
        content = {
            "code": 0,
            "data": {
                "auth_url": APIManager.assemble_authcode_url(state=state)
            }
        }
        return JsonResponse(content)
コード例 #10
0
ファイル: actions.py プロジェクト: tompig666/amazonads
 def retrieve_keyword_bidrec(self, profile_id, keyword_id):
     seller_profile = SellerProfile.objects\
         .filter(profile_id=profile_id).first()
     api_manager = APIManager(seller_profile.seller_id, self.__retry)
     return api_manager.retrieve_keyword_bidrec(profile_id, keyword_id)