Sha256: c7e1fdc6df204d34574ebed6e2bf9fcc5108f7d70ce4c675fee2883da5138e9d
Contents?: true
Size: 1.32 KB
Versions: 2
Compression:
Stored size: 1.32 KB
Contents
# -*- coding:utf-8 -*- require 'ppc/api/sm/account' require 'ppc/api/sm/plan' require 'ppc/api/sm/bulk' require 'ppc/api/sm/group' require 'ppc/api/sm/keyword' require 'ppc/api/sm/report' require 'ppc/api/sm/creative' module PPC module API class Sm extend ::PPC::API def self.request_uri(param = {}) URI("https://e.sm.cn/api/#{param[:service]}/#{param[:method]}") end def self.process( response, key, &func) ''' Process Http response. If operation successes, return value of given keys. You can process the result using function &func, or do nothing by passing block {|x|x} =========================== @Output: resultType{ desc: boolean, failure: Array, result: Array } failure is the failures part of response\'s header result is the processed response body. ''' result = {} result[:succ] = response['header']['desc'][/(success|执行成功)/] ? true : false result[:failure] = response['header']['failures'] result[:result] = func[ response['body'][key] ] rescue nil result[:no_quota] = (response['header']['failures']['code'] == '8501') rescue false result[:rquota] = response["header"]["leftQuota"] rescue 0 result end # process end # Sm end # API end # PPC
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ppc-2.0.5 | lib/ppc/api/sm.rb |
ppc-2.0.4 | lib/ppc/api/sm.rb |