Beispiel #1
0
class MasterReport:  #광고 정보 일괄 다운로드
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    MasterReportObjectList = List[MasterReportObject]

    def list(self) -> MasterReportObjectList:
        result = self.conn.get('/master-reports')
        return result

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

    def create(self, item: str, fromTime: str) -> MasterReportObject:
        data = jsonpickle.encode(CreateMasterReportObject(item, fromTime),
                                 unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.post('/master-reports', data_str)
        return result

    def delete_all(self):
        self.conn.delete('/master-reports')
        return True

    def delete_by_id(self, id: str):
        self.conn.delete('/master-reports/' + id)
        return True
Beispiel #2
0
class StatReport:  # 대용량 보고서
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    StatReportObjectList = List[StatReportObject]

    def get_stat_report_list(self) -> StatReportObjectList:
        result = self.conn.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.conn.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.dropna(data)
        data_str = json.dumps(data)

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

    def delete_stat_reports(self, reportJobId: str):
        self.conn.delete('/stat-reports/' + reportJobId)
        return True
Beispiel #3
0
class StatReport:  #대용량 다운로드 보고서
    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    StatReportObjectList = List[StatReportObject]

    def list(self) -> StatReportObjectList:
        result = self.conn.get('/stat-reports')
        return result

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

    def create(self, reportTp, statDt) -> StatReportObject:
        data = jsonpickle.encode(CreateStatReportObject(reportTp, statDt), unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.post('/stat-reports', data_str)

        return result

    def delete_all(self):
        self.conn.delete('/stat-reports/')
        return True

    def delete_by_id(self, reportJobId: str):
        self.conn.delete('/stat-reports/' + reportJobId)
        return True
Beispiel #4
0
class IpExclusion:
    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    ExclusionIdList = List[str]

    def get(self):
        result = self.conn.get('/tool/ip-exclusions')
        return result

    def create(self, filterIp, memo) -> IpExclusionObject:
        data = jsonpickle.encode(CreateIpExclusionObject(filterIp, memo), unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.post('/tool/ip-exclusions', data_str)
        return result

    def update(self, filterIp, ipFilterId, memo) -> IpExclusionObject:
        data = jsonpickle.encode(UpdateIpExclusionObject(filterIp, ipFilterId, memo), unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.put('/tool/ip-exclusions', data_str)
        return result

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

    def delete_by_ids(self, id_array: ExclusionIdList):
        query = {'ids':id_array}
        self.conn.delete('/tool/ip-exclusions', query)
        return True
Beispiel #5
0
class AdKeyword:
    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    AdKeywordList = List[AdKeywordObject]
    AdKeywordIdList = List[str]

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

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

    def 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.conn.get('/ncc/keywords', query)
        return result

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

    def create(self, nccAdgroupId, CreateAdKeywordObject) -> AdKeywordObject:
        data = jsonpickle.encode(CreateAdKeywordObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data = [data]
        data_str = json.dumps(data)
        result = self.conn.post('/ncc/keywords', data_str, {'nccAdgroupId': nccAdgroupId})
        return result

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

        query = {'fields': fields}

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

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

    def delete_items(self, ids: AdKeywordIdList):
        ids = ",".join(ids)
        query = {'ids': ids}
        self.conn.delete('/ncc/keywords', query)
class BusinessChannel:
    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    BusinessChannelObjectList = List[BusinessChannelObject]
    BusinessChannelIdList = List[str]

    def get(self, businessChannelId: str):
        result = self.conn.get('/ncc/channels/' + businessChannelId)
        return result

    def list(self):
        result = self.conn.get('/ncc/channels')
        return result

    def list_by_channel_type(self, channelTp: str):
        result = self.conn.get('/ncc/channels', {'channelTp': channelTp})
        return result

    def list_by_ids(self, ids: BusinessChannelIdList):
        ids = ",".join(ids)
        query = {'ids': ids}
        result = self.conn.get('/ncc/channels', query)
        return result

    def create(self, CreateBusinessChannelObject: CreateBusinessChannelObject) -> BusinessChannelObject:
        data = jsonpickle.encode(CreateBusinessChannelObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.post('/ncc/channels', data_str)
        return result

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

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

    def delete_by_ids(self, ids: BusinessChannelIdList):
        ids = ",".join(ids)
        query = {'ids': ids}
        self.conn.delete('/ncc/channels', query)
        return True
Beispiel #7
0
class AdExtension:  # 확장소재
    def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)
    AdExtensionObjectList = List[AdExtensionObject]
    IdList = List[str]
    ChangeFieldsList = List[str]

    def list_by_owner_id(self, ownerId: str) -> AdExtensionObjectList:
        result = self.conn.get('/ncc/ad-extensions', {'ownerId': ownerId})
        return result

    def list_by_ids(self, ids: IdList) -> AdExtensionObjectList:
        ids = ",".join(ids)
        ids = {'ids': ids}
        result = self.conn.get('/ncc/ad-extensions', ids)
        return result

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

    def create(self, CreateAdExtensionObject: CreateAdExtensionObject) -> AdExtensionObject:
        data = jsonpickle.encode(CreateAdExtensionObject, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = data
        data_str = json.dumps(data_str)
        result = self.conn.post('/ncc/ad-extensions', data_str)
        return result

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

    def delete(self, adExtensionId: str):
        self.conn.delete('/ncc/ad-extensions/' + adExtensionId)
        return True
Beispiel #8
0
class MasterReport:  # 광고정보일괄다운로드탭
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    MasterReportObjectList = List[MasterReportObject]

    def get_master_report_list(self) -> MasterReportObjectList:
        result = self.conn.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.conn.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.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.post('/master-reports', data_str)
        result = MasterReportObject(result)
        return result

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

    def delete_master_report_by_id(self, id: str):
        self.conn.delete('/master-reports', {'id': id})
        return True
Beispiel #9
0
class Ad:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    AdIdList = List[str]
    AdObjectList = List[AdObject]
    ChangeFieldsList = List[str]

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

    def list_by_adgroup_id(self, nccAdGroupId: str) -> AdObjectList:
        result = self.conn.get('/ncc/ads', {'nccAdgroupId': nccAdGroupId})
        return result

    def list(self, ids: AdIdList) -> AdObjectList:
        ids = ",".join(ids)
        ids = {'ids': ids}
        result = self.conn.get('/ncc/ads', ids)
        return result

    def create(self, adObject, nccAdgroupId, type, inspectRequestMsg,
               userLock) -> AdObject:
        data = jsonpickle.encode(CreateAdObject(adObject, nccAdgroupId, type,
                                                inspectRequestMsg, userLock),
                                 unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = data
        data_str = json.dumps(data_str)
        result = self.conn.post('/ncc/ads', data_str)
        return result

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

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

    def copy(self, adId: str, targetAdGroupId: str,
             userLock: bool) -> AdObject:
        query = {
            'ids': adId,
            'targetAdgroupId': targetAdGroupId,
            'userLock': userLock
        }
        result = self.conn.put('/ncc/ads', None, query)
        return result
Beispiel #10
0
class Ad:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    AdIdList = List[str]
    AdObjectList = List[AdObject]
    ChangeFieldsList = List[str]

    def get_ad_list_by_ids(self, ids: AdIdList) -> AdObjectList:
        ids = ",".join(ids)
        ids = {'ids': ids}
        result = self.conn.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.conn.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.conn.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.dropna(data)
        data_str = data
        data_str = json.dumps(data_str)
        result = self.conn.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.dropna(data)
        data_str = data
        data_str = json.dumps(data_str)
        result = self.conn.put('/ncc/ads/' + adId, data_str, query)
        result = AdObject(result)
        return result

    def delete_ad(self, adId: str):
        self.conn.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.conn.put('/ncc/ads', None, query)
        result = AdObject(result)
        return result
Beispiel #11
0
class Adgroup:
    def __init__(self, base_url: str, api_key: str, secret_key: str,
                 customer_id: int):
        self.conn = Connector(base_url, api_key, secret_key, customer_id)

    RestrictedKeywordsAddObject = List[RestrictedKeywordsObject]
    RestrictedKeywordList = List[RestrictedKeyword]
    AdgroupList = List[AdgroupObject]
    AdgroupIdList = List[str]
    RestrictedKeywordIdList = List[str]
    ChangeFieldsList = List[str]

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

    def list_by_ids(self, ids: AdgroupIdList) -> AdgroupList:
        ids = ",".join(ids)
        query = {'ids': ids}
        result = self.conn.get('/ncc/adgroups', query)
        return result

    def list_keyword_plus_restricted_keywords(
            self, adgroupId: str) -> RestrictedKeywordList:
        query = {'type': 'KEYWORD_PLUS_RESTRICT'}
        result = self.conn.get(
            '/ncc/adgroups/' + adgroupId + "/restricted-keywords", query)
        return result

    def list_by_campaign_id(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.conn.get('/ncc/adgroups', query)
        return result

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

    def create(self, create_adgroup_object: CreateAdgroupObject):
        data = jsonpickle.encode(create_adgroup_object, unpicklable=False)
        data = json.loads(data)
        data = CommonFunctions.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.post('/ncc/adgroups', data_str)
        return result

    def update(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.dropna(data)
        data_str = json.dumps(data)
        result = self.conn.put('/ncc/adgroups/' + adgroupId, data_str, query)
        return result

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

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

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