Beispiel #1
0
class Stat:

    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_stat_by_id(self, id: str, fields: str, timeRange: str, dataPreset: str = None, timeIncrement: str = None,
                                                                                    breakdown: str = None) -> StatObject:
        query = {'id': id, 'fields': fields, 'timeRange': timeRange, 'dataPreset': dataPreset,
                     'timeIncrement': timeIncrement, 'breakdown': breakdown}
        result = self.r.get('/stats', query)
        result = StatObject(result)

        return result
        
    def get_stat_by_ids(self, ids: StatIdList, fields: str, timeRange: str, dataPreset: str= None,
                                                        timeIncrement: str = None, breakdown: str = None) -> StatObject:

        query = {'ids': ids, 'fields': fields, 'timeRange': timeRange, 'dataPreset': dataPreset,
                     'timeIncrement': timeIncrement, 'breakdown': breakdown}
        result = self.r.get('/stats', query)
        result = StatObject(result)

        return result

    def get_stat_by_type(self, id: str, statType: str) -> StatTypeObject:
        query = {'id' :id, 'statType' : statType}
        result = self.r.get('/stats', query)
        result = StatTypeObject(result)
        return result
Beispiel #2
0
class RelKwdStat:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_rel_kwd_stat_list(self,
                              siteId: str = None,
                              biztpId: int = None,
                              hintKeywords: str = None,
                              event: int = None,
                              month: int = None,
                              showDetail: int = None) -> RelKwdStatObjectList:

        query = {
            'siteId': siteId,
            'biztpId': biztpId,
            'hintKeywords': hintKeywords,
            'event': event,
            'month': month,
            'showDetail': showDetail
        }
        result = self.r.get('/keywordstool', query)
        result = result['keywordList']
        relstat_list = []

        for arr in result:
            relstat = RelKwdStatObject(arr)
            relstat_list.append(relstat)

        return relstat_list
