<gh_stars>0
# Copyright 2017 Become Corp. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example code for
Service : KeywordEstimatorService
Operation: get
API Reference: https://github.com/yahoojp-marketing/sponsored-search-api-documents/blob/201901/docs/en/api_reference/services/KeywordEstimatorService.md

Generated by 'api_reference_example_generator.py' using code template 'examples/sample_template.py.template'
"""

import logging
import json

from yahooads import promotionalads

logging.basicConfig(level=logging.INFO)
# logging.getLogger('suds.client').setLevel(logging.DEBUG)
# logging.getLogger('suds.transport').setLevel(logging.DEBUG)


SERVICE = 'KeywordEstimatorService'
OPERATION = 'get'
OPERAND = {
  "accountId": "SAMPLE-ACCOUNT-ID", 
  "campaignEstimateRequest": {
    "campaignId": "SAMPLE-CAMPAIN-ID", 
    "adGroupEstimateRequests": [
      {
        "adGroupId": "SAMPLE-ADGROUP-ID", 
        "keywordEstimateRequests": {
          "keyword": {
            "text": "\u53e4\u7740", 
            "matchType": "PHRASE"
          }, 
          "isNegative": "FALSE", 
          "maxCpc": "5000"
        }, 
        "maxCpc": "800"
      }, 
      {
        "adGroupId": "SAMPLE-ADGROUP-ID", 
        "keywordEstimateRequests": {
          "keyword": {
            "text": "\u82b1\u706b\u3000\u590f", 
            "matchType": "EXACT"
          }, 
          "isNegative": "FALSE", 
          "maxCpc": "9000"
        }, 
        "maxCpc": "1000"
      }
    ], 
    "provinces": "JP-13", 
    "dailyBudget": "1000"
  }
}

"""
SAMPLE RESPONSE = {
  "rval": {
    "totalNumEntries": "2", 
    "Page.Type": "KeywordEstimatorPage", 
    "values": [
      {
        "operationSucceeded": "true", 
        "data": {
          "campaignId": "SAMPLE-CAMPAIN-ID", 
          "adGroupId": "SAMPLE-ADGROUP-ID", 
          "keyword": "\u53e4\u7740", 
          "min": {
            "clicks": "29.59", 
            "rank": "1.0", 
            "cpc": "32.11", 
            "cost": "1055.55", 
            "impressions": "3000.0", 
            "ctr": "0.0012"
          }, 
          "max": {
            "clicks": "36.16", 
            "rank": "1.1", 
            "cpc": "39.24", 
            "cost": "1290.12", 
            "impressions": "3100.0", 
            "ctr": "0.0022"
          }
        }
      }, 
      {
        "operationSucceeded": "true", 
        "data": {
          "campaignId": "SAMPLE-CAMPAIN-ID", 
          "adGroupId": "SAMPLE-ADGROUP-ID", 
          "keyword": "\u82b1\u706b\u3000\u590f", 
          "min": {
            "clicks": "11.59", 
            "rank": "1.0", 
            "cpc": "32.01", 
            "cost": "2055.55", 
            "impressions": "3000.0", 
            "ctr": "0.0012"
          }, 
          "max": {
            "clicks": "9999.16", 
            "rank": "1.1", 
            "cpc": "39.24", 
            "cost": "3290.12", 
            "impressions": "3100.0", 
            "ctr": "0.0022"
          }
        }
      }
    ]
  }
}
"""


def main():
    client = promotionalads.PromotionalAdsClient.LoadFromConfiguration()
    service = client.GetService(SERVICE)
    print("REQUEST : {}.{}\n{}".format(SERVICE, OPERATION, json.dumps(OPERAND, indent=2)))
    try:
        if OPERATION == "get":
            response = service.get(OPERAND)
        elif OPERATION.startswith("get"):
            get_method = getattr(service, OPERATION)
            response = get_method(OPERAND)
        elif OPERATION.startswith("mutate"):
            response = service.mutate(OPERAND)
        else:
            raise("Unknown Operation '{}'".format(OPERATION))
        print("RESPONSE :\n{}".format(response))
    except Exception as e:
        print("Exception at '{}' operations \n{}".format(SERVICE, e))
        raise e


if __name__ == '__main__':
    main()

# Copyright 2017 Become Corp. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Example code for
Service : KeywordEstimatorService
Operation: get
API Reference: https://github.com/yahoojp-marketing/sponsored-search-api-documents/blob/201901/docs/en/api_reference/services/KeywordEstimatorService.md

Generated by 'api_reference_example_generator.py' using code template 'examples/sample_template.py.template'
"""

import logging
import json

from yahooads import promotionalads

logging.basicConfig(level=logging.INFO)
# logging.getLogger('suds.client').setLevel(logging.DEBUG)
# logging.getLogger('suds.transport').setLevel(logging.DEBUG)


