Sha256: bc12bf7febcd0dc95c81ff290a46d7b2667f8a98b456e4d5270e038d729800ff
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 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' result[:failure] = response['header']['failures'] if !response['body'].nil? && response['body'][key] result[:result] = func[ response['body'][key] ] end result[:no_quota] = is_no_quota(response['header']['failures'], '8501') result end # process def self.reverse_type( types, maps = @map ) types = [ types ] unless types.is_a? Array types.map do |item| maps.each{|m| item.filter_and_replace_key(m[0],m[1].to_s)} item end end end # Sm end # API end # PPC
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ppc-1.3.2 | lib/ppc/api/sm.rb |