Beispiel #3
0
class Label:  #즐겨찾기
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_label_list(self) -> LabelObjectList:
        result = self.r.get('/ncc/labels')

        label_list = []
        for arr in result:
            label = LabelObject(arr)
            label_list.append(label)

        return label_list

    def update_label(self,
                     UpdateLabelObject: UpdateLabelObject) -> LabelObject:
        data = jsonpickle.encode(UpdateLabelObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.put('/ncc/labels', data_str)

        result = LabelObject(result)

        return result

    def update_label_ref(
            self,
            UpdateLabelRefObject: UpdateLabelRefObject) -> LabelRefObjectList:
        data = jsonpickle.encode(UpdateLabelRefObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data = [data]
        data_str = json.dumps(data)

        result = self.r.put('/ncc/label-refs/', data_str)

        labelref_list = []
        for arr in result:
            labelref = LabelRefObject(arr)
            labelref_list.append(labelref)

        return labelref_list
Beispiel #4
0
class Bizmoney:

    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_biz_money(self) -> BizmoneyObject:
        result = self.r.get('/billing/bizmoney')
        result = BizmoneyObject(result)

        return result

    def get_biz_money_cost(self, statDt: str) -> BizmoneyCostObjectList:
        result = self.r.get('/billing/bizmoney/cost/' + statDt)
        cost_list = []
        for arr in result:
            cost = BizmoneyCostObject(arr)
            cost_list.append(cost)

        return cost_list
Beispiel #5
0
class StatReport:  #대용량 보고서
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_stat_report_list(self) -> StatReportObjectList:
        result = self.r.get('/stat-reports')
        stat_list = []
        for arr in result:
            stat = StatReportObject(arr)
            stat_list.append(stat)

        return stat_list

    def get_stat_report(self, reportJobId: str) -> StatReportObject:
        result = self.r.get('/stat-reports/' + reportJobId)
        result = StatReportObject(result)

        return result

    def create_stat_report(
            self, CreateStatReportObject: CreateStatReportObject
    ) -> StatReportObject:

        data = jsonpickle.encode(CreateStatReportObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/stat-reports', data_str)
        result = StatReportObject(result)

        return result

    def delete_stat_reports(self, reportJobId: str):
        self.r.delete('/stat-reports/' + reportJobId)
        return True
Beispiel #6
0
class ManagedCustomerLink:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_managed_customer_link_list(self,
                                       rel_type: str = None
                                       ) -> ManagedCustomerLinkObjectList:
        query = {'type': rel_type}
        result = self.r.get('/customer-links', query)
        customer_list = []
        for arr in result:
            customer = ManagedCustomerLinkObject(arr)
            customer_list.append(customer)

        return customer_list
Beispiel #7
0
class IpExclusion:

    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_ip_exclusion(self):
        result = self.r.get('/tool/ip-exclusions')

        ip_exclusion_list = []
        for arr in result:
            ipex = IpExclusionObject(arr)
            ip_exclusion_list.append(ipex)

        return ip_exclusion_list

    def create_ip_exclusion(self, CreateIpExclusionObject: CreateIpExclusionObject) -> IpExclusionObject:
        data = jsonpickle.encode(CreateIpExclusionObject, unpicklable=False)
        data = json.loads(data)       
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/tool/ip-exclusions', data_str)
        result = IpExclusionObject(result)

        return result

    def update_ip_exclusion(self, UpdateIpExclusionObject: UpdateIpExclusionObject) -> UpdateIpExclusionObject:
        data = jsonpickle.encode(UpdateIpExclusionObject, unpicklable=False)
        data = json.loads(data)       
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.put('/tool/ip-exclusions', data_str)
        result = IpExclusionObject(result)

        return result

    def delete_ip_exclusion(self, id: str):
        result = self.r.delete('/tool/ip-exclusions/' + id)
        result = IpExclusionObject(result)

        return result

    def delete_ip_exclusion_many(self, id_array: ExclusionIdList):
        query = {'ids' : id_array}
        self.r.delete('/tool/ip-exclusions', query)

        return True
Beispiel #8
0
class MasterReport:  #광고정보일괄다운로드탭
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_master_report_list(self) -> MasterReportObjectList:
        result = self.r.get('/master-reports')

        mreport_list = []
        for arr in result:
            mreport = MasterReportObject(arr)
            mreport_list.append(mreport)

        return mreport_list

    def get_master_report_by_id(self, id: str) -> MasterReportObject:
        result = self.r.get('/master-reports/' + id)

        result = MasterReportObject(result)
        return result

    def create_master_report(
        self, CreateMasterReportObject: CreateMasterReportObject
    ) -> MasterReportObject:
        data = jsonpickle.encode(CreateMasterReportObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/master-reports', data_str)
        result = MasterReportObject(result)

        return result

    def delete_master_report_all(self):
        self.r.delete('/master-reports')
        return True

    def delete_master_report_by_id(self, id: str):
        self.r.delete('/master-reports', {'id': id})
        return True
Beispiel #9
0
 def __init__(self, base_url: str, api_key: str, secret_key: str,
              customer_id: int):
     self.r = RestApi(base_url, api_key, secret_key, customer_id)
Beispiel #10
0
class AdExtension:  #확장소재
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_ad_extensions_list(self, ownerId: str) -> AdExtensionObjectList:
        result = self.r.get('/ncc/ad-extensions', {'ownerId': ownerId})
        adext_list = []
        for arr in result:
            camp = AdExtensionObject(arr)
            adext_list.append(camp)
        return adext_list

    def get_ad_extensions_list_by_ids(self,
                                      ids: IdList) -> AdExtensionObjectList:
        ids = ",".join(ids)
        ids = {'ids': ids}
        result = self.r.get('/ncc/ad-extensions', ids)
        adext_list = []
        for arr in result:
            camp = AdExtensionObject(arr)
            adext_list.append(camp)
        return adext_list

    def get_ad_extensions(self, adExtensionId: str) -> AdExtensionObject:
        result = self.r.get('/ncc/ad-extensions/' + adExtensionId)
        result = AdExtensionObject(result)

        return result

    def create_ad_extensions(
            self, CreateAdExtensionObject: CreateAdExtensionObject
    ) -> AdExtensionObject:

        data = jsonpickle.encode(CreateAdExtensionObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = data
        data_str = json.dumps(data_str)

        result = self.r.post('/ncc/ad-extensions', data_str)
        result = AdExtensionObject(result)
        return result

    def update_ad_extensions(
            self, adExtensionId: str, fields: ChangeFieldsList,
            UpdateAdExtensionObject: UpdateAdExtensionObject
    ) -> AdExtensionObject:

        data = jsonpickle.encode(UpdateAdExtensionObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = data
        data_str = json.dumps(data_str)
        change_fields_list = ",".join(fields)
        query = {'fields': change_fields_list}
        result = self.r.put('/ncc/ad-extensions/' + adExtensionId, data_str,
                            query)
        result = AdExtensionObject(result)
        return result

    def delete_ad_extensions(self, adExtensionId: str):
        self.r.delete('/ncc/ad-extensions/' + adExtensionId)
        return True
Beispiel #11
0
class BusinessChannel:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_business_channel_list(self) -> BusinessChannelObjectList:
        result = self.r.get('/ncc/channels')

        business_channel_list = []
        for arr in result:
            channel = BusinessChannelObject(arr)
            business_channel_list.append(channel)

        return business_channel_list

    def get_business_channel_list_by_type(
            self, tp: str) -> BusinessChannelObjectList:
        result = self.r.get('/ncc/channels', {'channelTp': tp})

        business_channel_list = []
        for arr in result:
            channel = BusinessChannelObject(arr)
            business_channel_list.append(channel)

        return business_channel_list

    def get_business_channel_list_by_ids(
            self, ids: BusinessChannelIdList) -> BusinessChannelObjectList:
        ids = ",".join(ids)
        query = {'ids': ids}
        result = self.r.get('/ncc/channels', query)

        business_channel_list = []
        for arr in result:
            channel = BusinessChannelObject(arr)
            business_channel_list.append(channel)
        return business_channel_list

    def get_business_channel(self, businessChannelId) -> BusinessChannelObject:
        result = self.r.get('/ncc/channels/' + businessChannelId)
        result = BusinessChannelObject(result)

        return result

    def create_business_channel(
        self, CreateBusinessChannelObj: CreateBusinessChannelObject
    ) -> BusinessChannelObject:

        data = jsonpickle.encode(CreateBusinessChannelObj, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)
        result = self.r.post('/ncc/channels', data_str)
        result = BusinessChannelObject(result)
        return result

    def update_business_channel(
        self, fields, UpdateBusinessChannelObj: UpdateBusinessChannelObject
    ) -> BusinessChannelObject:
        data = jsonpickle.encode(UpdateBusinessChannelObj, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)
        result = self.r.put('/ncc/channels', data_str, fields)
        result = BusinessChannelObject(result)
        return result

    def delete_business_channel(self, businessChannelId: str):
        self.r.delete('/ncc/channels/' + businessChannelId)
        return True

    def delete_business_channel_by_ids(self, ids: BusinessChannelIdList):
        ids = ",".join(ids)
        query = {'ids': ids}
        self.r.delete('/ncc/channels', query)
        return True
Beispiel #12
0
class AdKeyword:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_adkeyword_list_by_label_id(self, nccLabelId: str) -> AdKeywordList:
        query = {'nccLabelId': nccLabelId}
        result = self.r.get('/ncc/keywords', query)

        adkeyword_list = []
        for arr in result:
            keyword = AdKeywordObject(arr)
            adkeyword_list.append(keyword)

        return adkeyword_list

    def get_adkeyword_list_by_ids(self, ids: AdKeywordIdList) -> AdKeywordList:
        ids = ",".join(ids)
        query = {'ids': ids}
        result = self.r.get('/ncc/keywords', query)

        adkeyword_list = []
        for arr in result:
            keyword = AdKeywordObject(arr)
            adkeyword_list.append(keyword)

        return adkeyword_list

    def get_adkeyword_list_by_group_id(self,
                                       nccAdgroupId: str = None,
                                       baseSearchId: str = None,
                                       recordSize: int = None,
                                       selector: str = None) -> AdKeywordList:

        query = {
            'nccAdgroupId': nccAdgroupId,
            'baseSearchId': baseSearchId,
            'recordSize': recordSize,
            'selector': selector
        }
        result = self.r.get('/ncc/keywords', query)

        adkeyword_list = []
        for arr in result:
            keyword = AdKeywordObject(arr)
            adkeyword_list.append(keyword)

        return adkeyword_list

    def get_adkeyword(self, nccKeywordId) -> AdKeywordObject:
        result = self.r.get('/ncc/keywords/' + nccKeywordId)
        result = AdKeywordObject(result)
        return result

    def create_adkeyword(self, nccAdgroupId,
                         CreateAdKeywordObject) -> AdKeywordObject:
        data = jsonpickle.encode(CreateAdKeywordObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data = [data]
        data_str = json.dumps(data)

        result = self.r.post('/ncc/keywords', data_str,
                             {'nccAdgroupId': nccAdgroupId})
        result = AdKeywordObject(result)
        return result

    def update_adkeyrword(self, nccKeywordId, fields,
                          UpdateAdKeywordObject) -> AdKeywordObject:
        data = jsonpickle.encode(UpdateAdKeywordObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        query = {'fields': fields}

        result = self.r.put('/ncc/keywords/' + nccKeywordId, data_str, query)
        result = AdKeywordObject(result)

        return result

    def delete_adkeyword(self, nccKeywordId: str):
        self.r.delete('/ncc/keywords/' + nccKeywordId)
        return True

    def delete_adkeyword_many(self, ids: AdKeywordIdList):
        ids = ",".join(ids)
        query = {'ids': ids}
        self.r.delete('/ncc/keywords', query)

    def managed_keyword_list(self,
                             keywords: KeywordsList) -> ManagedKeywordObject:
        keywords = ",".join(keywords)
        query = {'keywords': keywords}
        result = self.r.get('/ncc/managedKeyword', query)

        managedkeyword_list = []
        for arr in result:
            managedkeyword = ManagedKeywordObject(arr)
            managedkeyword_list.append(managedkeyword)

        return managedkeyword_list
Beispiel #13
0
class Ad:  #광고 소재에 관한 API입니다.
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_ad_list_by_ids(self, ids: AdIdList) -> AdObjectList:
        ids = ",".join(ids)
        ids = {'ids': ids}
        result = self.r.get('/ncc/ads', ids)
        ad_obj_list = []
        for arr in result:
            ad_obj = AdObject(arr)
            ad_obj_list.append(ad_obj)

        return ad_obj_list

    def get_ad_list(self, nccAdGroupId: str) -> AdObjectList:
        result = self.r.get('/ncc/ads', {'nccAdgroupId': nccAdGroupId})
        adobj_list = []
        for arr in result:
            ad_obj = AdObject(arr)
            adobj_list.append(ad_obj)

        return adobj_list

    def get_ad(self, adId: str) -> AdObject:
        result = self.r.get('/ncc/ads/' + adId)
        result = AdObject(result)
        return result

    def create_ad(self, CreateAdObject: CreateAdObject) -> AdObject:
        data = jsonpickle.encode(CreateAdObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = data
        data_str = json.dumps(data_str)
        result = self.r.post('/ncc/ads', data_str)
        result = AdObject(result)
        return result

    def update_ad(self, adId: str, fields: ChangeFieldsList,
                  UpdateAdObject: UpdateAdObject) -> AdObject:
        change_fields_list = ",".join(fields)
        query = {'fields': change_fields_list}
        data = jsonpickle.encode(UpdateAdObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = data
        data_str = json.dumps(data_str)
        result = self.r.put('/ncc/ads/' + adId, data_str, query)
        result = AdObject(result)
        return result

    def delete_ad(self, adId: str):
        self.r.delete('/ncc/ads/' + adId)
        return True

    def copy_ad(self, adId: str, targetAdGroupId: str,
                userLock: bool) -> AdObject:
        query = {
            'ids': adId,
            'targetAdgroupId': targetAdGroupId,
            'userLock': userLock
        }
        result = self.r.put('/ncc/ads', None, query)
        result = AdObject(result)
        return result
Beispiel #14
0
class Campaign:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_campaign_list(self,
                          campaignType: str = None,
                          baseSearchId: str = None,
                          recordSize: int = None,
                          selector: str = None) -> CampaignList:

        query = {
            'campaignType': campaignType,
            'baseSearchId': baseSearchId,
            'recordSize': recordSize,
            'selector': selector
        }
        result = self.r.get('/ncc/campaigns', query)

        camp_list = []
        for arr in result:
            camp = CampaignObject(arr)
            camp_list.append(camp)

        return camp_list

    def get_campaign_list_by_ids(self, ids: CampaignIdList) -> CampaignList:
        ids = ",".join(ids)
        query = {'ids': ids}

        result = self.r.get('/ncc/campaigns', query)

        camp_list = []
        for arr in result:
            camp = CampaignObject(arr)
            camp_list.append(camp)

        return camp_list

    def get_campaign(self, campaignId: str) -> CampaignObject:
        result = self.r.get('/ncc/campaigns/' + campaignId)
        camp = CampaignObject(result)
        return camp

    def create_campaign(self, campaign_add_object: CampaignAddObject):

        data = jsonpickle.encode(campaign_add_object, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)
        result = self.r.post('/ncc/campaigns', data_str)
        camp = CampaignObject(result)
        return camp

    def update_campaign(self, campaign_update_object: CampaignUpdateObject,
                        campaignId: str,
                        fields: ChangeFieldsList) -> CampaignList:
        fields = ",".join(fields)
        fields = {'fields': fields}
        data = jsonpickle.encode(campaign_update_object, unpicklable=False)
        result = self.r.put('/ncc/campaigns/' + str(campaignId), data,
                            fields)  #userLock, budget, period
        camp = CampaignObject(result)
        return camp
Beispiel #15
0
class Estimate:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_avg_position_bid_list(
        self, type, GetAvgPositionBidObject: GetAvgPositionBidObject
    ) -> EstimateAvgObjectList:

        data = jsonpickle.encode(GetAvgPositionBidObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/estimate/average-position-bid/' + type,
                             data_str)
        result = result['estimate']
        estimate_list = []
        for arr in result:
            estimate = EstimateAvgObject(arr)
            estimate_list.append(estimate)

        return estimate_list

    def get_median_bid_list(
            self, type: str, GetMedianBidObject: GetMedianBidObject
    ) -> EstimateMedianObjectList:
        data = jsonpickle.encode(GetMedianBidObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/estimate/median-bid/' + type, data_str)
        result = result['estimate']
        estimate_list = []
        for arr in result:
            estimate = EstimateMedianObject(arr)
            estimate_list.append(estimate)

        return estimate_list

    def get_exposure_mini_bid_list(
        self, type: str, GetExposureMiniBidObject: GetExposureMiniBidObject
    ) -> EstimateExposureMiniObjectList:
        data = jsonpickle.encode(GetExposureMiniBidObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/estimate/exposure-minimum-bid/' + type,
                             data_str)
        result = result['estimate']
        estimate_list = []
        for arr in result:
            estimate = EstimateExposureMiniObject(arr)
            estimate_list.append(estimate)

        return estimate_list

    def get_performance_list(
        self, type: str, GetPerformanceObject: GetPerformanceObject
    ) -> EstimatePerformanceObjectList:
        data = jsonpickle.encode(GetPerformanceObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/estimate/performance/' + type, data_str)
        result = result['estimate']

        estimate_list = []
        for arr in result:
            estimate = EstimatePerformanceObject(arr)
            estimate_list.append(estimate)

        return estimate_list

    def get_performance_list_many(
            self, type: str,
            GetPerformanceObjectList: GetPerformanceObjectList):
        data = jsonpickle.encode(GetPerformanceObjectList, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)

        result = self.r.post('/estimate/performance/' + type, data_str)
        result = result['estimate']

        estimate_list = []
        for arr in result:
            estimate = EstimatePerformanceObject(arr)
            estimate_list.append(estimate)

        return estimate_list
Beispiel #16
0
class AdGroup:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.r = RestApi(base_url, api_key, secret_key, customer_id)

    def get_restricted_keyword(self, adgroupId: str) -> RestrictedKeywordList:
        query = {'type': 'KEYWORD_PLUS_RESTRICT'}
        result = self.r.get(
            '/ncc/adgroups/' + adgroupId + "/restricted-keywords", query)
        restricted_list = []
        for arr in result:
            restricted_keyword = RestrictedKeyword(arr)
            restricted_list.append(restricted_keyword)

        return restricted_list

    def get_adgroup_list(self,
                         nccCampaignId: str = None,
                         baseSearchId: str = None,
                         recordSize: int = None,
                         selector: str = None) -> AdGroupList:

        query = {
            'nccCampaignId': nccCampaignId,
            'baseSearchId': baseSearchId,
            'record_size': recordSize,
            'selector': selector
        }
        result = self.r.get('/ncc/adgroups', query)

        adgroup_list = []
        for arr in result:
            camp = AdgroupObject(arr)
            adgroup_list.append(camp)

        return adgroup_list

    def get_adgroup_list_by_ids(self, ids: AdGroupIdList) -> AdGroupList:
        ids = ",".join(ids)
        query = {'ids': ids}
        result = self.r.get('/ncc/adgroups', query)
        adgroup_list = []
        for arr in result:
            camp = AdgroupObject(arr)
            adgroup_list.append(camp)

        return adgroup_list

    def get_adgroup_by_adgroupid(self, adgroupId: str) -> AdgroupObject:
        result = self.r.get('/ncc/adgroups/' + adgroupId)
        adgroup = AdgroupObject(result)
        return adgroup

    def create_restricted_keyword(
        self, adgroupId: str,
        restricted_keywords_object: RestrictedKeywordsAddObject
    ) -> RestrictedKeyword:
        data = jsonpickle.encode(restricted_keywords_object, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = [data]
        data_str = json.dumps(data_str)
        result = self.r.post(
            '/ncc/adgroups/%s/restricted-keywords' % str(adgroupId), data_str)
        restrict_keyword = RestrictedKeyword(result)

        return restrict_keyword

    def create_adgroup(self, create_adgroup_object: CreateAdgroupObject):
        data = jsonpickle.encode(create_adgroup_object, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)
        result = self.r.post('/ncc/adgroups', data_str)
        result = AdgroupObject(result)
        return result

    def update_adgroup(self, adgroupId: str, fields: ChangeFieldsList,
                       UpdateAdgroupObject: UpdateAdgroupObject):
        change_fields_list = ",".join(fields)
        query = {'fields': change_fields_list}
        data = jsonpickle.encode(UpdateAdgroupObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)
        result = self.r.put('/ncc/adgroups/' + adgroupId, data_str, query)
        result = AdgroupObject(result)
        return result

    def update_adgroup_entire(
            self, adgroupId: str,
            UpdateEntireAdgroupObject: UpdateEntireAdgroupObject):
        data = jsonpickle.encode(UpdateEntireAdgroupObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.delete_null_dict_items(data)
        data_str = json.dumps(data)
        result = self.r.put('/ncc/adgroups/' + adgroupId, data_str)
        result = AdgroupObject(result)
        return result

    def delete_group_restricted_keyword(
            self, adgroupId: str, res_keyword_ids: RestrictedKeywordIdList):
        res_keyword_ids = ",".join(res_keyword_ids)
        query = {'ids': res_keyword_ids}
        result = self.r.delete(
            '/ncc/adgroups/%s/restricted-keywords' % str(adgroupId), query)
        return True

    def delete_adgroup(self, adgroupId: str):
        result = self.r.delete('/ncc/adgroups/' + adgroupId)
        return True