baidu 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9b8eabdad5f511d630d6b08c547b3e36df32189
4
- data.tar.gz: efd30483fe5357b901b647919db740890c07844b
3
+ metadata.gz: e37178c85f6521e658f59cf8c8c3249e8e1492e7
4
+ data.tar.gz: ae7378591b0e813359a7deea907d1e8291174834
5
5
  SHA512:
6
- metadata.gz: 6b6fbc268eba762a1414ea0b2cffc6a319e55fd1c8a3e708c226483f4bd060ca118451b22c5466dc3ebd0cca33f3599e2890d4fd8b5131c3e298a2b4c46324c5
7
- data.tar.gz: 71c57fae2b36d8f91bad436dc4fa39fcdd8b5ed457f5b9ed4fe08f60285781a92ceb4c8f6c4774a736c1c059ae6183a9092a68cdf28d034490c022f151941e53
6
+ metadata.gz: 4d9a6405a089e4b2ddea08558ebfaeb2d0c17186d8730d865f2e79aae1191daca2f8cdbbccc5b2e3438fc2b5052b6b2faf1204079887825cd2ba5093e293f48b
7
+ data.tar.gz: c48d4431fe582fa0ce8c4567145598fad25c80a674520c7edea4b13298f3610f86de6141cb230730eb3efa6877894bb06a91f22d74c838ab1d3d4b6b1ad2c170
@@ -12,7 +12,6 @@ module Baidu
12
12
  @password = auth.password
13
13
  @token = auth.token
14
14
  @client = Savon.new("https://api.baidu.com/sem/sms/v3/#{classname}?wsdl")
15
- # Savon.new(@base_uri+service_name+'?wsdl')
16
15
  end
17
16
  def method_missing(name, *args, &block)
18
17
  options,debug = args[0],args[1]
@@ -39,7 +38,6 @@ module Baidu
39
38
  end
40
39
 
41
40
  name_request_sym = (name_tmp+'Request').to_sym #if %w(getCampaignByCampaignId getAllCampaign addCampaign updateCampaign deleteCampaign).include?name
42
- # puts name_request_sym
43
41
  name_response_sym = (name+'Response').snake_case.to_sym
44
42
  operation = make_operation(name)
45
43
  operation.header = operation_header
@@ -50,12 +48,7 @@ module Baidu
50
48
  puts operation.build if debug
51
49
  response = operation.call
52
50
  ap response if debug
53
- # ap response.failures if debug
54
- if response.failures
55
- raise response.failures.to_s
56
- else
57
- Baidu::Response.new(response,name_response_sym)
58
- end
51
+ Baidu::Response.new(response,name_response_sym)
59
52
  end
60
53
  def operations
61
54
  @client.operations(@service_name,@port_name)
@@ -88,9 +81,6 @@ module Baidu
88
81
  end
89
82
  end
90
83
 
91
- # def invalid_options?(options,necessary_options)
92
- # return true if necessary_options.any?{|necessary_option|!options.has_key?necessary_option}
93
- # end
94
84
  end
95
85
  end
96
86
  end
@@ -1,3 +1,3 @@
1
1
  module Baidu
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -1,34 +1,54 @@
1
1
  require 'spec_helper'
2
2
  describe Baidu::SEM::ReportService do
3
3
  subject{Baidu::SEM::ReportService.new($auth)}
4
- before :each do
5
- @options = {}
6
- @options[:performanceData] = [Baidu::SEM::PerformanceData::IMPRESSION, Baidu::SEM::PerformanceData::CLICK, Baidu::SEM::PerformanceData::CPC]
7
- @options[:startDate] = (Time.now - 24*3600).utc.iso8601
8
- @options[:endDate] = Time.now.utc.iso8601
9
- @options[:statIds] = $campaign_ids
10
- @options[:levelOfDetails] = Baidu::SEM::LevelOfDetails::CAMPAIGN
11
- @options[:reportType] = Baidu::SEM::ReportType::CAMPAIGN
12
- end
4
+ # before :each do
5
+ # end
13
6
 
14
- # describe "ReportService#getProfessionalReportId" do
15
- # @report_id = nil
16
- it "返回的id必须是32位数字和小写字母组合" do
17
- pending('need to rewrite')
18
- response = subject.getProfessionalReportId({:reportRequestType => @options}).body
19
- expect{ApiResponse.verify(response)}.not_to raise_error
20
- # report_id.class.should == String
21
- # report_id.should =~ /^[a-z0-9]{32}$/
22
- end
7
+ it 'should not raise error on #getProfessionalReportId #getReportState #getReportFileUrl series test' do
8
+ #getProfessionalReportId
9
+ options = {
10
+ :performanceData => [Baidu::SEM::PerformanceData::IMPRESSION, Baidu::SEM::PerformanceData::CLICK, Baidu::SEM::PerformanceData::CPC],
11
+ :startDate => (Time.now - 24*3600).utc.iso8601,
12
+ :endDate => Time.now.utc.iso8601,
13
+ :statIds => [$campaign_id],
14
+ :levelOfDetails => Baidu::SEM::LevelOfDetails::CAMPAIGN,
15
+ :reportType => Baidu::SEM::ReportType::CAMPAIGN
16
+ }
17
+ response = subject.getProfessionalReportId({:reportRequestType => options})
18
+ response.status.should == 0
19
+ response.desc.should == 'success'
20
+ response.quota.should == 2
21
+ response.rquota.should > 0
22
+ expect{ApiResponse.verify(response.body)}.not_to raise_error
23
+
24
+ #parse report_id
25
+ report_id = response.body[:report_id]
26
+
27
+ #getReportState
28
+ try_count = 0
29
+ loop do
30
+ response = subject.getReportState({:reportId => report_id})
31
+ response.status.should == 0
32
+ response.desc.should == 'success'
33
+ response.quota.should == 2
34
+ response.rquota.should > 0
35
+ expect{ApiResponse.verify(response.body)}.not_to raise_error
36
+ #verify is_generated status
37
+ is_generated = response.body[:is_generated]
38
+ break if is_generated == '3' or try_count > 10
39
+ sleep 1
40
+ try_count +=1
41
+ end
42
+
43
+
44
+ #getReportFileUrl
45
+ response = subject.getReportFileUrl({:reportId => report_id})
46
+ response.status.should == 0
47
+ response.desc.should == 'success'
48
+ response.quota.should == 2
49
+ response.rquota.should > 0
50
+ expect{ApiResponse.verify(response.body)}.not_to raise_error
23
51
 
24
- it "处理未过期有效id(1小时内产生的)应返回ReportState中的枚举值" do
25
- pending('need to rewrite')
26
- response = subject.getProfessionalReportId({:reportRequestType => @options}).body
27
- report_id = response[:report_id]
28
- response = subject.getReportState({:reportId=>report_id}).body
29
- expect{ApiResponse.verify(response)}.not_to raise_error
30
- # report_state = response[:report_state]
31
- # [Baidu::SEM::ReportState::PENDING,ReportState::DOING,ReportState::DONE].should include report_state
32
52
  end
33
53
 
34
54
  it "处理过期/无效id,应返回false" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: baidu
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - seoaqua
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2013-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler