├── powernad
├── __init__.py
├── API
│ ├── __init__.py
│ ├── ManagedCustomerLink.py
│ ├── Bizmoney.py
│ ├── RelKwdStat.py
│ ├── Stat.py
│ ├── StatReport.py
│ ├── Target.py
│ ├── MasterReport.py
│ ├── Label.py
│ ├── IpExclusion.py
│ ├── Campaign.py
│ ├── Ad.py
│ ├── AdExtension.py
│ ├── BusinessChannel.py
│ ├── AdKeyword.py
│ ├── Estimate.py
│ └── AdGroup.py
├── Common
│ ├── __init__.py
│ └── CommonFunctions.py
├── Object
│ ├── __init__.py
│ ├── Ad
│ │ ├── __init__.py
│ │ ├── sub
│ │ │ ├── __init__.py
│ │ │ └── AdFieldObject.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── UpdateAdObject.py
│ │ │ └── CreateAdObject.py
│ │ └── AdObject.py
│ ├── Label
│ │ ├── __init__.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── UpdateLabelObject.py
│ │ │ └── UpdateLabelRefObject.py
│ │ ├── LabelRefObject.py
│ │ └── LabelObject.py
│ ├── Stat
│ │ ├── __init__.py
│ │ ├── sub
│ │ │ ├── __init__.py
│ │ │ ├── SummaryObject.py
│ │ │ └── StatDataObject.py
│ │ ├── StatTypeObject.py
│ │ └── StatObject.py
│ ├── AdGroup
│ │ ├── __init__.py
│ │ ├── sub
│ │ │ ├── __init__.py
│ │ │ ├── adgroupAttrJson.py
│ │ │ ├── targetSummaryObject.py
│ │ │ └── target.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── RestrictedKeywordsObject.py
│ │ │ ├── CreateAdgroupObject.py
│ │ │ ├── UpdateEntireAdgroupObject.py
│ │ │ └── UpdateAdgroupObject.py
│ │ ├── RestrictedKeyword.py
│ │ └── AdgroupObject.py
│ ├── AdKeyword
│ │ ├── __init__.py
│ │ ├── sub
│ │ │ ├── __init__.py
│ │ │ └── ManagedKeywordInfoObject.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── CreateAdKeywordObject.py
│ │ │ └── UpdateAdKeywordObject.py
│ │ ├── ManagedKeywordObject.py
│ │ └── AdKeywordObject.py
│ ├── Bizmoney
│ │ ├── __init__.py
│ │ ├── BizmoneyObject.py
│ │ └── BizmoneyCostObject.py
│ ├── Campaign
│ │ ├── __init__.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── CampaignUpdateObject.py
│ │ │ └── CampaignAddObject.py
│ │ └── CampaignObject.py
│ ├── Estimate
│ │ ├── __init__.py
│ │ ├── sub
│ │ │ ├── __init__.py
│ │ │ └── KeyAndPositionObject.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── GetAvgPositionBidObject.py
│ │ │ ├── GetMedianBidObject.py
│ │ │ ├── GetExposureMiniBidObject.py
│ │ │ └── GetPerformanceObject.py
│ │ ├── EstimateMedianObject.py
│ │ ├── EstimateExposureMiniObject.py
│ │ ├── EstimateAvgObject.py
│ │ └── EstimatePerformanceObject.py
│ ├── RelKwdStat
│ │ ├── __init__.py
│ │ └── RelKwdStatObject.py
│ ├── StatReport
│ │ ├── __init__.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ └── CreateStatReportObject.py
│ │ └── StatReportObject.py
│ ├── AdExtension
│ │ ├── __init__.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── UpdateAdExtensionObject.py
│ │ │ └── CreateAdExtensionObject.py
│ │ └── AdExtensionObject.py
│ ├── BusinessChannel
│ │ ├── __init__.py
│ │ ├── sub
│ │ │ ├── __init__.py
│ │ │ └── BusinessInfo.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── CreateBusinessChannelObject.py
│ │ │ └── UpdateBusinessChannelObject.py
│ │ └── BusinessChannelObject.py
│ ├── IpExclusion
│ │ ├── __init__.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ ├── CreateIpExclusionObject.py
│ │ │ └── UpdateIpExclusionObject.py
│ │ └── IpExclusionObject.py
│ ├── MasterReport
│ │ ├── __init__.py
│ │ ├── RequestObject
│ │ │ ├── __init__.py
│ │ │ └── CreateMasterReportObject.py
│ │ └── MasterReportObject.py
│ └── ManagedCustomerLink
│ │ ├── __init__.py
│ │ └── ManagedCustomerLinkObject.py
├── Connector
│ ├── __init__.py
│ └── restapi.py
└── mini_api_doc.md
├── requirements.txt
├── setup.py
├── .gitignore
└── README.md
/powernad/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/API/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Common/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Connector/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Ad/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Label/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Stat/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Ad/sub/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Bizmoney/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Campaign/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/RelKwdStat/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Stat/sub/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/StatReport/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdExtension/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/sub/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/sub/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/sub/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/IpExclusion/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/MasterReport/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Ad/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/sub/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Label/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/ManagedCustomerLink/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdExtension/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Campaign/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/IpExclusion/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/StatReport/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/powernad/Object/MasterReport/RequestObject/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
1 | jsonpickle == 0.9.4
2 | requests==2.20.0
3 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/sub/KeyAndPositionObject.py:
--------------------------------------------------------------------------------
1 | class KeyAndPositionObject:
2 | def __init__(self, key, position):
3 | self.key = key
4 | self.position = position
--------------------------------------------------------------------------------
/powernad/Object/IpExclusion/RequestObject/CreateIpExclusionObject.py:
--------------------------------------------------------------------------------
1 | class CreateIpExclusionObject:
2 | def __init__(self, filterIp):
3 | self.filterIp = filterIp
4 | self.memo = None
--------------------------------------------------------------------------------
/powernad/Object/MasterReport/RequestObject/CreateMasterReportObject.py:
--------------------------------------------------------------------------------
1 | class CreateMasterReportObject:
2 | def __init__(self, item, fromTime):
3 | self.item = item
4 | self.fromTime = fromTime
--------------------------------------------------------------------------------
/powernad/Object/Label/RequestObject/UpdateLabelObject.py:
--------------------------------------------------------------------------------
1 | class UpdateLabelObject:
2 | def __init__(self, nccLabelId):
3 | self.color = None
4 | self.name = None
5 | self.nccLabelId = nccLabelId
--------------------------------------------------------------------------------
/powernad/Object/Estimate/RequestObject/GetAvgPositionBidObject.py:
--------------------------------------------------------------------------------
1 | class GetAvgPositionBidObject:
2 | def __init__(self, device, KeyAndPositonObject):
3 | self.device = device
4 | self.items = KeyAndPositonObject
--------------------------------------------------------------------------------
/powernad/Object/Estimate/RequestObject/GetMedianBidObject.py:
--------------------------------------------------------------------------------
1 | class GetMedianBidObject:
2 | def __init__(self, device, period, keys):
3 | self.device = device
4 | self.period = period
5 | self.items = keys
--------------------------------------------------------------------------------
/powernad/Object/Estimate/RequestObject/GetExposureMiniBidObject.py:
--------------------------------------------------------------------------------
1 | class GetExposureMiniBidObject:
2 | def __init__(self, device, period, keys):
3 | self.device = device
4 | self.period = period
5 | self.items = keys
--------------------------------------------------------------------------------
/powernad/Object/StatReport/RequestObject/CreateStatReportObject.py:
--------------------------------------------------------------------------------
1 | class CreateStatReportObject:
2 | def __init__(self, reportTp, statDt):
3 | self.reportTp = reportTp
4 | self.statDt = statDt
5 | #self.customerId = 1109868
--------------------------------------------------------------------------------
/powernad/Object/IpExclusion/RequestObject/UpdateIpExclusionObject.py:
--------------------------------------------------------------------------------
1 | class UpdateIpExclusionObject:
2 | def __init__(self, filterIp, ipFilterId):
3 | self.filterIp = filterIp
4 | self.ipFilterId = ipFilterId
5 | self.memo = None
--------------------------------------------------------------------------------
/powernad/Object/Ad/RequestObject/UpdateAdObject.py:
--------------------------------------------------------------------------------
1 | class UpdateAdObject:
2 | def __init__(self, adAttr, nccAdId):
3 | self.adAttr = adAttr
4 | self.inspectRequestMsg = None
5 | self.nccAdId = nccAdId
6 | self.userLock = None
--------------------------------------------------------------------------------
/powernad/Object/Estimate/RequestObject/GetPerformanceObject.py:
--------------------------------------------------------------------------------
1 | class GetPerformanceObject:
2 | def __init__(self, device, keywordplus, key, bids):
3 | self.device = device
4 | self.keywordplus = keywordplus
5 | self.key = key
6 | self.bids = bids
--------------------------------------------------------------------------------
/powernad/Object/AdExtension/RequestObject/UpdateAdExtensionObject.py:
--------------------------------------------------------------------------------
1 | class UpdateAdExtensionObject:
2 |
3 | def __init__(self, nccAdExtensionId, schedule=None, userLock = None):
4 | self.nccAdExtensionId = nccAdExtensionId
5 | self.schedule = schedule
6 | self.userLock = userLock
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/RequestObject/CreateAdKeywordObject.py:
--------------------------------------------------------------------------------
1 | class CreateAdKeywordObject:
2 | def __init__(self, keyword):
3 |
4 | self.bidAmt = None
5 | self.customerId = None
6 | self.keyword = keyword
7 | self.useGroupBidAmt = None
8 | self.userLock = None
--------------------------------------------------------------------------------
/powernad/Object/Ad/RequestObject/CreateAdObject.py:
--------------------------------------------------------------------------------
1 | class CreateAdObject:
2 | def __init__(self, adObject, nccAdgroupId, type):
3 | self.ad = adObject
4 | self.inspectRequestMsg = None
5 | self.nccAdgroupId = nccAdgroupId
6 | self.type = type
7 | self.userLock = None
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/RequestObject/CreateBusinessChannelObject.py:
--------------------------------------------------------------------------------
1 | class CreateBusinessChannelObject:
2 | def __init__(self, site_url, name):
3 | self.businessInfo = {'site' : site_url}
4 | self.channelTp = 'SITE'
5 | self.inspectRequestMsg = None
6 | self.name = name
7 |
--------------------------------------------------------------------------------
/powernad/Common/CommonFunctions.py:
--------------------------------------------------------------------------------
1 | class CommonFunctions:
2 |
3 | def delete_null_dict_items(input_dict):
4 | cleaned_dict = dict()
5 | for now in input_dict:
6 | if input_dict[now] != None:
7 | cleaned_dict.update({now: input_dict[now]})
8 |
9 | return cleaned_dict
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/sub/adgroupAttrJson.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class adgroupAttrObject:
4 | def __init__(self, json_def=None):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 | self.campaignTp = None if 'campaignTp' not in s else s['campaignTp']
--------------------------------------------------------------------------------
/powernad/Object/Label/RequestObject/UpdateLabelRefObject.py:
--------------------------------------------------------------------------------
1 | class UpdateLabelRefObject:
2 | def __init__(self, customerId, nccLabelId, refId, refTp):
3 | self.customerId = customerId
4 | self.enable = True
5 | self.nccLabelId = nccLabelId
6 | self.refId = refId
7 | self.refTp = refTp
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/RequestObject/UpdateAdKeywordObject.py:
--------------------------------------------------------------------------------
1 | class UpdateAdKeywordObject:
2 |
3 | def __init__(self, nccAdgroupId, nccKeywordId):
4 |
5 | self.bidAmt = None
6 | self.links = None
7 | self.nccAdgroupId = nccAdgroupId
8 | self.nccKeywordId = nccKeywordId
9 | self.useGroupBidAmt = None
10 | self.userLock = None
--------------------------------------------------------------------------------
/powernad/Object/Campaign/RequestObject/CampaignUpdateObject.py:
--------------------------------------------------------------------------------
1 | class CampaignUpdateObject:
2 | def __init__(self, lock, budget =None, period=None):
3 | if lock != None:
4 | self.userLock = bool(lock)
5 | if budget != None:
6 | self.useDailyBudget = bool(budget)
7 | if period != None:
8 | self.usePeriod = bool(period)
9 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/EstimateMedianObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class EstimateMedianObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 |
8 | s = json_def
9 |
10 | self.bid = None if 'bid' not in s else s['bid']
11 | self.keyword = None if 'keyword' not in s else s['keyword']
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/RequestObject/UpdateBusinessChannelObject.py:
--------------------------------------------------------------------------------
1 | class UpdateBusinessChannelObject:
2 | def __init__(self, nccBusinessChannelId, site_url, name):
3 | self.businessInfo = {'site' : site_url}
4 | self.channelTp = 'SITE'
5 | self.inspectRequestMsg = None
6 | self.name = name
7 | self.nccBusinessChannelId = nccBusinessChannelId
8 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/EstimateExposureMiniObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class EstimateExposureMiniObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 |
8 | s = json_def
9 |
10 | self.bid = None if 'bid' not in s else s['bid']
11 | self.keyword = None if 'keyword' not in s else s['keyword']
--------------------------------------------------------------------------------
/powernad/Object/Stat/sub/SummaryObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class SummaryObject:
4 | def __init__(self, json_def):
5 |
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.dateEnd = None if 'dateEnd' not in s else s['dateEnd']
11 | self.dateStart = None if 'dateStart' not in s else s['dateStart']
12 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/RequestObject/RestrictedKeywordsObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | import datetime
3 |
4 | class RestrictedKeywordsObject:
5 | def __init__(self, keyword, description, nccAdgroupId):
6 | self.delFlag = False
7 | self.description = description
8 | self.keyword = keyword
9 | self.nccAdgroupId = nccAdgroupId
10 | self.type = "KEYWORD_PLUS_RESTRICT"
--------------------------------------------------------------------------------
/powernad/Object/AdExtension/RequestObject/CreateAdExtensionObject.py:
--------------------------------------------------------------------------------
1 | class CreateAdExtensionObject:
2 |
3 | def __init__(self, pcChannelId, mobileChannelId, ownerId, type, userLock):
4 |
5 | self.pcChannelId = pcChannelId
6 | self.mobileChannelId = mobileChannelId
7 | self.ownerId = ownerId
8 | self.schedule = None
9 | self.type = type
10 | self.userLock = userLock
--------------------------------------------------------------------------------
/powernad/Object/Estimate/EstimateAvgObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class EstimateAvgObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 |
8 | s = json_def
9 |
10 | self.bid = None if 'bid' not in s else s['bid']
11 | self.keyword = None if 'keyword' not in s else s['keyword']
12 | self.position = None if 'position' not in s else s['position']
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/ManagedKeywordObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | from ..AdKeyword.sub.ManagedKeywordInfoObject import ManagedKeywordInfoObject
3 |
4 | class ManagedKeywordObject:
5 | def __init__(self, json_def):
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.keyword = None if 'keyword' not in s else s['keyword']
11 | self.managedKeyword = None if 'managedKeyword' not in s else ManagedKeywordInfoObject(s['managedKeyword'])
12 |
13 |
14 |
--------------------------------------------------------------------------------
/powernad/Object/Estimate/EstimatePerformanceObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class EstimatePerformanceObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 |
8 | s = json_def
9 |
10 | self.bid = None if 'bid' not in s else s['bid']
11 | self.clicks = None if 'clicks' not in s else s['clicks']
12 | self.cost = None if 'cost' not in s else s['cost']
13 | self.impressions = None if 'impressions' not in s else s['impressions']
--------------------------------------------------------------------------------
/powernad/Object/Bizmoney/BizmoneyObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class BizmoneyObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.bizmoney = None if 'bizmoney' not in s else s['bizmoney']
10 | self.budgetLock = None if 'budgetLock' not in s else s['budgetLock']
11 | self.customerId = None if 'customerId' not in s else s['customerId']
12 | self.refundLock = None if 'refundLock' not in s else s['refundLock']
--------------------------------------------------------------------------------
/powernad/Object/Stat/StatTypeObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 |
4 | class StatTypeObject:
5 |
6 | def __init__(self, json_def):
7 | if type(json_def) is str:
8 | json_def = json.loads(json_def)
9 | s = json_def
10 |
11 | self.clkCnt = None if 'clkCnt' not in s else s['clkCnt']
12 | self.drtCrto = None if 'drtCrto' not in s else s['drtCrto']
13 | self.salesAmt = None if 'salesAmt' not in s else s['salesAmt']
14 | self.schKeyword = None if 'schKeyword' not in s else s['schKeyword']
15 |
16 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/sub/targetSummaryObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class targetSummaryObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.media = None if 'media' not in s else s['media']
10 | self.pcMobile = None if 'pcMobile' not in s else s['pcMobile']
11 | self.region = None if 'region' not in s else s['region']
12 | self.time = None if 'time' not in s else s['time']
13 | self.week = None if 'week' not in s else s['week']
14 |
--------------------------------------------------------------------------------
/powernad/Object/Campaign/RequestObject/CampaignAddObject.py:
--------------------------------------------------------------------------------
1 | class CampaignAddObject:
2 |
3 | def __init__(self, customerId, campaignTp, name):
4 | self.customerId = customerId
5 | self.campaignTp = campaignTp
6 | self.dailyBudget = None
7 | self.deliveryMethod = None
8 | self.name = name
9 | self.periodEndDt = None
10 | self.periodStartDt = None
11 | self.trackingMode = None
12 | self.trackingUrl = None
13 | self.useDailyBudget = None
14 | self.usePeriod = None
15 | self.userLock = None
--------------------------------------------------------------------------------
/powernad/Object/Label/LabelRefObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class LabelRefObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.nccLabelId = None if 'nccLabelId' not in s else s['nccLabelId']
10 | self.customerId = None if 'customerId' not in s else s['customerId']
11 | self.refId = None if 'refId' not in s else s['refId']
12 | self.refTp = None if 'refTp' not in s else s['refTp']
13 | self.enable = None if 'enable' not in s else s['enable']
--------------------------------------------------------------------------------
/powernad/Object/IpExclusion/IpExclusionObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class IpExclusionObject:
4 |
5 | def __init__(self, json_def):
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.customerId = None if 'customerId' not in s else s['customerId']
11 | self.filterIp = None if 'filterIp' not in s else s['filterIp']
12 | self.ipFilterId = None if 'ipFilterId' not in s else s['ipFilterId']
13 | self.memo = None if 'memo' not in s else s['memo']
14 | self.regTm = None if 'regTm' not in s else s['regTm']
--------------------------------------------------------------------------------
/powernad/Object/Label/LabelObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class LabelObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.color = None if 'color' not in s else s['color']
10 | self.customerId = None if 'customerId' not in s else s['customerId']
11 | self.name = None if 'name' not in s else s['name']
12 | self.nccLabelId = None if 'nccLabelId' not in s else s['nccLabelId']
13 | self.regTm = None if 'regTm' not in s else s['regTm']
14 | self.editTm = None if 'editTm' not in s else s['editTm']
15 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/RestrictedKeyword.py:
--------------------------------------------------------------------------------
1 | import json
2 | class RestrictedKeyword:
3 | def __init__(self, json_def):
4 | if type(json_def) is str:
5 | json_def = json.loads(json_def)
6 | s = json_def
7 |
8 | self.delFlag = None if 'delFlag' not in s else s['delFlag']
9 | self.keyword = None if 'keyword' not in s else s['keyword']
10 | self.nccAdgroupId = None if 'nccAdgroupId' not in s else s['nccAdgroupId']
11 | self.nccAdgroupRestrictKwdId = None if 'nccAdgroupRestrictKwdId' not in s else s['nccAdgroupRestrictKwdId']
12 | self.regTm = None if 'regTm' not in s else s['regTm']
13 | self.type = None if 'type' not in s else s['type']
--------------------------------------------------------------------------------
/powernad/Object/Stat/StatObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | from ..Stat.sub.StatDataObject import StatDataObject
3 | from ..Stat.sub.SummaryObject import SummaryObject
4 | class StatObject:
5 |
6 | def __init__(self, json_def):
7 | if type(json_def) is str:
8 | json_def = json.loads(json_def)
9 | s = json_def
10 |
11 | self.data = None if 'data' not in s else self.match_data(s['data']) #list
12 | self.summary = None if 'data' not in s else SummaryObject(s['data'])
13 |
14 | def match_data(self, s):
15 |
16 | stat_list = []
17 | for arr in s:
18 | stat = StatDataObject(arr)
19 | stat_list.append(stat)
20 |
21 | return stat_list
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/sub/target.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class target:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 | self.delFlag = None if 'delFlag' not in s else s['delFlag']
9 | self.editTm = None if 'editTm' not in s else s['editTm']
10 | self.nccTargetId = None if 'nccTargetId' not in s else s['nccTargetId']
11 | self.ownerId = None if 'ownerId' not in s else s['ownerId']
12 | self.regTm = None if 'regTm' not in s else s['regTm']
13 | self.target = None if 'target' not in s else s['target']
14 | self.targetTp = None if 'targetTp' not in s else s['targetTp']
15 |
--------------------------------------------------------------------------------
/powernad/Object/StatReport/StatReportObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class StatReportObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.downloadUrl = None if 'downloadUrl' not in s else s['downloadUrl']
10 | self.loginId = None if 'loginId' not in s else s['loginId']
11 | self.regTm = None if 'regTm' not in s else s['regTm']
12 | self.reportJobId = None if 'reportJobId' not in s else s['reportJobId']
13 | self.reportTp = None if 'reportTp' not in s else s['reportTp']
14 | self.statDt = None if 'statDt' not in s else s['statDt']
15 | self.status = None if 'status' not in s else s['status']
16 | self.updateTm = None if 'updateTm' not in s else s['updateTm']
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | from setuptools import setup, find_packages
4 | from codecs import open
5 | from os import path
6 | import os
7 |
8 | setup(
9 | name = 'powernad',
10 | version = '0.8.0',
11 | packages=find_packages(),
12 | author = 'devkingsejong',
13 | author_email = 'devkingsejong@gmail.com',
14 | classifiers=[
15 | 'Development Status :: 2 - Pre-Alpha',
16 | 'Topic :: Software Development :: Libraries',
17 | 'Programming Language :: Python :: 3',
18 | 'Programming Language :: Python :: 3.4',
19 | 'Programming Language :: Python :: 3.5',
20 | 'Programming Language :: Python :: 3.6',
21 | ],
22 | keywords='Easy to use naver ad to python',
23 | url = 'https://github.com/devkingsejong/python-PowerNad',
24 | description = 'Easy to use naver ad to python',
25 | )
--------------------------------------------------------------------------------
/powernad/API/ManagedCustomerLink.py:
--------------------------------------------------------------------------------
1 | from powernad.Connector.restapi import RestApi
2 | from powernad.Object.ManagedCustomerLink.ManagedCustomerLinkObject import ManagedCustomerLinkObject
3 |
4 | from typing import List
5 | ManagedCustomerLinkObjectList = List[ManagedCustomerLinkObject]
6 |
7 |
8 | class ManagedCustomerLink:
9 |
10 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
11 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
12 |
13 | def get_managed_customer_link_list(self, rel_type: str = None) -> ManagedCustomerLinkObjectList:
14 | query = {'type': rel_type}
15 | result = self.r.get('/customer-links', query)
16 | customer_list = []
17 | for arr in result:
18 | customer = ManagedCustomerLinkObject(arr)
19 | customer_list.append(customer)
20 |
21 | return customer_list
22 |
--------------------------------------------------------------------------------
/powernad/Object/Stat/sub/StatDataObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class StatDataObject:
4 |
5 | def __init__(self, json_def):
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.avgRnk = None if 'avgRnk' not in s else s['avgRnk']
11 | self.ccnt = None if 'ccnt' not in s else s['ccnt']
12 | self.clkCnt = None if 'clkCnt' not in s else s['clkCnt']
13 | self.cpc = None if 'cpc' not in s else s['cpc']
14 | self.ctr = None if 'ctr' not in s else s['ctr']
15 | self.dateEnd = None if 'dateEnd' not in s else s['dateEnd']
16 | self.dateStart = None if 'dateStart' not in s else s['dateStart']
17 | self.drtCrto = None if 'drtCrto' not in s else s['drtCrto']
18 | self.impCnt = None if 'impCnt' not in s else s['impCnt']
19 | self.salesAmt = None if 'salesAmt' not in s else s['salesAmt']
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/RequestObject/CreateAdgroupObject.py:
--------------------------------------------------------------------------------
1 | from ..sub.target import target
2 |
3 | class CreateAdgroupObject:
4 | def __init__(self, ncc_campaign_id, name, pc_channel_id, mobile_channel_id):
5 | self.adgroupAttrJson = {'contentsType' : 'PRODUCT'}
6 | self.bidAmt = None
7 | self.budgetLock = None
8 | self.contentsNetworkBidAmt = None
9 | self.dailyBudget = None
10 | self.keywordPlusWeight = None
11 | self.mobileChannelId = mobile_channel_id
12 | self.mobileNetworkBidWeight = None
13 | self.name = name
14 | self.nccCampaignId = ncc_campaign_id
15 | self.pcChannelId = pc_channel_id
16 | self.pcNetworkBidWeight = None
17 | self.targets = None #target object
18 | self.useCntsNetworkBidAmt = None
19 | self.useDailyBudget = None
20 | self.useKeywordPlus = None
21 | self.userLock = None
22 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/RequestObject/UpdateEntireAdgroupObject.py:
--------------------------------------------------------------------------------
1 | class UpdateEntireAdgroupObject:
2 | def __init__(self, bidAmt, contentsNetworkBidAmt, dailyBudget, keywordPlusWeight, mobileNetworkBidWeight, nccAdgroupId,
3 | pcNetworkBidWeight, useCntsNetworkBidAmt, useDailyBudget, useKeywordPlus, userLock):
4 | self.bidAmt = bidAmt
5 | self.budgetLock = None
6 | self.contentsNetworkBidAmt = contentsNetworkBidAmt
7 | self.dailyBudget = dailyBudget
8 | self.keywordPlusWeight = keywordPlusWeight
9 | self.mobileChannelId = None
10 | self.mobileNetworkBidWeight = mobileNetworkBidWeight
11 | self.name = None
12 | self.nccAdgroupId = nccAdgroupId
13 | self.nccCampaignId = None
14 | self.pcNetworkBidWeight = pcNetworkBidWeight
15 | #self.targts = None
16 | self.useCntsNetworkBidAmt = useCntsNetworkBidAmt
17 | self.useDailyBudget = useDailyBudget
18 | self.useKeywordPlus = useKeywordPlus
19 | self.userLock = userLock
--------------------------------------------------------------------------------
/powernad/API/Bizmoney.py:
--------------------------------------------------------------------------------
1 | from powernad.Connector.restapi import RestApi
2 | from powernad.Object.Bizmoney.BizmoneyObject import BizmoneyObject
3 | from powernad.Object.Bizmoney.BizmoneyCostObject import BizmoneyCostObject
4 | from typing import List
5 |
6 | BizmoneyCostObjectList = List[BizmoneyCostObject]
7 |
8 |
9 | class Bizmoney:
10 |
11 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
12 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
13 |
14 | def get_biz_money(self) -> BizmoneyObject:
15 | result = self.r.get('/billing/bizmoney')
16 | result = BizmoneyObject(result)
17 |
18 | return result
19 |
20 | def get_biz_money_cost(self, statDt: str) -> BizmoneyCostObjectList:
21 | result = self.r.get('/billing/bizmoney/cost/' + statDt)
22 | cost_list = []
23 | for arr in result:
24 | cost = BizmoneyCostObject(arr)
25 | cost_list.append(cost)
26 |
27 | return cost_list
28 |
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/sub/ManagedKeywordInfoObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class ManagedKeywordInfoObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.PCPLMaxDepth = None if 'PCPLMaxDepth' not in s else s['PCPLMaxDepth']
10 | self.editTm = None if 'editTm' not in s else s['editTm']
11 | self.isAdult = None if 'isAdult' not in s else s['isAdult']
12 | self.isBrand = None if 'isBrand' not in s else s['isBrand']
13 | self.isLowSearchVolume = None if 'isLowSearchVolume' not in s else s['isLowSearchVolume']
14 | self.isRestricted = None if 'isRestricted' not in s else s['isRestricted']
15 | self.isSeason = None if 'isSeason' not in s else s['isSeason']
16 | self.isSellProhibit = None if 'isSellProhibit' not in s else s['isSellProhibit']
17 | self.keyword = None if 'keyword' not in s else s['keyword']
18 | self.regTm = None if 'regTm' not in s else s['regTm']
--------------------------------------------------------------------------------
/powernad/Object/Bizmoney/BizmoneyCostObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | class BizmoneyCostObject:
3 |
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.adjustedNonRefundableAmt = None if 'adjustedNonRefundableAmt' not in s else s['adjustedNonRefundableAmt']
10 | self.adjustedRefundableAmt = None if 'adjustedRefundableAmt' not in s else s['adjustedRefundableAmt']
11 | self.customerId = None if 'customerId' not in s else s['customerId']
12 | self.date = None if 'date' not in s else s['date']
13 | self.device = None if 'device' not in s else s['device']
14 | self.networkType = None if 'networkType' not in s else s['networkType']
15 | self.nonRefundableAmt = None if 'nonRefundableAmt' not in s else s['nonRefundableAmt']
16 | self.productCode = None if 'productCode' not in s else s['productCode']
17 | self.refundableAmt = None if 'refundableAmt' not in s else s['refundableAmt']
--------------------------------------------------------------------------------
/powernad/Object/MasterReport/MasterReportObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class MasterReportObject:
4 | def __init__(self, json_def):
5 |
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.clientCustomerId = None if 'clientCustomerId' not in s else s['clientCustomerId']
11 | self.downloadUrl = None if 'downloadUrl' not in s else s['downloadUrl']
12 | self.fromTime = None if 'fromTime' not in s else s['fromTime']
13 | self.id = None if 'id' not in s else s['id']
14 | self.item = None if 'item' not in s else s['item']
15 | self.managerCustomerId = None if 'managerCustomerId' not in s else s['managerCustomerId']
16 | self.managerLoginId = None if 'managerLoginId' not in s else s['managerLoginId']
17 | self.registTime = None if 'registTime' not in s else s['registTime']
18 | self.status = None if 'status' not in s else s['status']
19 | self.updateTime = None if 'updateTime' not in s else s['updateTime']
--------------------------------------------------------------------------------
/powernad/Object/RelKwdStat/RelKwdStatObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class RelKwdStatObject:
4 | def __init__(self, json_def):
5 |
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.relKeyword = None if 'relKeyword' not in s else s['relKeyword']
11 | self.monthlyPcQcCnt = None if 'monthlyPcQcCnt' not in s else s['monthlyPcQcCnt']
12 | self.monthlyMobileQcCnt = None if 'monthlyMobileQcCnt' not in s else s['monthlyMobileQcCnt']
13 | self.monthlyAvePcClkCnt = None if 'monthlyAvePcClkCnt' not in s else s['monthlyAvePcClkCnt']
14 | self.monthlyAveMobileClkCnt = None if 'monthlyAveMobileClkCnt' not in s else s['monthlyAveMobileClkCnt']
15 | self.monthlyAvePcCtr = None if 'monthlyAvePcCtr' not in s else s['monthlyAvePcCtr']
16 | self.monthlyAveMobileCtr = None if 'monthlyAveMobileCtr' not in s else s['monthlyAveMobileCtr']
17 | self.plAvgDepth = None if 'plAvgDepth' not in s else s['plAvgDepth']
18 | self.compIdx = None if 'compIdx' not in s else s['compIdx']
--------------------------------------------------------------------------------
/powernad/Object/Ad/sub/AdFieldObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | class AdFieldObject:
3 | def __init__(self, json_def = None):
4 | if type(json_def) is str:
5 | json_def = json.loads(json_def)
6 | s = json_def
7 |
8 | self.pc_display = None if 'pc' not in s else self.pc_display_easy(s['pc'])
9 | self.pc_final = None if 'pc' not in s else self.pc_final_easy(s['pc'])
10 | self.mobile_display = None if 'mobile' not in s else self.mobile_display_easy(s['mobile'])
11 | self.mobile_final = None if 'mobile' not in s else self.mobile_final_easy(s['mobile'])
12 | self.headline = None if 'headline' not in s else s['headline']
13 | self.description = None if 'description' not in s else s['description']
14 |
15 |
16 | def pc_final_easy(self, pc):
17 | return pc['final']
18 |
19 | def pc_display_easy(self, pc):
20 | return pc['display']
21 |
22 | def mobile_final_easy(self, mobile):
23 | return mobile['final']
24 |
25 | def mobile_display_easy(self, mobile):
26 | return mobile['display']
27 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/RequestObject/UpdateAdgroupObject.py:
--------------------------------------------------------------------------------
1 | class UpdateAdgroupObject:
2 | def __init__(self, bidAmt = None, userLock = None, useKeywordPlus = None, networkBidWeight = None,
3 | targetLocation = None, targetTime = None, targetMedia = None):
4 | self.bidAmt = bidAmt
5 | self.userLock = userLock
6 | self.useKeywordPlus = useKeywordPlus
7 | self.useCntsNetworkBidAmt = networkBidWeight
8 | #self.target = self.make_target_obj(targetLocation, targetTime, targetLocation)
9 | self.targetLoaction = targetLocation
10 | self.targetTime = targetTime
11 | self.targetMedia = targetMedia
12 |
13 |
14 | def make_target_obj(self,nccTargetId, ownerId, targetLocation, targetTime, targetLoaction):
15 | target_obj = []
16 | if targetLoaction != None:
17 | target_obj.append(targetLoaction)
18 | if targetTime != None:
19 | target_obj.append(targetTime)
20 | if targetLoaction != None:
21 | targetLoaction.append(targetLoaction)
22 |
23 | return targetLoaction
24 |
25 |
--------------------------------------------------------------------------------
/powernad/API/RelKwdStat.py:
--------------------------------------------------------------------------------
1 | from powernad.Connector.restapi import RestApi
2 | from powernad.Object.RelKwdStat.RelKwdStatObject import RelKwdStatObject
3 | from typing import List
4 | RelKwdStatObjectList = List[RelKwdStatObject]
5 |
6 |
7 | class RelKwdStat:
8 |
9 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
10 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
11 |
12 | def get_rel_kwd_stat_list(self, siteId: str = None, biztpId: int = None, hintKeywords: str = None, event: int = None,
13 | month: int = None, showDetail: int = None) -> RelKwdStatObjectList:
14 |
15 | query = {'siteId': siteId, 'biztpId': biztpId, 'hintKeywords': hintKeywords,
16 | 'event': event, 'month': month, 'showDetail': showDetail}
17 | result = self.r.get('/keywordstool', query)
18 | result = result['keywordList']
19 | relstat_list = []
20 |
21 | for arr in result:
22 | relstat = RelKwdStatObject(arr)
23 | relstat_list.append(relstat)
24 |
25 | return relstat_list
26 |
--------------------------------------------------------------------------------
/powernad/Object/Ad/AdObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | from ..Ad.sub.AdFieldObject import AdFieldObject
3 | class AdObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.ad = None if 'ad' not in s else AdFieldObject(s['ad'])
10 | self.adattr = None if 'adattr' not in s else s['adattr']
11 | self.customerId = None if 'customerId' not in s else s['customerId']
12 | self.editTm = None if 'editTm' not in s else s['editTm']
13 | self.inspectRequestMsg = None if 'inspectRequestMsg' not in s else s['inspectRequestMsg']
14 | self.inspectStatus = None if 'inspectStatus' not in s else s['inspectStatus']
15 | self.nccAdId = None if 'nccAdId' not in s else s['nccAdId']
16 | self.nccAdgroupId = None if 'nccAdgroupId' not in s else s['nccAdgroupId']
17 | self.regTm = None if 'regTm' not in s else s['regTm']
18 | self.status = None if 'status' not in s else s['status']
19 | self.statusReason = None if 'statusReason' not in s else s['statusReason']
20 | self.type = None if 'type' not in s else s['type']
21 | self.userLock = None if 'userLock' not in s else s['userLock']
--------------------------------------------------------------------------------
/powernad/Object/AdExtension/AdExtensionObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class AdExtensionObject:
4 |
5 | def __init__(self, json_def):
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 |
9 | s = json_def
10 |
11 | self.customerId = None if 'customerId' not in s else s['customerId']
12 | self.delFlag = None if 'delFlag' not in s else s['delFlag']
13 | self.editTm = None if 'editTm' not in s else s['editTm']
14 | self.inspectStatus = None if 'inspectStatus' not in s else s['inspectStatus']
15 | self.mobileChannelId = None if 'mobileChannelId' not in s else s['mobileChannelId']
16 | self.nccAdExtensionId = None if 'nccAdExtensionId' not in s else s['nccAdExtensionId']
17 | self.ownerId = None if 'ownerId' not in s else s['ownerId']
18 | self.pcChannelId = None if 'pcChannelId' not in s else s['pcChannelId']
19 | self.regTm = None if 'regTm' not in s else s['regTm']
20 | self.status = None if 'status' not in s else s['status']
21 | self.statusReason = None if 'statusReason' not in s else s['statusReason']
22 | self.type = None if 'type' not in s else s['type']
23 | self.userLock = None if 'userLock' not in s else s['userLock']
--------------------------------------------------------------------------------
/powernad/Object/AdKeyword/AdKeywordObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class AdKeywordObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.bidAmt = None if 'bidAmt' not in s else s['bidAmt']
10 | self.customerId = None if 'customerId' not in s else s['customerId']
11 | self.editTm = None if 'editTm' not in s else s['editTm']
12 | self.inspectStatus = None if 'inspectStatus' not in s else s['inspectStatus']
13 | self.keyword = None if 'keyword' not in s else s['keyword']
14 | self.nccAdgroupId = None if 'nccAdgroupId' not in s else s['nccAdgroupId']
15 | self.nccCampaignId = None if 'nccCampaignId' not in s else s['nccCampaignId']
16 | self.nccKeywordId = None if 'nccKeywordId' not in s else s['nccKeywordId']
17 | self.nccQi = None if 'nccQi' not in s else s['nccQi']
18 | self.regTm = None if 'regTm' not in s else s['regTm']
19 | self.status = None if 'status' not in s else s['status']
20 | self.statusReason = None if 'statusReason' not in s else s['statusReason']
21 | self.useGroupBidAmt = None if 'useGroupBidAmt' not in s else s['useGroupBidAmt']
22 | self.userLock = None if 'userLock' not in s else s['userLock']
23 |
24 |
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/sub/BusinessInfo.py:
--------------------------------------------------------------------------------
1 | import json
2 | class BusinessInfo:
3 | def __init__(self, json_def):
4 | if type(json_def) is str:
5 | json_def = json.loads(json_def)
6 | s = json_def
7 |
8 | self.isMobileNaverLogin = None if 'isMobileNaverLogin' not in s else s['isMobileNaverLogin']
9 | self.isMobileNaverPay = None if 'isMobileNaverPay' not in s else s['isMobileNaverPay']
10 | self.isMobileNaverTalkTalk = None if 'isMobileNaverTalkTalk' not in s else s['isMobileNaverTalkTalk']
11 | self.isNaverLogin = None if 'isNaverLogin' not in s else s['isNaverLogin']
12 | self.isNaverPay = None if 'isNaverPay' not in s else s['isNaverPay']
13 | self.isNaverTalkTalk = None if 'isNaverTalkTalk' not in s else s['isNaverTalkTalk']
14 | self.isStoreFarm = None if 'isStoreFarm' not in s else s['isStoreFarm']
15 | self.mobileCertStatus = None if 'mobileCertStatus' not in s else s['mobileCertStatus']
16 | self.naAccountId = None if 'naAccountId' not in s else s['naAccountId']
17 | self.naAccountType = None if 'naAccountType' not in s else s['naAccountType']
18 | self.originalPath = None if 'originalPath' not in s else s['originalPath']
19 | self.site = None if 'site' not in s else s['site']
20 | self.thumbnailPath = None if 'thumbnailPath' not in s else s['thumbnailPath']
21 | self.useNaverPayNaScript = None if 'useNaverPayNaScript' not in s else s['useNaverPayNaScript']
22 | self.useSaNaScript = None if 'useSaNaScript' not in s else s['useSaNaScript']
23 | self.useStoreFarmNaScript = None if 'useStoreFarmNaScript' not in s else s['useStoreFarmNaScript']
24 |
25 |
--------------------------------------------------------------------------------
/powernad/API/Stat.py:
--------------------------------------------------------------------------------
1 | from powernad.Connector.restapi import RestApi
2 | from powernad.Object.Stat.StatObject import StatObject
3 | from powernad.Object.Stat.StatTypeObject import StatTypeObject
4 | from typing import List
5 |
6 | StatIdList = List[str]
7 |
8 |
9 | class Stat:
10 |
11 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
12 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
13 |
14 | def get_stat_by_id(self, id: str, fields: str, timeRange: str, datePreset: str = None, timeIncrement: str = None,
15 | breakdown: str = None) -> StatObject:
16 | query = {'id': id, 'fields': fields, 'timeRange': timeRange, 'datePreset': datePreset,
17 | 'timeIncrement': timeIncrement, 'breakdown': breakdown}
18 | result = self.r.get('/stats', query)
19 | result = StatObject(result)
20 |
21 | return result
22 |
23 | def get_stat_by_ids(self, ids: StatIdList, fields: str, timeRange: str, datePreset: str= None,
24 | timeIncrement: str = None, breakdown: str = None) -> StatObject:
25 |
26 | query = {'ids': ids, 'fields': fields, 'timeRange': timeRange, 'dataPreset': datePreset,
27 | 'timeIncrement': timeIncrement, 'breakdown': breakdown}
28 | result = self.r.get('/stats', query)
29 | result = StatObject(result)
30 |
31 | return result
32 |
33 | def get_stat_by_type(self, id: str, statType: str) -> StatTypeObject:
34 | query = {'id' :id, 'statType' : statType}
35 | result = self.r.get('/stats', query)
36 | result = StatTypeObject(result)
37 | return result
--------------------------------------------------------------------------------
/powernad/Object/BusinessChannel/BusinessChannelObject.py:
--------------------------------------------------------------------------------
1 | import json
2 | from ..BusinessChannel.sub.BusinessInfo import BusinessInfo
3 | class BusinessChannelObject:
4 | def __init__(self, json_def):
5 | if type(json_def) is str:
6 | json_def = json.loads(json_def)
7 | s = json_def
8 |
9 | self.adultStatus = None if 'adultStatus' not in s else s['adultStatus']
10 | self.blackStatus = None if 'blackStatus' not in s else s['blackStatus']
11 | self.businessInfo = None if 'businessInfo' not in s else BusinessInfo(s['businessInfo'])
12 | self.channelKey = None if 'adultStatus' not in s else s['adultStatus']
13 | self.channelTp = None if 'adultStatus' not in s else s['adultStatus']
14 | self.customerId = None if 'customerId' not in s else s['customerId']
15 | self.delFlag = None if 'delFlag' not in s else s['delFlag']
16 | self.editTm = None if 'editTm' not in s else s['editTm']
17 | self.enabled = None if 'enabled' not in s else s['enabled']
18 | self.firstChargeTm = None if 'firstChargeTm' not in s else s['firstChargeTm']
19 | self.inspectTm = None if 'inspectTm' not in s else s['inspectTm']
20 | self.mobileInspectStatus = None if 'mobileInspectStatus' not in s else s['mobileInspectStatus']
21 | self.name = None if 'name' not in s else s['name']
22 | self.nccBusinessChannelId = None if 'nccBusinessChannelId' not in s else s['nccBusinessChannelId']
23 | self.pcInspectStatus = None if 'pcInspectStatus' not in s else s['pcInspectStatus']
24 | self.regTm = None if 'regTm' not in s else s['regTm']
25 | self.status = None if 'status' not in s else s['status']
26 | self.statusReason = None if 'statusReason' not in s else s['statusReason']
27 |
--------------------------------------------------------------------------------
/powernad/API/StatReport.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.StatReport.StatReportObject import StatReportObject
5 | from powernad.Object.StatReport.RequestObject.CreateStatReportObject import CreateStatReportObject
6 | from powernad.Common.CommonFunctions import CommonFunctions
7 | from typing import List
8 | StatReportObjectList = List[StatReportObject]
9 |
10 |
11 | class StatReport: #대용량 보고서
12 |
13 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
14 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
15 |
16 | def get_stat_report_list(self) -> StatReportObjectList:
17 | result = self.r.get('/stat-reports')
18 | stat_list = []
19 | for arr in result:
20 | stat = StatReportObject(arr)
21 | stat_list.append(stat)
22 |
23 | return stat_list
24 |
25 | def get_stat_report(self, reportJobId: str) -> StatReportObject:
26 | result = self.r.get('/stat-reports/' + reportJobId)
27 | result = StatReportObject(result)
28 |
29 | return result
30 |
31 | def create_stat_report(self, CreateStatReportObject: CreateStatReportObject) -> StatReportObject:
32 |
33 | data = jsonpickle.encode(CreateStatReportObject, unpicklable=False)
34 | data = json.loads(data)
35 | data = CommonFunctions.delete_null_dict_items(data)
36 | data_str = json.dumps(data)
37 |
38 | result = self.r.post('/stat-reports', data_str)
39 | result = StatReportObject(result)
40 |
41 | return result
42 |
43 | def delete_stat_reports(self, reportJobId: str):
44 | self.r.delete('/stat-reports/'+ reportJobId)
45 | return True
46 |
--------------------------------------------------------------------------------
/powernad/API/Target.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.Target.TargetObject import TargetObject
5 | from powernad.Object.Target.RequestObject.UpdateTargetObject import UpdateTargetObject
6 | from powernad.Common.CommonFunctions import CommonFunctions
7 | from typing import List
8 | TargetObjectList = List[TargetObject]
9 | TypesList = List[str]
10 | OwnerIdList = List[str]
11 |
12 |
13 | class Target:
14 |
15 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
16 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
17 |
18 | def get_target_list(self, ownerId: str, types: TypesList) -> TargetObjectList:
19 | result = self.r.get('/ncc/targets', {'ownerId': ownerId, 'types': types})
20 |
21 | target_list = []
22 | for arr in result:
23 | target = TargetObject(arr)
24 | target_list.append(target)
25 |
26 | return target_list
27 |
28 | def get_target_lists(self, ownerId: OwnerIdList, types: TypesList) -> TargetObjectList:
29 | result = self.r.get('/ncc/targets', {'ownerId': ownerId, 'types': types})
30 |
31 | target_list = []
32 | for arr in result:
33 | target = TargetObject(arr)
34 | target_list.append(target)
35 |
36 | return target_list
37 |
38 | def update_target(self, targetId: str, UpdateTargetObject: UpdateTargetObject) -> TargetObject:
39 |
40 | data = jsonpickle.encode(UpdateTargetObject, unpicklable=False)
41 | data = json.loads(data)
42 | data = CommonFunctions.delete_null_dict_items(data)
43 | data_str = json.dumps(data)
44 |
45 | result = self.r.put('/ncc/targets/'+targetId, data_str)
46 |
47 | result = TargetObject(result)
48 | return result
49 |
--------------------------------------------------------------------------------
/powernad/Object/Campaign/CampaignObject.py:
--------------------------------------------------------------------------------
1 | # pylint: disable=C0103
2 |
3 | import json
4 |
5 | class CampaignObject():
6 |
7 | def __init__(self, json_def):
8 | if type(json_def) is str:
9 | json_def = json.loads(json_def)
10 |
11 | s = json_def
12 |
13 | self.campaignTp = None if 'campaignTp' not in s else s['campaignTp']
14 | self.customerId = None if 'customerId' not in s else s['customerId']
15 | self.dailyBudget = None if 'dailyBudget' not in s else s['dailyBudget']
16 | self.delFlag = None if 'delFlag' not in s else s['delFlag']
17 | self.deliveryMethod = None if 'deliveryMethod' not in s else s['deliveryMethod']
18 | self.editTm = None if 'editTm' not in s else s['editTm']
19 | self.expectCost = None if 'expectCost' not in s else s['expectCost']
20 | self.migType = None if 'migType' not in s else s['migType']
21 | self.name = None if 'name' not in s else s['name']
22 | self.nccCampaignId = None if 'nccCampaignId' not in s else s['nccCampaignId']
23 | self.periodEndDt = None if 'periodEndDt' not in s else s['periodEndDt']
24 | self.periodStartDt = None if 'periodStartDt' not in s else s['periodStartDt']
25 | self.regTm = None if 'regTm' not in s else s['regTm']
26 | self.status = None if 'status' not in s else s['status']
27 | self.statusReason = None if 'statusReason' not in s else s['statusReason']
28 | self.trackingMode = None if 'trackingMode' not in s else s['trackingMode']
29 | self.trackingUrl = None if 'trackingUrl' not in s else s['trackingUrl']
30 | self.useDailyBudget = None if 'useDailyBudget' not in s else s['useDailyBudget']
31 | self.usePeriod = None if 'usePeriod' not in s else s['usePeriod']
32 | self.userLock = None if 'userLock' not in s else s['userLock']
33 |
34 |
--------------------------------------------------------------------------------
/powernad/Object/ManagedCustomerLink/ManagedCustomerLinkObject.py:
--------------------------------------------------------------------------------
1 | import json
2 |
3 | class ManagedCustomerLinkObject:
4 |
5 | def __init__(self, json_def):
6 | if type(json_def) is str:
7 | json_def = json.loads(json_def)
8 | s = json_def
9 |
10 | self.clientCustomerDelFlag = None if 'clientCustomerDelFlag' not in s else s['clientCustomerDelFlag']
11 | self.clientCustomerId = None if 'clientCustomerId' not in s else s['clientCustomerId']
12 | self.clientEnable = None if 'clientEnable' not in s else s['clientEnable']
13 | self.clientLoginId = None if 'clientLoginId' not in s else s['clientLoginId']
14 | self.clientPenaltySt = None if 'clientPenaltySt' not in s else s['clientPenaltySt']
15 | self.customerLinkId = None if 'customerLinkId' not in s else s['customerLinkId']
16 | self.description = None if 'description' not in s else s['description']
17 | self.editTm = None if 'editTm' not in s else s['editTm']
18 | self.isProxyAgency = None if 'isProxyAgency' not in s else s['isProxyAgency']
19 | self.linkStatus = None if 'linkStatus' not in s else s['linkStatus']
20 | self.managerCompanyName = None if 'managerCompanyName' not in s else s['managerCompanyName']
21 | self.managerCustomerDelFlag = None if 'managerCustomerDelFlag' not in s else s['managerCustomerDelFlag']
22 | self.managerCustomerId = None if 'managerCustomerId' not in s else s['managerCustomerId']
23 | self.managerEnable = None if 'managerEnable' not in s else s['managerEnable']
24 | self.managerName = None if 'managerName' not in s else s['managerName']
25 | self.managerPenaltySt = None if 'managerPenaltySt' not in s else s['managerPenaltySt']
26 | self.regTm = None if 'regTm' not in s else s['regTm']
27 | self.roleId = None if 'roleId' not in s else s['roleId']
--------------------------------------------------------------------------------
/powernad/API/MasterReport.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.MasterReport.MasterReportObject import MasterReportObject
5 | from powernad.Object.MasterReport.RequestObject.CreateMasterReportObject import CreateMasterReportObject
6 | from powernad.Common.CommonFunctions import CommonFunctions
7 | from typing import List
8 |
9 | MasterReportObjectList = List[MasterReportObject]
10 |
11 |
12 | class MasterReport: #광고정보일괄다운로드탭
13 |
14 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
15 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
16 |
17 | def get_master_report_list(self) -> MasterReportObjectList:
18 | result = self.r.get('/master-reports')
19 |
20 | mreport_list = []
21 | for arr in result:
22 | mreport = MasterReportObject(arr)
23 | mreport_list.append(mreport)
24 |
25 | return mreport_list
26 |
27 | def get_master_report_by_id(self, id: str) -> MasterReportObject:
28 | result = self.r.get('/master-reports/' + id)
29 |
30 | result = MasterReportObject(result)
31 | return result
32 |
33 | def create_master_report(self, CreateMasterReportObject: CreateMasterReportObject) -> MasterReportObject:
34 | data = jsonpickle.encode(CreateMasterReportObject, unpicklable=False)
35 | data = json.loads(data)
36 | data = CommonFunctions.delete_null_dict_items(data)
37 | data_str = json.dumps(data)
38 |
39 | result = self.r.post('/master-reports', data_str)
40 | result = MasterReportObject(result)
41 |
42 | return result
43 |
44 | def delete_master_report_all(self):
45 | self.r.delete('/master-reports')
46 | return True
47 |
48 | def delete_master_report_by_id(self, id: str):
49 | self.r.delete('/master-reports', {'id': id})
50 | return True
51 |
--------------------------------------------------------------------------------
/powernad/API/Label.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.Label.LabelObject import LabelObject
5 | from powernad.Object.Label.LabelRefObject import LabelRefObject
6 | from powernad.Object.Label.RequestObject.UpdateLabelObject import UpdateLabelObject
7 | from powernad.Object.Label.RequestObject.UpdateLabelRefObject import UpdateLabelRefObject
8 | from powernad.Common.CommonFunctions import CommonFunctions
9 | from typing import List
10 | LabelRefObjectList = List[LabelRefObject]
11 | LabelObjectList = List[LabelObject]
12 |
13 |
14 | class Label: #즐겨찾기
15 |
16 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
17 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
18 |
19 | def get_label_list(self) -> LabelObjectList:
20 | result = self.r.get('/ncc/labels')
21 |
22 | label_list = []
23 | for arr in result:
24 | label = LabelObject(arr)
25 | label_list.append(label)
26 |
27 | return label_list
28 |
29 | def update_label(self, UpdateLabelObject: UpdateLabelObject) -> LabelObject:
30 | data = jsonpickle.encode(UpdateLabelObject, unpicklable=False)
31 | data = json.loads(data)
32 | data = CommonFunctions.delete_null_dict_items(data)
33 | data_str = json.dumps(data)
34 |
35 | result = self.r.put('/ncc/labels', data_str)
36 |
37 | result = LabelObject(result)
38 |
39 | return result
40 |
41 | def update_label_ref(self, UpdateLabelRefObject: UpdateLabelRefObject) -> LabelRefObjectList:
42 | data = jsonpickle.encode(UpdateLabelRefObject, unpicklable=False)
43 | data = json.loads(data)
44 | data = CommonFunctions.delete_null_dict_items(data)
45 | data = [data]
46 | data_str = json.dumps(data)
47 |
48 | result = self.r.put('/ncc/label-refs/', data_str)
49 |
50 | labelref_list = []
51 | for arr in result:
52 | labelref = LabelRefObject(arr)
53 | labelref_list.append(labelref)
54 |
55 | return labelref_list
56 |
--------------------------------------------------------------------------------
/powernad/API/IpExclusion.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.IpExclusion.IpExclusionObject import IpExclusionObject
5 | from powernad.Object.IpExclusion.RequestObject.CreateIpExclusionObject import CreateIpExclusionObject
6 | from powernad.Object.IpExclusion.RequestObject.UpdateIpExclusionObject import UpdateIpExclusionObject
7 | from powernad.Common.CommonFunctions import CommonFunctions
8 | from typing import List
9 |
10 | ExclusionIdList = List[str]
11 |
12 |
13 | class IpExclusion:
14 |
15 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
16 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
17 |
18 | def get_ip_exclusion(self):
19 | result = self.r.get('/tool/ip-exclusions')
20 |
21 | ip_exclusion_list = []
22 | for arr in result:
23 | ipex = IpExclusionObject(arr)
24 | ip_exclusion_list.append(ipex)
25 |
26 | return ip_exclusion_list
27 |
28 | def create_ip_exclusion(self, CreateIpExclusionObject: CreateIpExclusionObject) -> IpExclusionObject:
29 | data = jsonpickle.encode(CreateIpExclusionObject, unpicklable=False)
30 | data = json.loads(data)
31 | data = CommonFunctions.delete_null_dict_items(data)
32 | data_str = json.dumps(data)
33 |
34 | result = self.r.post('/tool/ip-exclusions', data_str)
35 | result = IpExclusionObject(result)
36 |
37 | return result
38 |
39 | def update_ip_exclusion(self, UpdateIpExclusionObject: UpdateIpExclusionObject) -> UpdateIpExclusionObject:
40 | data = jsonpickle.encode(UpdateIpExclusionObject, unpicklable=False)
41 | data = json.loads(data)
42 | data = CommonFunctions.delete_null_dict_items(data)
43 | data_str = json.dumps(data)
44 |
45 | result = self.r.put('/tool/ip-exclusions', data_str)
46 | result = IpExclusionObject(result)
47 |
48 | return result
49 |
50 | def delete_ip_exclusion(self, id: str):
51 | result = self.r.delete('/tool/ip-exclusions/' + id)
52 | result = IpExclusionObject(result)
53 |
54 | return result
55 |
56 | def delete_ip_exclusion_many(self, id_array: ExclusionIdList):
57 | query = {'ids' : id_array}
58 | self.r.delete('/tool/ip-exclusions', query)
59 |
60 | return True
61 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | # Created by https://www.gitignore.io/api/python,visualstudiocode
3 | # Edit at https://www.gitignore.io/?templates=python,visualstudiocode
4 |
5 | ### Python ###
6 | # Byte-compiled / optimized / DLL files
7 | __pycache__/
8 | *.py[cod]
9 | *$py.class
10 |
11 | # C extensions
12 | *.so
13 |
14 | # Distribution / packaging
15 | .Python
16 | build/
17 | develop-eggs/
18 | dist/
19 | downloads/
20 | eggs/
21 | .eggs/
22 | lib/
23 | lib64/
24 | parts/
25 | sdist/
26 | var/
27 | wheels/
28 | *.egg-info/
29 | .installed.cfg
30 | *.egg
31 | MANIFEST
32 |
33 | # PyInstaller
34 | # Usually these files are written by a python script from a template
35 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
36 | *.manifest
37 | *.spec
38 |
39 | # Installer logs
40 | pip-log.txt
41 | pip-delete-this-directory.txt
42 |
43 | # Unit test / coverage reports
44 | htmlcov/
45 | .tox/
46 | .nox/
47 | .coverage
48 | .coverage.*
49 | .cache
50 | nosetests.xml
51 | coverage.xml
52 | *.cover
53 | .hypothesis/
54 | .pytest_cache/
55 |
56 | # Translations
57 | *.mo
58 | *.pot
59 |
60 | # Django stuff:
61 | *.log
62 | local_settings.py
63 | db.sqlite3
64 |
65 | # Flask stuff:
66 | instance/
67 | .webassets-cache
68 |
69 | # Scrapy stuff:
70 | .scrapy
71 |
72 | # Sphinx documentation
73 | docs/_build/
74 |
75 | # PyBuilder
76 | target/
77 |
78 | # Jupyter Notebook
79 | .ipynb_checkpoints
80 |
81 | # IPython
82 | profile_default/
83 | ipython_config.py
84 |
85 | # pyenv
86 | .python-version
87 |
88 | # celery beat schedule file
89 | celerybeat-schedule
90 |
91 | # SageMath parsed files
92 | *.sage.py
93 |
94 | # Environments
95 | .env
96 | .venv
97 | env/
98 | venv/
99 | ENV/
100 | env.bak/
101 | venv.bak/
102 |
103 | # Spyder project settings
104 | .spyderproject
105 | .spyproject
106 |
107 | # Rope project settings
108 | .ropeproject
109 |
110 | # mkdocs documentation
111 | /site
112 |
113 | # mypy
114 | .mypy_cache/
115 | .dmypy.json
116 | dmypy.json
117 |
118 | # Pyre type checker
119 | .pyre/
120 |
121 | ### Python Patch ###
122 | .venv/
123 |
124 | ### Python.VirtualEnv Stack ###
125 | # Virtualenv
126 | # http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
127 | [Bb]in
128 | [Ii]nclude
129 | [Ll]ib
130 | [Ll]ib64
131 | [Ll]ocal
132 | [Ss]cripts
133 | pyvenv.cfg
134 | pip-selfcheck.json
135 |
136 | ### VisualStudioCode ###
137 | .vscode/*
138 | !.vscode/settings.json
139 | !.vscode/tasks.json
140 | !.vscode/launch.json
141 | !.vscode/extensions.json
142 |
143 | # End of https://www.gitignore.io/api/python,visualstudiocode
--------------------------------------------------------------------------------
/powernad/API/Campaign.py:
--------------------------------------------------------------------------------
1 | # pylint: disable=C0103
2 | # pylint: disable=E0401
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.Campaign.CampaignObject import CampaignObject
5 | from powernad.Object.Campaign.RequestObject.CampaignAddObject import CampaignAddObject
6 | from powernad.Object.Campaign.RequestObject.CampaignUpdateObject import CampaignUpdateObject
7 | import json
8 | import jsonpickle
9 | from typing import List
10 | from powernad.Common.CommonFunctions import CommonFunctions
11 |
12 | CampaignList = List[CampaignObject]
13 | CampaignIdList = List[str]
14 | ChangeFieldsList = List[str]
15 |
16 |
17 | class Campaign:
18 |
19 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
20 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
21 |
22 | def get_campaign_list(self, campaignType: str =None, baseSearchId: str=None, recordSize: int=None, selector: str=None) -> CampaignList:
23 |
24 | query = {'campaignType' : campaignType, 'baseSearchId' : baseSearchId, 'recordSize' : recordSize, 'selector' : selector}
25 | result = self.r.get('/ncc/campaigns', query)
26 |
27 | camp_list = []
28 | for arr in result:
29 | camp = CampaignObject(arr)
30 | camp_list.append(camp)
31 |
32 | return camp_list
33 |
34 | def get_campaign_list_by_ids(self, ids: CampaignIdList) -> CampaignList:
35 | ids = ",".join(ids)
36 | query = {'ids' : ids}
37 |
38 | result = self.r.get('/ncc/campaigns', query)
39 |
40 | camp_list = []
41 | for arr in result:
42 | camp = CampaignObject(arr)
43 | camp_list.append(camp)
44 |
45 | return camp_list
46 |
47 | def get_campaign(self, campaignId: str) -> CampaignObject:
48 | result = self.r.get('/ncc/campaigns/'+ campaignId)
49 | camp = CampaignObject(result)
50 | return camp
51 |
52 | def create_campaign(self, campaign_add_object: CampaignAddObject):
53 |
54 | data = jsonpickle.encode(campaign_add_object, unpicklable=False)
55 | data = json.loads(data)
56 | data = CommonFunctions.delete_null_dict_items(data)
57 | data_str = json.dumps(data)
58 | result = self.r.post('/ncc/campaigns', data_str)
59 | camp = CampaignObject(result)
60 | return camp
61 |
62 | def update_campaign(self, campaign_update_object: CampaignUpdateObject, campaignId: str, fields: ChangeFieldsList) -> CampaignList:
63 | fields = ",".join(fields)
64 | fields = {'fields': fields}
65 | data = jsonpickle.encode(campaign_update_object, unpicklable=False)
66 | result = self.r.put('/ncc/campaigns/' + str(campaignId), data, fields) #userLock, budget, period
67 | camp = CampaignObject(result)
68 | return camp
--------------------------------------------------------------------------------
/powernad/API/Ad.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.Ad.AdObject import AdObject
5 | from powernad.Object.Ad.RequestObject.CreateAdObject import CreateAdObject
6 | from powernad.Object.Ad.RequestObject.UpdateAdObject import UpdateAdObject
7 | from powernad.Common.CommonFunctions import CommonFunctions
8 | from typing import List
9 |
10 | AdIdList = List[str]
11 | AdObjectList = List[AdObject]
12 | ChangeFieldsList = List[str]
13 |
14 |
15 | class Ad: #광고 소재에 관한 API입니다.
16 |
17 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
18 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
19 |
20 | def get_ad_list_by_ids(self, ids: AdIdList) -> AdObjectList:
21 | ids = ",".join(ids)
22 | ids = {'ids' : ids}
23 | result = self.r.get('/ncc/ads', ids)
24 | ad_obj_list = []
25 | for arr in result:
26 | ad_obj = AdObject(arr)
27 | ad_obj_list.append(ad_obj)
28 |
29 | return ad_obj_list
30 |
31 | def get_ad_list(self, nccAdGroupId: str) -> AdObjectList:
32 | result = self.r.get('/ncc/ads', {'nccAdgroupId': nccAdGroupId})
33 | adobj_list = []
34 | for arr in result:
35 | ad_obj = AdObject(arr)
36 | adobj_list.append(ad_obj)
37 |
38 | return adobj_list
39 |
40 | def get_ad(self, adId: str) -> AdObject:
41 | result = self.r.get('/ncc/ads/' + adId)
42 | result = AdObject(result)
43 | return result
44 |
45 | def create_ad(self, CreateAdObject: CreateAdObject) -> AdObject:
46 | data = jsonpickle.encode(CreateAdObject, unpicklable=False)
47 | data = json.loads(data)
48 | data = CommonFunctions.delete_null_dict_items(data)
49 | data_str = data
50 | data_str = json.dumps(data_str)
51 | result = self.r.post('/ncc/ads', data_str)
52 | result = AdObject(result)
53 | return result
54 |
55 | def update_ad(self, adId: str, fields: ChangeFieldsList, UpdateAdObject: UpdateAdObject) -> AdObject:
56 | change_fields_list = ",".join(fields)
57 | query = {'fields': change_fields_list}
58 | data = jsonpickle.encode(UpdateAdObject, unpicklable=False)
59 | data = json.loads(data)
60 | data = CommonFunctions.delete_null_dict_items(data)
61 | data_str = data
62 | data_str = json.dumps(data_str)
63 | result = self.r.put('/ncc/ads/' + adId, data_str, query)
64 | result = AdObject(result)
65 | return result
66 |
67 | def delete_ad(self, adId: str):
68 | self.r.delete('/ncc/ads/' + adId)
69 | return True
70 |
71 | def copy_ad(self, adId: str, targetAdGroupId: str, userLock: bool) -> AdObject:
72 | query = {'ids' : adId, 'targetAdgroupId' : targetAdGroupId, 'userLock' : userLock}
73 | result = self.r.put('/ncc/ads', None, query)
74 | result = AdObject(result)
75 | return result
76 |
--------------------------------------------------------------------------------
/powernad/API/AdExtension.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.AdExtension.AdExtensionObject import AdExtensionObject
5 | from powernad.Object.AdExtension.RequestObject.CreateAdExtensionObject import CreateAdExtensionObject
6 | from powernad.Object.AdExtension.RequestObject.UpdateAdExtensionObject import UpdateAdExtensionObject
7 | from powernad.Common.CommonFunctions import CommonFunctions
8 | from typing import List
9 |
10 | AdExtensionObjectList = List[AdExtensionObject]
11 | IdList = List[str]
12 | ChangeFieldsList = List[str]
13 |
14 |
15 | class AdExtension: #확장소재
16 |
17 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
18 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
19 |
20 | def get_ad_extensions_list(self, ownerId: str) -> AdExtensionObjectList:
21 | result = self.r.get('/ncc/ad-extensions', {'ownerId': ownerId})
22 | adext_list = []
23 | for arr in result:
24 | camp = AdExtensionObject(arr)
25 | adext_list.append(camp)
26 | return adext_list
27 |
28 | def get_ad_extensions_list_by_ids(self, ids: IdList) -> AdExtensionObjectList:
29 | ids = ",".join(ids)
30 | ids = {'ids' : ids}
31 | result = self.r.get('/ncc/ad-extensions', ids)
32 | adext_list = []
33 | for arr in result:
34 | camp = AdExtensionObject(arr)
35 | adext_list.append(camp)
36 | return adext_list
37 |
38 | def get_ad_extensions(self, adExtensionId: str) -> AdExtensionObject:
39 | result = self.r.get('/ncc/ad-extensions/'+adExtensionId)
40 | result = AdExtensionObject(result)
41 |
42 | return result
43 |
44 | def create_ad_extensions(self, CreateAdExtensionObject: CreateAdExtensionObject) -> AdExtensionObject:
45 |
46 | data = jsonpickle.encode(CreateAdExtensionObject, unpicklable=False)
47 | data = json.loads(data)
48 | data = CommonFunctions.delete_null_dict_items(data)
49 | data_str = data
50 | data_str = json.dumps(data_str)
51 |
52 | result = self.r.post('/ncc/ad-extensions', data_str)
53 | result = AdExtensionObject(result)
54 | return result
55 |
56 | def update_ad_extensions(self, adExtensionId: str, fields: ChangeFieldsList,
57 | UpdateAdExtensionObject: UpdateAdExtensionObject) -> AdExtensionObject:
58 |
59 | data = jsonpickle.encode(UpdateAdExtensionObject, unpicklable=False)
60 | data = json.loads(data)
61 | data = CommonFunctions.delete_null_dict_items(data)
62 | data_str = data
63 | data_str = json.dumps(data_str)
64 | change_fields_list = ",".join(fields)
65 | query = {'fields': change_fields_list}
66 | result = self.r.put('/ncc/ad-extensions/'+adExtensionId, data_str, query)
67 | result = AdExtensionObject(result)
68 | return result
69 |
70 | def delete_ad_extensions(self, adExtensionId: str):
71 | self.r.delete('/ncc/ad-extensions/'+adExtensionId)
72 | return True
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PowerNad
2 | ## 과제용 프로젝트임에도 관심가져 주셔서 감사합니다. :)
3 |
4 | []()
5 | []()
6 | [](https://pypi.python.org/pypi?:action=display&name=powernad&version=0.3)
7 | [](https://github.com/devkingsejong/python-PowerNad#license)
8 |
9 | ``` 본 문서 또는 라이브러리내에서 언급되는 'Naver' 혹은 '네이버'는 Naver Corp의 상표입니다. ```
10 | ``` 'Naver' and '네이버' are trademarks of Naver Corp ```
11 | ## What is PowerNad?
12 |
13 | PowerNad는 Power for NaverAD의 약자로 [네이버 광고 API](http://naver.github.io/searchad-apidoc/#/guides)를 Python에서 쉽게 사용할 수 있도록 해주는 라이브러리 입니다.
14 |
15 | ``` 2017. 03. 15 ``` 기준으로 전체 API중 90% 이상의 커버율을 가지고 있습니다.
16 |
17 | ## How to Install?
18 |
19 | ``` pip3 install powernad ```
20 |
21 | or
22 |
23 | ```git clone https://github.com/devkingsejong/python-PowerNad.git ```
24 |
25 | ## How to Use?
26 |
27 | powernad는 크게 API들이 정의 되어 있는 ```API```와 Request Object들이 정의되어 있는 ```Object```로 나누어져 있습니다.
28 |
29 | ### 1. Include API
30 |
31 | 특정 API를 사용하고 싶다면,
32 |
33 | ```python
34 | from powernad.API.AdGroup import *
35 | from powernad.API.Campaign import *
36 | ```
37 | 위와 같이 [네이버 광고 API](http://naver.github.io/searchad-apidoc/#/guides)에 정의되어 있는 API명을 import합니다.
38 |
39 | ### 2. Initialize API
40 |
41 | ```python
42 | ad_group = AdGroup('API 호출 주소', 'API 키', 'Secret 키', '유저 고유번호')
43 | campaign = Campaign('API 호출 주소', 'API 키', 'Secret 키', '유저 고유번호')
44 | ```
45 | ```API 호출 주소 ``` : API base url
46 | ```API 키``` : api_key
47 | ```Secret 키``` : secret_key
48 | ```유저 고유번호``` : customer_id
49 |
50 | 위와 같이 Naver API 관리패널에서 발급받은 정보를 넣어, 초기화 해줍니다.
51 |
52 | ### 3. Use GET API
53 |
54 | (1) 캠페인 아이디를 기반으로 그룹 불러오기
55 |
56 | ```python
57 | group_list = campaign.get_adgroup_list('cmp-xxxxx')
58 | ```
59 |
60 | (2) 그룹 아이디를 기반으로 그룹 리스트 불러오기
61 | ```python
62 | group_list2 = ad_group.get_adgroup_list_by_ids(그룹고유번호)
63 | ```
64 |
65 | ### 4. Use Post API(Require Request Params)
66 |
67 | PowerNad에서는 보다 쉽게 Request 파라미터를 구성할 수 있도록, 미리 정의된 ```Object``` 모음을 제공합니다.
68 |
69 | 만약 ```그룹 생성 API```를 사용하고 싶다면,
70 |
71 | ``` python
72 | from powernad.API import AdGroup
73 | from powernad.Object.AdGroup.RequestObject.CreateAdgroupObject import CreateAdgroupObject
74 |
75 | ad_group = AdGroup('API 호출 주소', 'API 키', 'Secret 키', '유저 고유번호')
76 | cad = CreateAdgroupObject('cmp-a000-00-0003', 'group Name', 'bsn-0001-00-0001', 'bsn-a001-00-0002')
77 | ad_group.create_adgroup(cad)
78 |
79 | ```
80 | 위와 같이 Object를 API파라미터에 넣어주는 것 만으로 간단하게 사용할 수 있습니다. (필수 parameter는 생성자로 정의 가능합니다.)
81 |
82 | ## License
83 |
84 |
85 | Copyright (c) <2017> <[devkingsejong](https://github.com/devkingsejong/python-PowerNad)>
86 |
87 | 이 소프트웨어의 복제본과 관련된 문서화 파일(“소프트웨어”)을 획득하는 사람은 누구라도 소프트웨어를 별다른 제한 없이 무상으로 사용할 수 있는 권한을 부여 받는다.
88 | 여기에는 소프트웨어의 복제본을 무제한으로 사용, 복제, 수정, 병합, 공표, 배포, 서브라이선스 설정 및 판매할 수 있는 권리와 이상의 행위를 소프트웨어를 제공받은
89 | 다른 수취인들에게 허용할 수 있는 권리가 포함되며, 다음과 같은 조건을 충족시키는 것을 전제로 한다.
90 |
91 | ```위와 같은 저작권 안내 문구와 본 허용 문구가 소프트웨어의 모든 복제본 및 중요 부분에 포함되어야 한다.```
92 |
93 | 이 소프트웨어는 상품성, 특정 목적 적합성, 그리고 비침해에 대한 보증을 포함한 어떠한 형태의 보증도 명시적이나 묵시적으로 설정되지 않은 “있는 그대로의” 상태로 제공된다. 소프트웨어를 개발한 프로그래머나 저작권자는 어떠한 경우에도 소프트웨어나 소프트웨어의 사용 등의 행위와 관련하여 일어나는 어떤 요구사항이나 손해 및 기타 책임에 대해 계약상, 불법행위 또는 기타 이유로 인한 책임을 지지 않는다.
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/powernad/Object/AdGroup/AdgroupObject.py:
--------------------------------------------------------------------------------
1 | # pylint: disable=C0103
2 | # pylint: disable=E0401
3 |
4 | import json
5 | from ..AdGroup.sub.target import target
6 | from ..AdGroup.sub.targetSummaryObject import targetSummaryObject
7 | from ..AdGroup.sub.adgroupAttrJson import adgroupAttrObject
8 | class AdgroupObject:
9 | def __init__(self, json_def):
10 | if type(json_def) is str:
11 | json_def = json.loads(json_def)
12 | s = json_def
13 |
14 | self.adgroupAttrJson = None if 'adgroupAttrJson' not in s else self.__match_group_attr(s['adgroupAttrJson'])
15 | self.bidAmt = None if 'bidAmt' not in s else s['bidAmt']
16 | self.budgetLock = None if 'budgetLock' not in s else s['budgetLock']
17 | self.contentsNetworkBidAmt = None if 'contentsNetworkBidAmt' not in s else s['contentsNetworkBidAmt']
18 | self.customerId = None if 'customerId' not in s else s['customerId']
19 | self.dailyBudget = None if 'dailyBudget' not in s else s['dailyBudget']
20 | self.delFlag = None if 'delFlag' not in s else s['delFlag']
21 | self.editTm = None if 'editTm' not in s else s['editTm']
22 | self.expectCost = None if 'expectCost' not in s else s['expectCost']
23 | self.keywordPlusWeight = None if 'keywordPlusWeight' not in s else s['keywordPlusWeight']
24 | self.migType = None if 'migType' not in s else s['migType']
25 | self.mobileChannelId = None if 'mobileChannelId' not in s else s['mobileChannelId']
26 | self.mobileChannelKey = None if 'mobileChannelKey' not in s else s['mobileChannelKey']
27 | self.mobileNetworkBidWeight = None if 'mobileNetworkBidWeight' not in s else s['mobileNetworkBidWeight']
28 | self.name = None if 'name' not in s else s['name']
29 | self.nccAdgroupId = None if 'nccAdgroupId' not in s else s['nccAdgroupId']
30 | self.nccCampaignId = None if 'nccCampaignId' not in s else s['nccCampaignId']
31 | self.pcChannelId = None if 'pcChannelId' not in s else s['pcChannelId']
32 | self.pcChannelKey = None if 'pcChannelKey' not in s else s['pcChannelKey']
33 | self.pcNetworkBidWeight = None if 'pcNetworkBidWeight' not in s else s['pcNetworkBidWeight']
34 | self.regTm = None if 'regTm' not in s else s['regTm']
35 | self.status = None if 'status' not in s else s['status']
36 | self.statusReason = None if 'statusReason' not in s else s['statusReason']
37 | self.targets = None if 'targets' not in s else self.__match_target(s['targets'])
38 | self.targetSummary = None if 'targetSummary' not in s else self.__match_target_summary(s['targetSummary'])
39 | self.useCntsNetworkBidAmt = None if 'useCntsNetworkBidAmt' not in s else s['useCntsNetworkBidAmt']
40 | self.useDailyBudget = None if 'useDailyBudget' not in s else s['useDailyBudget']
41 | self.useKeywordPlus = None if 'useKeywordPlus' not in s else s['useKeywordPlus']
42 | self.userLock = None if 'userLock' not in s else s['userLock']
43 |
44 |
45 | def __match_target(self, sarray):
46 | target_list = []
47 | for arr in sarray:
48 | target_item = target(arr)
49 | target_list.append(target_item)
50 |
51 | return target_list
52 |
53 | def __match_target_summary(self, sarray):
54 | summary = targetSummaryObject(sarray)
55 | return summary
56 |
57 | def __match_group_attr(self, sarray):
58 | attr = adgroupAttrObject(sarray)
59 | return attr
--------------------------------------------------------------------------------
/powernad/API/BusinessChannel.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.BusinessChannel.BusinessChannelObject import BusinessChannelObject
5 | from powernad.Object.BusinessChannel.RequestObject.CreateBusinessChannelObject import CreateBusinessChannelObject
6 | from powernad.Object.BusinessChannel.RequestObject.UpdateBusinessChannelObject import UpdateBusinessChannelObject
7 | from powernad.Common.CommonFunctions import CommonFunctions
8 | from typing import List
9 |
10 | BusinessChannelObjectList = List[BusinessChannelObject]
11 | BusinessChannelIdList = List[str]
12 |
13 |
14 | class BusinessChannel:
15 |
16 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
17 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
18 |
19 | def get_business_channel_list(self) -> BusinessChannelObjectList:
20 | result = self.r.get('/ncc/channels')
21 |
22 | business_channel_list = []
23 | for arr in result:
24 | channel = BusinessChannelObject(arr)
25 | business_channel_list.append(channel)
26 |
27 | return business_channel_list
28 |
29 | def get_business_channel_list_by_type(self, tp: str) -> BusinessChannelObjectList:
30 | result = self.r.get('/ncc/channels', {'channelTp': tp})
31 |
32 | business_channel_list = []
33 | for arr in result:
34 | channel = BusinessChannelObject(arr)
35 | business_channel_list.append(channel)
36 |
37 | return business_channel_list
38 |
39 | def get_business_channel_list_by_ids(self, ids: BusinessChannelIdList) -> BusinessChannelObjectList:
40 | ids = ",".join(ids)
41 | query = {'ids': ids}
42 | result = self.r.get('/ncc/channels', query)
43 |
44 | business_channel_list = []
45 | for arr in result:
46 | channel = BusinessChannelObject(arr)
47 | business_channel_list.append(channel)
48 | return business_channel_list
49 |
50 | def get_business_channel(self, businessChannelId) -> BusinessChannelObject:
51 | result = self.r.get('/ncc/channels/'+businessChannelId)
52 | result = BusinessChannelObject(result)
53 |
54 | return result
55 |
56 | def create_business_channel(self, CreateBusinessChannelObj: CreateBusinessChannelObject) -> BusinessChannelObject:
57 |
58 | data = jsonpickle.encode(CreateBusinessChannelObj, unpicklable=False)
59 | data = json.loads(data)
60 | data = CommonFunctions.delete_null_dict_items(data)
61 | data_str = json.dumps(data)
62 | result = self.r.post('/ncc/channels', data_str)
63 | result = BusinessChannelObject(result)
64 | return result
65 |
66 | def update_business_channel(self, fields, UpdateBusinessChannelObj: UpdateBusinessChannelObject) -> BusinessChannelObject:
67 | data = jsonpickle.encode(UpdateBusinessChannelObj, unpicklable=False)
68 | data = json.loads(data)
69 | data = CommonFunctions.delete_null_dict_items(data)
70 | data_str = json.dumps(data)
71 | result = self.r.put('/ncc/channels', data_str, fields)
72 | result = BusinessChannelObject(result)
73 | return result
74 |
75 | def delete_business_channel(self, businessChannelId: str):
76 | self.r.delete('/ncc/channels/'+businessChannelId)
77 | return True
78 |
79 | def delete_business_channel_by_ids(self, ids: BusinessChannelIdList):
80 | ids = ",".join(ids)
81 | query = {'ids': ids}
82 | self.r.delete('/ncc/channels', query)
83 | return True
84 |
--------------------------------------------------------------------------------
/powernad/API/AdKeyword.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.AdKeyword.AdKeywordObject import AdKeywordObject
5 | from powernad.Object.AdKeyword.ManagedKeywordObject import ManagedKeywordObject
6 | from powernad.Common.CommonFunctions import CommonFunctions
7 | from typing import List
8 |
9 | AdKeywordList = List[AdKeywordObject]
10 | AdKeywordIdList = List[str]
11 | KeywordsList = List[str]
12 |
13 |
14 | class AdKeyword:
15 |
16 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
17 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
18 |
19 | def get_adkeyword_list_by_label_id(self, nccLabelId: str) -> AdKeywordList:
20 | query = {'nccLabelId': nccLabelId}
21 | result = self.r.get('/ncc/keywords', query)
22 |
23 | adkeyword_list = []
24 | for arr in result:
25 | keyword = AdKeywordObject(arr)
26 | adkeyword_list.append(keyword)
27 |
28 | return adkeyword_list
29 |
30 | def get_adkeyword_list_by_ids(self, ids: AdKeywordIdList) -> AdKeywordList:
31 | ids = ",".join(ids)
32 | query = {'ids' : ids}
33 | result = self.r.get('/ncc/keywords', query)
34 |
35 | adkeyword_list = []
36 | for arr in result:
37 | keyword = AdKeywordObject(arr)
38 | adkeyword_list.append(keyword)
39 |
40 | return adkeyword_list
41 |
42 |
43 | def get_adkeyword_list_by_group_id(self, nccAdgroupId: str= None, baseSearchId:str =None,
44 | recordSize: int = None, selector:str = None) -> AdKeywordList:
45 |
46 | query = {'nccAdgroupId' : nccAdgroupId, 'baseSearchId' : baseSearchId, 'recordSize' : recordSize,
47 | 'selector' : selector}
48 | result = self.r.get('/ncc/keywords', query)
49 |
50 | adkeyword_list = []
51 | for arr in result:
52 | keyword = AdKeywordObject(arr)
53 | adkeyword_list.append(keyword)
54 |
55 | return adkeyword_list
56 |
57 |
58 | def get_adkeyword(self, nccKeywordId) -> AdKeywordObject:
59 | result = self.r.get('/ncc/keywords/' + nccKeywordId)
60 | result = AdKeywordObject(result)
61 | return result
62 |
63 | def create_adkeyword(self, nccAdgroupId, CreateAdKeywordObject) -> AdKeywordObject:
64 | data = jsonpickle.encode(CreateAdKeywordObject, unpicklable=False)
65 | data = json.loads(data)
66 | data = CommonFunctions.delete_null_dict_items(data)
67 | data = [data]
68 | data_str = json.dumps(data)
69 |
70 | result = self.r.post('/ncc/keywords', data_str, {'nccAdgroupId' : nccAdgroupId})
71 | result = AdKeywordObject(result)
72 | return result
73 |
74 | def update_adkeyrword(self, nccKeywordId, fields, UpdateAdKeywordObject) -> AdKeywordObject:
75 | data = jsonpickle.encode(UpdateAdKeywordObject, unpicklable=False)
76 | data = json.loads(data)
77 | data = CommonFunctions.delete_null_dict_items(data)
78 | data_str = json.dumps(data)
79 |
80 | query = {'fields' : fields}
81 |
82 | result = self.r.put('/ncc/keywords/'+nccKeywordId, data_str, query)
83 | result = AdKeywordObject(result)
84 |
85 | return result
86 |
87 | def delete_adkeyword(self, nccKeywordId: str):
88 | self.r.delete('/ncc/keywords/' + nccKeywordId)
89 | return True
90 |
91 | def delete_adkeyword_many(self, ids: AdKeywordIdList):
92 | ids = ",".join(ids)
93 | query = {'ids' : ids}
94 | self.r.delete('/ncc/keywords', query)
95 |
96 | def managed_keyword_list(self, keywords: KeywordsList) -> ManagedKeywordObject:
97 | keywords = ",".join(keywords)
98 | query = {'keywords': keywords}
99 | result = self.r.get('/ncc/managedKeyword', query)
100 |
101 | managedkeyword_list = []
102 | for arr in result:
103 | managedkeyword = ManagedKeywordObject(arr)
104 | managedkeyword_list.append(managedkeyword)
105 |
106 | return managedkeyword_list
--------------------------------------------------------------------------------
/powernad/API/Estimate.py:
--------------------------------------------------------------------------------
1 | import json
2 | import jsonpickle
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.Estimate.EstimateAvgObject import EstimateAvgObject
5 | from powernad.Object.Estimate.EstimateMedianObject import EstimateMedianObject
6 | from powernad.Object.Estimate.EstimateExposureMiniObject import EstimateExposureMiniObject
7 | from powernad.Object.Estimate.EstimatePerformanceObject import EstimatePerformanceObject
8 | from powernad.Object.Estimate.RequestObject.GetAvgPositionBidObject import GetAvgPositionBidObject
9 | from powernad.Object.Estimate.RequestObject.GetExposureMiniBidObject import GetExposureMiniBidObject
10 | from powernad.Object.Estimate.RequestObject.GetMedianBidObject import GetMedianBidObject
11 | from powernad.Object.Estimate.RequestObject.GetPerformanceObject import GetPerformanceObject
12 | from powernad.Common.CommonFunctions import CommonFunctions
13 |
14 | from typing import List
15 | EstimateAvgObjectList = List[EstimateAvgObject]
16 | EstimateMedianObjectList = List[EstimateMedianObject]
17 | EstimateExposureMiniObjectList = List[EstimateExposureMiniObject]
18 | EstimatePerformanceObjectList = List[EstimatePerformanceObject]
19 | GetPerformanceObjectList = List[GetPerformanceObject]
20 |
21 |
22 | class Estimate:
23 |
24 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
25 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
26 |
27 | def get_avg_position_bid_list(self, type, GetAvgPositionBidObject: GetAvgPositionBidObject) -> EstimateAvgObjectList:
28 |
29 | data = jsonpickle.encode(GetAvgPositionBidObject, unpicklable=False)
30 | data = json.loads(data)
31 | data = CommonFunctions.delete_null_dict_items(data)
32 | data_str = json.dumps(data)
33 |
34 | result = self.r.post('/estimate/average-position-bid/' + type, data_str)
35 | result = result['estimate']
36 | estimate_list = []
37 | for arr in result:
38 | estimate = EstimateAvgObject(arr)
39 | estimate_list.append(estimate)
40 |
41 | return estimate_list
42 |
43 | def get_median_bid_list(self, type: str, GetMedianBidObject: GetMedianBidObject) -> EstimateMedianObjectList:
44 | data = jsonpickle.encode(GetMedianBidObject, unpicklable=False)
45 | data = json.loads(data)
46 | data = CommonFunctions.delete_null_dict_items(data)
47 | data_str = json.dumps(data)
48 |
49 | result = self.r.post('/estimate/median-bid/' + type, data_str)
50 | result = result['estimate']
51 | estimate_list = []
52 | for arr in result:
53 | estimate = EstimateMedianObject(arr)
54 | estimate_list.append(estimate)
55 |
56 | return estimate_list
57 |
58 | def get_exposure_mini_bid_list(self, type: str, GetExposureMiniBidObject: GetExposureMiniBidObject) -> EstimateExposureMiniObjectList:
59 | data = jsonpickle.encode(GetExposureMiniBidObject, unpicklable=False)
60 | data = json.loads(data)
61 | data = CommonFunctions.delete_null_dict_items(data)
62 | data_str = json.dumps(data)
63 |
64 | result = self.r.post('/estimate/exposure-minimum-bid/' + type, data_str)
65 | result = result['estimate']
66 | estimate_list = []
67 | for arr in result:
68 | estimate = EstimateExposureMiniObject(arr)
69 | estimate_list.append(estimate)
70 |
71 | return estimate_list
72 |
73 | def get_performance_list(self, type: str, GetPerformanceObject: GetPerformanceObject) -> EstimatePerformanceObjectList:
74 | data = jsonpickle.encode(GetPerformanceObject, unpicklable=False)
75 | data = json.loads(data)
76 | data = CommonFunctions.delete_null_dict_items(data)
77 | data_str = json.dumps(data)
78 |
79 | result = self.r.post('/estimate/performance/' + type, data_str)
80 | result = result['estimate']
81 |
82 | estimate_list = []
83 | for arr in result:
84 | estimate = EstimatePerformanceObject(arr)
85 | estimate_list.append(estimate)
86 |
87 | return estimate_list
88 |
89 | def get_performance_list_many(self, type: str, GetPerformanceObjectList: GetPerformanceObjectList):
90 | data = jsonpickle.encode(GetPerformanceObjectList, unpicklable=False)
91 | data = json.loads(data)
92 | data = CommonFunctions.delete_null_dict_items(data)
93 | data_str = json.dumps(data)
94 |
95 | result = self.r.post('/estimate/performance/' + type, data_str)
96 | result = result['estimate']
97 |
98 | estimate_list = []
99 | for arr in result:
100 | estimate = EstimatePerformanceObject(arr)
101 | estimate_list.append(estimate)
102 |
103 | return estimate_list
104 |
--------------------------------------------------------------------------------
/powernad/Connector/restapi.py:
--------------------------------------------------------------------------------
1 | import base64
2 | import hmac
3 | import hashlib
4 | import time
5 | import urllib.parse
6 | import json
7 | import requests
8 | import jsonpickle
9 |
10 |
11 | class RestApi:
12 | def __init__(self, base_url, api_key, secret_key, customer_id):
13 | self.base_url = base_url
14 | self.api_key = api_key
15 | self.secret_key = secret_key
16 | self.customer_id = customer_id
17 |
18 |
19 | def generate_signature(self, timestamp, method, path):
20 | sign = "%s.%s.%s" % (timestamp, method, path)
21 | # signature = hmac.new(self.secret_key.encode(), sign.encode(), hashlib.sha256).hexdigest()
22 | signature = hmac.new(self.secret_key.encode(), sign.encode(), hashlib.sha256).digest()
23 | return base64.b64encode(signature).decode()
24 |
25 |
26 | def get_timestamp(self):
27 | return round(time.time() * 1000)
28 |
29 |
30 | def get_header(self, method, uri):
31 | timestamp = self.get_timestamp()
32 | header = {}
33 | header['Content-Type'] = 'application/json; charset=UTF-8'
34 | header['X-Timestamp'] = str(timestamp)
35 | header['X-API-KEY'] = self.api_key
36 | header['X-Customer'] = str(self.customer_id)
37 | header['X-Signature'] = self.generate_signature(timestamp, method, uri)
38 |
39 | return header
40 |
41 | def build_http_query(self, query):
42 | if query:
43 | query_list = []
44 |
45 | for key, value in query.items():
46 |
47 | if value != None:
48 | q = "%s=%s" % ( urllib.parse.quote_plus(key), urllib.parse.quote_plus(value) )
49 | else:
50 | continue
51 | query_list.append(q)
52 | return '&'.join(query_list)
53 | else:
54 | return ''
55 |
56 |
57 | def get_transaction_id(self, headers):
58 | if "X-Transaction-ID" in headers:
59 | return headers["X-Transaction-ID"]
60 | else:
61 | return "unknown"
62 |
63 |
64 | def parse_response(self, response):
65 | if response:
66 | header = response.headers
67 | body = response.text
68 | transaction_id = self.get_transaction_id(header)
69 | json_body = json.loads(body)
70 |
71 | return {'transaction_id': transaction_id, 'json': json_body}
72 |
73 | return {}
74 |
75 |
76 | def get(self, uri, query={}):
77 | url = "%s%s%s%s" % ( self.base_url, uri, '' if query=={} else '?', self.build_http_query(query))
78 | headers = self.get_header('GET', uri)
79 |
80 | try:
81 | r = requests.get(url, headers=headers)
82 | response = self.parse_response(r)
83 | if not r.ok:
84 | print("Http status: %s" % r.status_code)
85 |
86 | return response['json']
87 | except:
88 | print("failed to request")
89 |
90 |
91 | def post(self, uri, data, query={}):
92 | url = "%s%s%s%s" % ( self.base_url, uri, '' if query=={} else '?', self.build_http_query(query))
93 | data_str = data
94 | headers = self.get_header('POST', uri)
95 |
96 | try:
97 | r = requests.post(url, data=data_str, headers=headers)
98 | response = self.parse_response(r)
99 | if not r.ok:
100 | print("Http status: %s" % r.status_code)
101 |
102 | return response['json']
103 | except:
104 | print("failed to request")
105 |
106 |
107 | def delete(self, uri, query={}):
108 | url = "%s%s%s%s" % ( self.base_url, uri, '' if query=={} else '?', self.build_http_query(query))
109 | headers = self.get_header('DELETE', uri)
110 |
111 | try:
112 | r = requests.delete(url, headers=headers)
113 | response = self.parse_response(r)
114 | if not r.ok:
115 | print("Http status: %s" % r.status_code)
116 |
117 | return response['json']
118 | except:
119 | print("failed to request")
120 |
121 |
122 |
123 | def put(self, uri, data, query={}):
124 | url = "%s%s%s%s" % ( self.base_url, uri, '' if query=={} else '?', self.build_http_query(query))
125 | data_str = data
126 | headers = self.get_header('PUT', uri)
127 |
128 | try:
129 | r = requests.put(url, data=data_str, headers=headers)
130 | response = self.parse_response(r)
131 | if not r.ok:
132 | print("Http status: %s" % r.status_code)
133 |
134 | return response['json']
135 | except:
136 | print("failed to request")
137 |
138 |
139 | def download(self, url, localpath):
140 | return None
141 |
142 | def null_dict(self, input_dict):
143 | real = dict()
144 | for now in input_dict:
145 | if input_dict[now] != None:
146 | real.update({now :input_dict[now]})
147 | return real
148 |
--------------------------------------------------------------------------------
/powernad/API/AdGroup.py:
--------------------------------------------------------------------------------
1 | # pylint: disable=C0103
2 | # pylint: disable=E0401
3 | from powernad.Connector.restapi import RestApi
4 | from powernad.Object.AdGroup.RestrictedKeyword import RestrictedKeyword
5 | from powernad.Object.AdGroup.RequestObject.RestrictedKeywordsObject import RestrictedKeywordsObject
6 | from powernad.Object.AdGroup.RequestObject.UpdateEntireAdgroupObject import UpdateEntireAdgroupObject
7 | from powernad.Object.AdGroup.RequestObject.CreateAdgroupObject import CreateAdgroupObject
8 | from powernad.Object.AdGroup.RequestObject.UpdateAdgroupObject import UpdateAdgroupObject
9 | from powernad.Object.AdGroup.AdgroupObject import AdgroupObject
10 | from powernad.Common.CommonFunctions import CommonFunctions
11 | import json
12 | import jsonpickle
13 | from typing import List
14 |
15 | RestrictedKeywordsAddObject = List[RestrictedKeywordsObject]
16 | RestrictedKeywordList = List[RestrictedKeyword]
17 | AdGroupList = List[AdgroupObject]
18 | AdGroupIdList = List[str]
19 | RestrictedKeywordIdList = List[str]
20 | ChangeFieldsList = List[str]
21 |
22 |
23 | class AdGroup:
24 |
25 | def __init__(self, base_url: str, api_key: str, secret_key: str, customer_id: int):
26 | self.r = RestApi(base_url, api_key, secret_key, customer_id)
27 |
28 | def get_restricted_keyword(self, adgroupId: str) -> RestrictedKeywordList:
29 | query = {'type': 'KEYWORD_PLUS_RESTRICT'}
30 | result = self.r.get('/ncc/adgroups/' + adgroupId + "/restricted-keywords", query);
31 | restricted_list = []
32 | for arr in result:
33 | restricted_keyword = RestrictedKeyword(arr)
34 | restricted_list.append(restricted_keyword)
35 |
36 | return restricted_list
37 |
38 | def get_adgroup_list(self, nccCampaignId: str = None, baseSearchId: str = None,
39 | recordSize: int = None, selector: str = None) -> AdGroupList:
40 |
41 | query = {'nccCampaignId' : nccCampaignId, 'baseSearchId' : baseSearchId,
42 | 'record_size': recordSize, 'selector' : selector}
43 | result = self.r.get('/ncc/adgroups', query)
44 |
45 | adgroup_list = []
46 | for arr in result:
47 | camp = AdgroupObject(arr)
48 | adgroup_list.append(camp)
49 |
50 | return adgroup_list
51 |
52 | def get_adgroup_list_by_ids(self, ids: AdGroupIdList) -> AdGroupList:
53 | ids = ",".join(ids)
54 | query = {'ids' : ids}
55 | result = self.r.get('/ncc/adgroups', query)
56 | adgroup_list = []
57 | for arr in result:
58 | camp = AdgroupObject(arr)
59 | adgroup_list.append(camp)
60 |
61 | return adgroup_list
62 |
63 | def get_adgroup_by_adgroupid(self, adgroupId: str) -> AdgroupObject:
64 | result = self.r.get('/ncc/adgroups/'+adgroupId)
65 | adgroup = AdgroupObject(result)
66 | return adgroup
67 |
68 | def create_restricted_keyword(self, adgroupId: str, restricted_keywords_object: RestrictedKeywordsAddObject) -> RestrictedKeyword:
69 | data = jsonpickle.encode(restricted_keywords_object, unpicklable=False)
70 | data = json.loads(data)
71 | data = CommonFunctions.delete_null_dict_items(data)
72 | data_str = [data]
73 | data_str = json.dumps(data_str);
74 | result = self.r.post('/ncc/adgroups/%s/restricted-keywords' % str(adgroupId), data_str)
75 | restrict_keyword = RestrictedKeyword(result)
76 |
77 | return restrict_keyword
78 |
79 | def create_adgroup(self, create_adgroup_object: CreateAdgroupObject):
80 | data = jsonpickle.encode(create_adgroup_object, unpicklable=False)
81 | data = json.loads(data)
82 | data = CommonFunctions.delete_null_dict_items(data)
83 | data_str = json.dumps(data)
84 | result = self.r.post('/ncc/adgroups', data_str)
85 | result = AdgroupObject(result)
86 | return result
87 |
88 | def update_adgroup(self, adgroupId: str, fields: ChangeFieldsList, UpdateAdgroupObject: UpdateAdgroupObject):
89 | change_fields_list = ",".join(fields)
90 | query = {'fields': change_fields_list}
91 | data = jsonpickle.encode(UpdateAdgroupObject, unpicklable=False)
92 | data = json.loads(data)
93 | data = CommonFunctions.delete_null_dict_items(data)
94 | data_str = json.dumps(data)
95 | result = self.r.put('/ncc/adgroups/' + adgroupId, data_str, query)
96 | result = AdgroupObject(result)
97 | return result
98 |
99 | def update_adgroup_entire(self, adgroupId: str, UpdateEntireAdgroupObject: UpdateEntireAdgroupObject):
100 | data = jsonpickle.encode(UpdateEntireAdgroupObject, unpicklable=False)
101 | data = json.loads(data)
102 | data = CommonFunctions.delete_null_dict_items(data)
103 | data_str = json.dumps(data)
104 | result = self.r.put('/ncc/adgroups/' + adgroupId, data_str)
105 | result = AdgroupObject(result)
106 | return result
107 |
108 | def delete_group_restricted_keyword(self, adgroupId: str, res_keyword_ids: RestrictedKeywordIdList):
109 | res_keyword_ids = ",".join(res_keyword_ids)
110 | query = {'ids': res_keyword_ids}
111 | result = self.r.delete('/ncc/adgroups/%s/restricted-keywords' % str(adgroupId), query)
112 | return True
113 |
114 | def delete_adgroup(self, adgroupId: str):
115 | result = self.r.delete('/ncc/adgroups/' + adgroupId)
116 | return True
--------------------------------------------------------------------------------
/powernad/mini_api_doc.md:
--------------------------------------------------------------------------------
1 | # 캠페인
2 |
3 | ## 초기화:
4 |
5 | ```python
6 | from API.Campaign import Campaign
7 | campain = Campaign(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
8 | ```
9 |
10 |
11 | ## 캠페인 리스트 불러오기:
12 |
13 | ```python
14 | campain.get_campaign_list()
15 | ```
16 |
17 | ## 아이디로 캠페인 리스트 불러오기 :
18 |
19 | ```python
20 | campain.get_campaign_list_by_ids("cmp-a001-01-000000000171629")
21 | ```
22 |
23 | ## 캠페인 정보 불러오기:
24 |
25 | ```python
26 | campain.get_campaign("cmp-a001-01-000000000171629")
27 | ```
28 |
29 | ## 캠페인 생성하기:
30 |
31 | ```python
32 | from Object.Campain.RequestObject.CampainAddObject import CampainAddObject
33 |
34 | campain_add_object = CampaignAddObject(client.CUSTOMER_ID, "WEB_SITE", "난니가정말좋아")
35 | campain.create_campaign(campain_add_object)
36 | ```
37 |
38 | ## 캠페인 업데이트하기:
39 |
40 | ```python
41 | from Object.Campain.RequestObject.CampainUpdateObject import CampainUpdateObject
42 |
43 | campain_update_object = CampainUpdateObject(True, True, True) # userLock, budget, period만 필드에 들어갑니다.
44 | campain_add_object.update_campaign(campain_update_object, "cmp-a001-01-000000000375491", "userLock")
45 | ```
46 |
47 | # 애드그룹
48 |
49 | ## 초기화:
50 |
51 | ```python
52 | from API.AdGroup import AdGroup
53 | ad_group = AdGroup(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
54 | ```
55 |
56 | ## 제외한 확장 키워드 불러오기:
57 |
58 | ```python
59 | ad_group.get_restricted_keyword(애드그룹고유번호)
60 | ```
61 |
62 | ## 캠페인 아이디를 기반으로 그룹들 불러오기:
63 |
64 | ```python
65 | ad_group.get_adgroup_list(campaignid = None, baseid = None, record_size = None, selector = None)
66 | ```
67 |
68 | ## 그룹 고유 아이디를 기반으로 그룹리스트 불러오기 :
69 |
70 | ```python
71 | ad_group.get_adgroup_list_by_ids(그룹고유번호)
72 | ```
73 |
74 | ## 그룹 고유 아이디를 기반으로 그룹 정보 불러오기 :
75 |
76 | ```python
77 | ad_group.get_adgroup_by_adgroupid(그룹고유번호)
78 | ```
79 |
80 | ## 제외할 확장 키워드를 추가하기:
81 |
82 | ```python
83 | from Object.Adgroup.RequestObject.RestrictedKeywordsObject import RestrictedKeywordsObject
84 |
85 | restricted_keywords_object = RestrictedKeywordsObject("쁘디성형","에피아테스트2","grp-a001-01-000000002412336")
86 | ad_group.create_restricted_keyword("grp-a001-01-000000002412336", restricted_keywords_object)
87 | ```
88 |
89 | ## 애드그룹 생성하기:
90 |
91 | ```python
92 | from Object.Adgroup.RequestObject.CreateAdGroupObject import CreateAdGroupObject
93 |
94 | create_ad_group_object = CreateAdgroupObject('cmp-a001-01-000000000375491',
95 | 'ad_group_name',
96 | 'bsn-a001-00-000000000268491',
97 | 'bsn-a001-00-000000000268491')
98 | ad_group.create_adgroup(create_ad_group_object)
99 | ```
100 |
101 | ## 애드그룹업데이트하기(필드를 통해):
102 |
103 | ```python
104 | from Object.Adgroup.RequestObject.UpdateAdgroupObject import UpdateAdgroupObject
105 |
106 | update_adgroup_object = UpdateAdgroupObject(50000)
107 | ad_group.update_adgroup('grp-a001-01-000000002412336', {'fields': 'bidAmt'}, update_adgroup_object)
108 | ```
109 |
110 | ## 애드그룹업데이트하기(엔타이어):
111 |
112 | ```동작 여부 테스트 필요```
113 |
114 | ## 그룹에서 제외 키워드 삭제하기:
115 |
116 | ```python
117 | ad_group.delete_group_restricted_keyword('grp-a001-01-000000002412336','rst-a001-00-000000000081865')
118 | ```
119 |
120 | ## 애드그룹 삭제하기 :
121 |
122 | ```python
123 | ad_group.delete_adgroup('grp-a001-01-000000002548183')
124 | ```
125 |
126 | # 애드(소재)
127 |
128 | ## 초기화:
129 |
130 | ```python
131 | from API.Ad import Ad
132 |
133 | ad = Ad(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
134 | ```
135 |
136 | ## 소재고유번호를 통해 리스트 받아오기:
137 |
138 | ```python
139 | ad_list = ad.get_ad_list_by_ids('nad-a001-01-000000009598016')
140 | print(ad_list[0].nccAdId)
141 | ```
142 |
143 | ## 애드그룹고유번호를 통해 리스트 받아오기:
144 |
145 | ```python
146 | ad_list = ad.get_ad_list('grp-a001-01-000000002412336')
147 | print(ad_list[0].ad.pc)
148 | ```
149 |
150 | ## 소재고유번호를 통해 소재 정보 받아오기:
151 |
152 | ```python
153 | target_ad = ad.get_ad('nad-a001-01-000000009598016')
154 | print(target_ad.nccAdgroupId)
155 | ```
156 |
157 | ## 소재등록하기:
158 |
159 | ```python
160 | from Object.Ad.sub.AdFieldObject import AdFieldObject
161 |
162 | filed_obj = AdFieldObject()
163 | filed_obj.description = "이것은 에이피아이 테스트의 일종으로 테스트입니다."
164 | filed_obj.headline = "에이피아이 wowwow"
165 | filed_obj.pc = filed_obj.make_pc_easy('http://www.naver.com')
166 | filed_obj.mobile = filed_obj.make_mobile_easy('http://www.naver.com')
167 |
168 | add_obj = CreateAdObject(filed_obj, 'grp-a001-01-000000002412336', 'TEXT_45')
169 |
170 | return_obj = ad.create_ad(add_obj)
171 | ```
172 |
173 | ## 소재 수정하기:
174 |
175 | ```python
176 | from Object.Ad.sub.AdFieldObject import AdFieldObject
177 |
178 | filed_obj = AdFieldObject()
179 | filed_obj.description = "이것은 에이피아이 테스트의 일종으로 테스트"
180 | filed_obj.headline = "에이피아이 에드클라우드"
181 | filed_obj.pc = filed_obj.make_pc_easy('http://www.naver.com')
182 | filed_obj.mobile = filed_obj.make_mobile_easy('http://www.naver.com')
183 |
184 | update_obj = UpdateAdObject(filed_obj,'nad-a001-01-000000010072369')
185 | update_obj.userLock = 1
186 | ad.update_ad('nad-a001-01-000000010072369', 'userLock', update_obj)
187 | ```
188 |
189 | ## 소재 복사:
190 |
191 | ```python
192 | ad.copy_ad('nad-a001-01-000000009598016', 'grp-a001-01-000000002548182', '0')
193 | ```
194 |
195 | ## 소재 삭제:
196 |
197 | ```python
198 | ad.delete_ad('nad-a001-01-000000010072402')
199 | ```
200 |
201 | # 확장소재
202 |
203 | ## 초기화:
204 |
205 | ```python
206 | from API.AdExtention import AdExtention
207 |
208 | ad_extention = AdExtention(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
209 | ```
210 |
211 | ## 캠페인 아이디나 그룹아이디를 기반으로 확장소재 리스트 가져오기:
212 |
213 | ```python
214 | ad_extention.get_ad_extensions_list('cmp-a001-01-000000000375491')
215 | ```
216 |
217 | ## 확장소재 아이디를 기반으로 확장소재 리스트 가져오기 :
218 |
219 | ```python
220 | ad_extention.get_ad_extensions_list_by_ids('ext-a001-01-000000000503236')
221 | ```
222 |
223 | ## 확장소재 아이디를 기반으로 확장소재 가져오기:
224 |
225 | ```python
226 | target_ad_extention = ad_extention.get_ad_extensions('ext-a001-01-000000000503236')
227 | print(target_ad_extention)
228 | ```
229 |
230 | ## 확장 소재를 등록하기:
231 |
232 | ```python
233 | from Object.AdExtention.RequestObject.CreateAdExtensionObject import CreateAdExtensionObject
234 |
235 | create_ad_extention_object = CreateAdExtensionObject('bsn-a001-00-000000000287001',
236 | 'bsn-a001-00-000000000287001',
237 | 'cmp-a001-01-000000000375491', 'PHONE', False)
238 | ad_extention.creat_ad_extensions(create_ad_extention_object)
239 | ```
240 |
241 | ## 확장소재 업데이트:
242 |
243 | ```python
244 | from Object.AdExtention.RequestObject.UpdateAdExtensionObject import UpdateAdExtensionObject
245 |
246 | update_ad_extention_object = UpdateAdExtensionObject('ext-a001-01-000000000503236', None, False)
247 | ad_extention.update_ad_extensions('ext-a001-01-000000000503236', 'userLock', update_ad_extention_object)
248 | ```
249 |
250 | ## 확장소재 삭제하기:
251 |
252 | ```python
253 | ad_extention.delete_ad_extensions('ext-a001-01-000000000503236')
254 | ```
255 |
256 | # 비즈니스채널
257 |
258 | ## 초기화:
259 |
260 | ```python
261 | from API.BusinessChannel import BusinessChannel
262 |
263 | business_channel = BusinessChannel(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
264 | ```
265 |
266 | ## 비즈니스 채널 리스트가져오기:
267 |
268 | ```python
269 | target_business_channel = business_channel.get_business_channel_list()
270 | print(target_business_channel[0].businessInfo.site)
271 | ```
272 |
273 | ## 채널 타입을 기준으로 채널 리스트 가져오기:
274 |
275 | ```python
276 | target_business_channel = business_channel.get_business_channel_list_by_type(self, 'PHONE'):
277 | print(target_business_channel[0].businessInfo.site)
278 | ```
279 |
280 | ## 채널 고유번호를 기준으로 채널 리스트 가져오기:
281 |
282 | ```python
283 | target_business_channel_list = business_channel.get_business_channel_list_by_ids('bsn-a001-00-000000000124029')
284 | print(target_business_channel_list[0].businessInfo.site)
285 | ```
286 |
287 | ## 채널 고유번호로 비즈니스 채널 가져오기:
288 |
289 | ```python
290 | target_business_channel = business_channel.get_business_channel('bsn-a001-00-000000000124029')
291 | print(target_business_channel.blackStatus)
292 | ```
293 |
294 | ## 비즈니스 채널 만들기:
295 |
296 | ```python
297 | from Object.BusinessChannel.RequestObject.CreateBusinessChannelObject import CreateBusinessChannelObject
298 |
299 | create_business_channel_object = CreateBusinessChannelObject('http://simpangoooo.net', 'apitest2')
300 | business_channel.create_business_channel(create_business_channel_object)
301 | ```
302 |
303 | ## 비즈채널업데이트:
304 |
305 | ``` 동작 여부 테스트 필요함 ```
306 |
307 | ## 비즈채널삭제:
308 |
309 | ```python
310 | business_channel.delete_business_channel('bsn-a001-00-000000000298203')
311 | ```
312 |
313 | ## ids로 비즈채널(클릭초이스) 삭제:
314 |
315 | ```python
316 | business_channel.delete_business_channel_by_ids('ids,')
317 | ```
318 |
319 | ## request inspect:
320 |
321 | ``` 지원 예정 ```
322 |
323 | # AdKeyword
324 |
325 | ## 초기화:
326 |
327 | ```python
328 | from API.AdKeyword import AdKeyword
329 |
330 | ad_keyword = AdKeyword(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
331 | ```
332 |
333 | ## 키워드 고유번호를 기반으로 키워드 리스트 가져오기:
334 |
335 | ```python
336 | ad_keyword.get_adkeyword_list_by_ids(ids)
337 | ```
338 |
339 | ## 라벨 아이디를 기반으로 키워드 리스트 가져오기:
340 |
341 | ```python
342 | ad_keyword.get_adkeyword_list_by_labelid(labelid)
343 | ```
344 |
345 | ## 그룹 아이디를 기반으로 키워드 리스트 가져오기:
346 |
347 | ```python
348 | ad_keyword.get_adkeyword_list_by_groupid(group id)
349 | ```
350 |
351 | ## 키워드 정보 가져오기:
352 |
353 | ```python
354 | target_ad_keyword = ad_keyword.get_adkeyword('nkw-a001-01-000000458957253')
355 | print(target_ad_keyword.bidAmt)
356 | ```
357 |
358 | ## 키워드 생성하기:
359 |
360 | ```python
361 | from Object.AdKeyword.RequestObject.CreateAdKeywordObject import CreateAdKeywordObject
362 |
363 | create_ad_keyword_object = CreateAdKeywordObject("키워드")
364 |
365 | ad_keyword.create_adkeyword('grp-a001-01-000000002412336', create_ad_keyword_object)
366 | ```
367 |
368 | ## 키워드 업데이트 하기:
369 |
370 | ```python
371 | from Object.AdKeyword.RequestObject.UpdateAdKeywordObject import UpdateAdKeywordObject
372 |
373 | update_ad_keyword_objecy = UpdateAdKeywordObject('grp-a001-01-000000002412336', 'nkw-a001-01-000000472996331')
374 | update_ad_keyword_objecy.bidAmt = 3450
375 | update_ad_keyword_objecy.useGroupBidAmt = False
376 |
377 | ad_keyword.update_adkeyrword('nkw-a001-01-000000472996331', 'bidAmt', update_ad_keyword_objecy)
378 | ```
379 |
380 | ## 키워드 삭제하기:
381 |
382 | ```python
383 | ad_keyword.delete_adkeyword('nkw-a001-01-000000472996331')
384 | ```
385 |
386 | ## 키워드 한번에 여러개 삭제:
387 |
388 | ```python
389 | ad_keyword.delete_adkeyword_many(ids_list):
390 | ```
391 |
392 | ## 관리하고 있는 키워드의 리스트 가져오기:
393 |
394 | ```python
395 | target_ad_keyword = ad_keyword.managed_keyword_list('온라인광고')
396 | print(target_ad_keyword[0].managedKeyword.isAdult)
397 | ```
398 |
399 | # 라벨
400 |
401 | ## 초기화:
402 |
403 | ```python
404 | from API.Label import Label
405 |
406 | label = Label(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
407 | ```
408 |
409 | ## 라벨 가져오기:
410 |
411 | ```python
412 | target_label = label.get_label_list()
413 |
414 | print(target_label[0].color)
415 | ```
416 |
417 | ## 라벨 업데이트:
418 |
419 | ```python
420 | from Object.Label.RequestObject.UpdateLabelObject import UpdateLabelObject
421 |
422 | update_label_object = UpdateLabelObject('lbl-a001-00-000000000033511')
423 | update_label_object.name = "API TST"
424 |
425 | label.update_label(update_label_object)
426 | ```
427 |
428 | ## 라벨 REF(바로가기) 업데이트:
429 |
430 | ```python
431 | from Object.Label.RequestObject.UpdateLabelRefObject import UpdateLabelRefObject
432 |
433 | update_label_ref_object = UpdateLabelRefObject('1109868',
434 | 'lbl-a001-00-000000000033513',
435 | 'grp-a001-01-000000002601856',
436 | 'ADGROUP')
437 | label.update_label_ref(update_label_ref_object)
438 | ```
439 |
440 | # 타겟
441 |
442 | ## 초기화:
443 |
444 | ```python
445 | from API.Target import Target
446 | target = Target(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
447 | ```
448 |
449 | ## 타겟리스트 가져오기:
450 |
451 | ```python
452 | current_target = target.get_target_list('grp-a001-01-000000002412336')
453 | print(current_target[0].nccTargetId)
454 | ```
455 |
456 | ## 타겟리스트 업데이트:
457 |
458 | ```python
459 | 테스트 필요(Target Object 관련 구현)
460 | ```
461 |
462 | # IpExclusion
463 |
464 | ## 초기화
465 |
466 | ```python
467 | from API.IpExclusion import IpExclusion
468 | ip_exclusion = IpExclusion(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
469 | ```
470 |
471 | ## 차단된 아이피 리스트 가져오기:
472 |
473 | ```python
474 | target_ip_exclusion = ip_exclusion.get_ip_exclusion()
475 | print(target_ip_exclusion[0].filterIp)
476 | ```
477 |
478 | ## 차단할 아이피 추가하기:
479 |
480 | ```python
481 | from Object.IpExclusion.RequestObject.CreateIpExclusionObject import CreateIpExclusionObject
482 |
483 | create_ip_exclusion = CreateIpExclusion('1.234.56.7')
484 |
485 | ip_exclusion.create_ip_exclusion(create_ip_exclusion)
486 | ```
487 |
488 | ## 차단할 아이피 업데이트:
489 |
490 | ```python
491 | from Object.IpExclusion.RequestObject.UpdateIpExclusionObject import UpdateIpExclusionObject
492 |
493 | update_ip_exclusion = UpdateIpExclusionObject('1.222.34.5', '3487550')
494 | update_ip_exclusion.memo = "change test"
495 |
496 | ip_exclusion.update_ip_exclusion(update_ip_exclusion)
497 | ```
498 |
499 | ## 차단할 아이피 삭제하기:
500 |
501 | ```python
502 | ip_exclusion.delete_ip_exclusion('34.875.50.1')
503 | ```
504 |
505 | ## 차단할 아이피 리스트로 삭제하기:
506 |
507 | ```python
508 | ip_exclusion.delete_ip_exclusion_many(id list)
509 | ```
510 |
511 | # 비즈머니
512 |
513 | ## 초기화
514 |
515 | ```python
516 | from API.Bizmoney import Bizmoney
517 |
518 | biz_money = Bizmoney(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
519 | ```
520 |
521 | ## 비즈머니 조회:
522 |
523 | ```python
524 | current_biz_money = biz_money.get_biz_money()
525 | print(current_biz_money.bizmoney)
526 | ```
527 |
528 | ## 비즈머니 사용실적:
529 |
530 | ```python
531 | biz_money.get_biz_money_cost('20170301')
532 | ```
533 |
534 |
535 | # ManagedCustomerLinkList:
536 |
537 | ## 초기화
538 |
539 | ```python
540 | from API.ManagedCustomerLink import ManagedCustomerLink
541 |
542 | managed_customer_link = ManagedCustomerLink(
543 | client.BASE_URL,
544 | client.API_KEY,
545 | client.SECRET_KEY,
546 | client.CUSTOMER_ID
547 | )
548 | ```
549 |
550 | ## 리스트로 고객리스트 가져오기:
551 |
552 | ```python
553 | managed_customer_link.get_managed_customer_link_list(타입<선택사항>)
554 | ```
555 |
556 | # 대용량보고서:
557 |
558 | ## 초기화
559 |
560 | ```python
561 | from API.StatReport import StatReport
562 |
563 | stat_report = StatReport(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
564 | ```
565 |
566 | ## 대용량보고서목록보기:
567 |
568 | ```python
569 | current_stat_report = stat_report.get_stat_report_list()
570 | print(current_stat_report[0].statDt)
571 | ```
572 |
573 | ## 리스트고유번호로 대용량 보고서 목록보기:
574 |
575 | ```python
576 | current_stat_report = stat_report.get_stat_report('150381075')
577 | print(current_stat_report.statDt)
578 | ```
579 |
580 | ## 대용량 보고서 생성하기
581 |
582 | ```python
583 | from Object.StatReport.RequestObject.CreateStatReportObject import CreateStatReportObject
584 |
585 | create_stat_report_object = CreateStatReportObject('AD_CONVERSION_DETAIL', '2017-03-10T15:00:00Z')
586 |
587 | stat_report.create_stat_report(create_stat_report_object)
588 | ```
589 |
590 | ## 대용량 보고서 삭제하기:
591 |
592 | ```
593 | stat_report.delete_stat_reports('158389454')
594 | ```
595 |
596 | ## 아이디로 스탯가져오기:
597 |
598 | ```python
599 | fields = '["impCnt","clkCnt","salesAmt"]'
600 | target_stat_report = stat_report.get_stat_by_id('grp-a001-01-000000002412336',
601 | fields,
602 | '{"since":"2017-02-26","until":"2017-03-04"}',
603 | None, None, None)
604 | print(target_stat_report.data[0].dateEnd)
605 | ```
606 |
607 | ## 아이디 리스트로 가져오기:
608 |
609 | ```python
610 | fields = '["impCnt","clkCnt","salesAmt"]'
611 | target_stat_report = stat_report.get_stat_by_id('grp-a001-01-000000002412336,grp-a001-01-000000001235166',
612 | fields,
613 | '{"since":"2017-02-26","until":"2017-03-04"}',
614 | None, None, None)
615 | print(target_stat_report.data[0].dateEnd)
616 | ```
617 |
618 | ### 스탯타입으로 가져오기(테스트필):
619 |
620 | ``` 동작 여부 테스트 필요함 ```
621 |
622 | # MasterReport(광고정보일괄다운로드):
623 |
624 | ## 초기화:
625 |
626 | ```python
627 | from API.MasterReport import MasterReport
628 | master_report = MasterReport(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
629 | ```
630 |
631 | ## 다운로드 목록 불러오기:
632 |
633 | ```python
634 | current_master_report = master_report.get_master_report_list()
635 | print(current_master_report[0].managerLoginId)
636 | ```
637 |
638 | ## 아이디로 다운로드 정보 가져오기:
639 |
640 | ```python
641 | current_master_report = master_report.get_master_report_by_id('F9F0D4813CDB89E7F5907EAE79C7A0B2')
642 | print(current_master_report.registTime)
643 | ```
644 |
645 | ## 다운로드 요청 만들기:
646 |
647 | ```python
648 | from Object.MasterReport.RequestObject.CreateMasterReportObject import CreateMasterReportObject
649 |
650 | create_master_report_object = CreateMasterReportObject('Campaign', '2017-03-12T15:00:00Z')
651 | master_report.create_master_report(create_master_report_object)
652 | ```
653 |
654 | ## 전부삭제하기:
655 |
656 | ```python
657 | master_report.delete_master_report_all()
658 | ```
659 |
660 | ## 특정아이디로 삭제하기:
661 |
662 | ```python
663 | master_report.delete_master_report_by_id('3BE28582CCC31D199D2C583D191257B5')
664 | ```
665 |
666 | # 관계있는 키워드 정보들 보기(RelKwdStat):
667 |
668 | ## 초기화
669 |
670 | ```python
671 | from API.RelKwdStat import RelKwdStat
672 | rel_kwd_stat = RelKwdStat(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
673 | ```
674 |
675 | ## 관계있는 키워드 정보들 보기(RelKwdStat)
676 |
677 |
678 | ```python
679 | target_rel_kwd_stat = rel_kwd_stat.get_relkwd_stat_list('bsn-a001-00-000000000124029')
680 | print(target_rel_kwd_stat[0].monthlyAveMobileClkCnt)
681 | ```
682 |
683 | # Estimate
684 |
685 | ## 초기화
686 |
687 | ```python
688 | from API.Estimate import Estimate
689 |
690 | estimate = Estimate(client.BASE_URL, client.API_KEY, client.SECRET_KEY, client.CUSTOMER_ID)
691 | ```
692 |
693 | ## 순위로 비딩 평균 가져오기:
694 |
695 | ```python
696 | from Object.Estimate.RequestObject.GetAvgPositionBidObject import GetAvgPositionBidObject
697 | from Object.Estimate.sub.KeyAndPositionObject import KeyAndPositionObject
698 |
699 | key_and_position1 = KeyAndPositionObject('음주운전', 3)
700 | key_and_position2 = KeyAndPositionObject('보험', 3)
701 | get_avg_position_bid_object = GetAvgPositionBidObject('PC', [key_and_position1, key_and_position2])
702 |
703 | target_bidding_estimate = estimate.get_avg_position_bid_list('keyword', get_avg_position_bid_object)
704 | print(target_bidding_estimate[0].bid)
705 | ```
706 |
707 | ## 키워드로 평균 비딩 가져오기:
708 |
709 | ```python
710 | from Object.Estimate.RequestObject.GetMedianBidObject import GetMedianBidObject
711 |
712 | get_median_bid_object = GetMedianBidObject('PC', 'DAY', ['화분', '보험'])
713 |
714 | target_bid_estimate = estimate.get_median_bid_list('keyword', get_median_bid_object)
715 | print(target_bid_estimate[0].bid)
716 | ```
717 |
718 | ## 노출 최솟값 받아오기:
719 |
720 | ```python
721 | from Object.Estimate.RequestObject.GetExposureMiniBidObject import GetExposureMiniBidObject
722 | get_exposure_mini_bid_object = GetExposureMiniBidObject('PC', 'DAY', ['화분', '보험'])
723 |
724 | target_bid_estimate = estimate.get_exposure_mini_bid_list('keyword', get_exposure_mini_bid_object)
725 | print(target_bid_estimate[0].bid)
726 | ```
727 |
728 | ## 예상실적 받아오기(Median):
729 |
730 | ```python
731 | from Object.Estimate.RequestObject.GetExposureMiniBidObject import GetExposureMiniBidObject
732 |
733 | get_exposure_mini_bid_object = GetExposureMiniBidObject('PC', 'DAY', ['화분', '보험'])
734 |
735 | target_bid_estimate = estimate.get_exposure_mini_bid_list('keyword', get_exposure_mini_bid_object)
736 | print(target_bid_estimate[0].cicks)
737 | ```
738 |
739 | ## 예상실적 받아오기(Performance):
740 |
741 | ```python
742 | from Object.Estimate.RequestObject.GetPerformanceObject import GetPerformanceObject
743 |
744 | get_performance_object = GetPerformanceObject('BOTH', False, '보험', [500, 3000, 5000])
745 |
746 | target_bid_estimate = estimate.get_performance_list('keyword', get_performance_object)
747 | print(target_bid_estimate[1].clicks)
748 | ```
749 |
750 | ## 예상실적 한번에 많이 받아오기:
751 | ``` 동작 여부 테스트 필요함(NPLA, NPC 제외) ```
752 |
--------------------------------------------------------------------------------