SERVICE = 'KeywordEstimatorService'
OPERATION = 'get'
OPERAND = {
  "accountId": "SAMPLE-ACCOUNT-ID", 
  "campaignEstimateRequest": {
    "campaignId": "SAMPLE-CAMPAIN-ID", 
    "adGroupEstimateRequests": [
      {
        "adGroupId": "SAMPLE-ADGROUP-ID", 
        "keywordEstimateRequests": {
          "keyword": {
            "text": "\u53e4\u7740", 
            "matchType": "PHRASE"
          }, 
          "isNegative": "FALSE", 
          "maxCpc": "5000"
        }, 
        "maxCpc": "800"
      }, 
      {
        "adGroupId": "SAMPLE-ADGROUP-ID", 
        "keywordEstimateRequests": {
          "keyword": {
            "text": "\u82b1\u706b\u3000\u590f", 
            "matchType": "EXACT"
          }, 
          "isNegative": "FALSE", 
          "maxCpc": "9000"
        }, 
        "maxCpc": "1000"
      }
    ], 
    "provinces": "JP-13", 
    "dailyBudget": "1000"
  }
}

"""
SAMPLE RESPONSE = {
  "rval": {
    "totalNumEntries": "2", 
    "Page.Type": "KeywordEstimatorPage", 
    "values": [
      {
        "operationSucceeded": "true", 
        "data": {
          "campaignId": "SAMPLE-CAMPAIN-ID", 
          "adGroupId": "SAMPLE-ADGROUP-ID", 
          "keyword": "\u53e4\u7740", 
          "min": {
            "clicks": "29.59", 
            "rank": "1.0", 
            "cpc": "32.11", 
            "cost": "1055.55", 
            "impressions": "3000.0", 
            "ctr": "0.0012"
          }, 
          "max": {
            "clicks": "36.16", 
            "rank": "1.1", 
            "cpc": "39.24", 
            "cost": "1290.12", 
            "impressions": "3100.0", 
            "ctr": "0.0022"
          }
        }
      }, 
      {
        "operationSucceeded": "true", 
        "data": {
          "campaignId": "SAMPLE-CAMPAIN-ID", 
          "adGroupId": "SAMPLE-ADGROUP-ID", 
          "keyword": "\u82b1\u706b\u3000\u590f", 
          "min": {
            "clicks": "11.59", 
            "rank": "1.0", 
            "cpc": "32.01", 
            "cost": "2055.55", 
            "impressions": "3000.0", 
            "ctr": "0.0012"
          }, 
          "max": {
            "clicks": "9999.16", 
            "rank": "1.1", 
            "cpc": "39.24", 
            "cost": "3290.12", 
            "impressions": "3100.0", 
            "ctr": "0.0022"
          }
        }
      }
    ]
  }
}
"""


def main():
    client = promotionalads.PromotionalAdsClient.LoadFromConfiguration()
    service = client.GetService(SERVICE)
    print("REQUEST : {}.{}\n{}".format(SERVICE, OPERATION, json.dumps(OPERAND, indent=2)))
    try:
        if OPERATION == "get":
            response = service.get(OPERAND)
        elif OPERATION.startswith("get"):
            get_method = getattr(service, OPERATION)
            response = get_method(OPERAND)
        elif OPERATION.startswith("mutate"):
            response = service.mutate(OPERAND)
        else:
            raise("Unknown Operation '{}'".format(OPERATION))
        print("RESPONSE :\n{}".format(response))
    except Exception as e:
        print("Exception at '{}' operations \n{}".format(SERVICE, e))
        raise e


if __name__ == '__main__':
    main()
# Copyright 2017 Become Corp. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #      http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. Example code for Service : KeywordEstimatorService Operation: get API Reference: https://github.com/yahoojp-marketing/sponsored-search-api-documents/blob/201901/docs/en/api_reference/services/KeywordEstimatorService.md  Generated by 'api_reference_example_generator.py' using code template 'examples/sample_template.py.template' # logging.getLogger('suds.client').setLevel(logging.DEBUG) # logging.getLogger('suds.transport').setLevel(logging.DEBUG) SAMPLE RESPONSE = {   "rval": {     "totalNumEntries": "2",      "Page.Type": "KeywordEstimatorPage",      "values": [       {         "operationSucceeded": "true",          "data": {           "campaignId": "SAMPLE-CAMPAIN-ID",            "adGroupId": "SAMPLE-ADGROUP-ID",            "keyword": "\u53e4\u7740",            "min": {             "clicks": "29.59",              "rank": "1.0",              "cpc": "32.11",              "cost": "1055.55",              "impressions": "3000.0",              "ctr": "0.0012"           },            "max": {             "clicks": "36.16",              "rank": "1.1",              "cpc": "39.24",              "cost": "1290.12",              "impressions": "3100.0",              "ctr": "0.0022"           }         }       },        {         "operationSucceeded": "true",          "data": {           "campaignId": "SAMPLE-CAMPAIN-ID",            "adGroupId": "SAMPLE-ADGROUP-ID",            "keyword": "\u82b1\u706b\u3000\u590f",            "min": {             "clicks": "11.59",              "rank": "1.0",              "cpc": "32.01",              "cost": "2055.55",              "impressions": "3000.0",              "ctr": "0.0012"           },            "max": {             "clicks": "9999.16",              "rank": "1.1",              "cpc": "39.24",              "cost": "3290.12",              "impressions": "3100.0",              "ctr": "0.0022"           }         }       }     ]   } }