soapy_bing 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/lib/soapy_bing/account.rb +1 -0
- data/lib/soapy_bing/ads/reports/base.rb +2 -1
- data/lib/soapy_bing/ads/reports/campaign_performance_report.rb +1 -0
- data/lib/soapy_bing/ads/reports/parsers/csv_parser.rb +2 -1
- data/lib/soapy_bing/ads/reports/parsers.rb +1 -0
- data/lib/soapy_bing/ads/reports.rb +1 -0
- data/lib/soapy_bing/ads.rb +1 -0
- data/lib/soapy_bing/helpers/class_name.rb +1 -0
- data/lib/soapy_bing/helpers/ssl_version.rb +1 -0
- data/lib/soapy_bing/helpers.rb +1 -0
- data/lib/soapy_bing/oauth_credentials.rb +6 -6
- data/lib/soapy_bing/param_guard.rb +2 -1
- data/lib/soapy_bing/soap/request/base.rb +1 -0
- data/lib/soapy_bing/soap/request/poll_generate_report_request.rb +6 -5
- data/lib/soapy_bing/soap/request/submit_generate_report_request.rb +3 -2
- data/lib/soapy_bing/soap/request.rb +1 -0
- data/lib/soapy_bing/soap/response/base.rb +1 -0
- data/lib/soapy_bing/soap/response/payload.rb +2 -1
- data/lib/soapy_bing/soap/response/poll_generate_report_response.rb +1 -0
- data/lib/soapy_bing/soap/response/report_status.rb +1 -0
- data/lib/soapy_bing/soap/response/submit_generate_report_response.rb +1 -0
- data/lib/soapy_bing/soap/response.rb +1 -0
- data/lib/soapy_bing/soap/template_renderer.rb +1 -0
- data/lib/soapy_bing/soap.rb +1 -0
- data/lib/soapy_bing/version.rb +2 -1
- data/lib/soapy_bing.rb +1 -0
- data/lib/tasks/console.rake +1 -0
- data/lib/tasks/coverage.rake +1 -0
- data/lib/tasks/spec.rake +1 -0
- data/soapy_bing.gemspec +1 -0
- data/spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb +1 -0
- data/spec/integration/soapy_bing/oauth_credentials_spec.rb +1 -0
- data/spec/simplecov_setup.rb +1 -0
- data/spec/soapy_bing/account_spec.rb +1 -0
- data/spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb +1 -0
- data/spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb +2 -1
- data/spec/soapy_bing/ads_spec.rb +1 -0
- data/spec/soapy_bing/helpers/class_name_spec.rb +1 -0
- data/spec/soapy_bing/helpers/ssl_version_spec.rb +1 -0
- data/spec/soapy_bing/oauth_credentials_spec.rb +1 -0
- data/spec/soapy_bing/param_guard_spec.rb +1 -0
- data/spec/soapy_bing/soap/request/base_spec.rb +1 -0
- data/spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb +5 -4
- data/spec/soapy_bing/soap/response/base_spec.rb +1 -0
- data/spec/soapy_bing/soap/response/payload_spec.rb +2 -1
- data/spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb +1 -0
- data/spec/soapy_bing/soap/response/report_status_spec.rb +1 -0
- data/spec/soapy_bing/soap/response/submit_generate_report_response_spec.rb +1 -0
- data/spec/soapy_bing/soap/template_renderer_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/dotenv.rb +1 -0
- data/spec/support/vcr.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75bb3e63ec854d756a3d216b9ddcd0ad8742aa80
|
4
|
+
data.tar.gz: 596a7c5f4d3c5f1f15611d7e98fbea0b0498d985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44998a329b39fda44bff367952ee29ca0e0f5a1df9ee15b38fe8ded6137a98e3b152273cefe8c87c453ff9fd118f7716abe627c2ef94ed44708888f770ace2f1
|
7
|
+
data.tar.gz: 11fe49b2c467a48dacfdc2d9b68cb296fc00759fefa4c867425fa531a0a19476220a661a10503439398adf0bbd125abdec78cab37733e8c88e6900ed5047673e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.1
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/soapy_bing/account.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'ostruct'
|
2
3
|
require 'uri'
|
3
4
|
require 'httparty'
|
@@ -35,7 +36,7 @@ module SoapyBing
|
|
35
36
|
|
36
37
|
def parser_class
|
37
38
|
class_name = "#{settings.format.upcase}Parser".to_sym
|
38
|
-
|
39
|
+
raise UnknownParserError, class_name unless Parsers.constants.include?(class_name)
|
39
40
|
Parsers.const_get class_name
|
40
41
|
end
|
41
42
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'csv'
|
2
3
|
|
3
4
|
module SoapyBing
|
@@ -17,7 +18,7 @@ module SoapyBing
|
|
17
18
|
def rows
|
18
19
|
@rows ||= begin
|
19
20
|
header, *body = extract_csv_payload
|
20
|
-
|
21
|
+
raise FormatError if body.size != payload_rows_number
|
21
22
|
body.map { |row| header.zip(row).to_h }
|
22
23
|
end
|
23
24
|
end
|
data/lib/soapy_bing/ads.rb
CHANGED
data/lib/soapy_bing/helpers.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'httparty'
|
2
3
|
|
3
4
|
module SoapyBing
|
4
5
|
class OauthCredentials
|
5
6
|
class TokenRefreshError < StandardError; end
|
6
7
|
|
7
|
-
TOKEN_URL = 'https://login.live.com/oauth20_token.srf'
|
8
|
+
TOKEN_URL = 'https://login.live.com/oauth20_token.srf'
|
8
9
|
|
9
10
|
attr_reader :client_id, :client_secret, :refresh_token, :token_url
|
10
11
|
|
@@ -24,11 +25,10 @@ module SoapyBing
|
|
24
25
|
|
25
26
|
def request_access_token
|
26
27
|
resp = HTTParty.post(token_url, body: access_token_params)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
28
|
+
|
29
|
+
raise TokenRefreshError unless resp.code == 200
|
30
|
+
|
31
|
+
resp['access_token']
|
32
32
|
end
|
33
33
|
|
34
34
|
def access_token_params
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module SoapyBing
|
2
3
|
class ParamGuard
|
3
4
|
class ParamRequiredError < StandardError; end
|
@@ -8,7 +9,7 @@ module SoapyBing
|
|
8
9
|
end
|
9
10
|
|
10
11
|
def require!(name)
|
11
|
-
local_options.fetch(name, ENV[env_var_name(name)]) ||
|
12
|
+
local_options.fetch(name, ENV[env_var_name(name)]) || raise(ParamRequiredError, err_msg(name))
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module SoapyBing
|
2
3
|
module Soap
|
3
4
|
module Request
|
@@ -6,12 +7,12 @@ module SoapyBing
|
|
6
7
|
class PendingStatusError < StandardError; end
|
7
8
|
class PollingTimeoutError < StandardError; end
|
8
9
|
|
9
|
-
API_BASE_URL = 'https://reporting.api.bingads.microsoft.com'
|
10
|
+
API_BASE_URL = 'https://reporting.api.bingads.microsoft.com'
|
10
11
|
API_VERSION = 9
|
11
12
|
API_ENDPOINT =
|
12
|
-
"#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc"
|
13
|
+
"#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc"
|
13
14
|
|
14
|
-
POLLING_TRIES =
|
15
|
+
POLLING_TRIES = 100
|
15
16
|
|
16
17
|
def perform
|
17
18
|
Retryable.retryable(tries: POLLING_TRIES, on: PendingStatusError) { poll! }
|
@@ -23,8 +24,8 @@ module SoapyBing
|
|
23
24
|
|
24
25
|
def poll!
|
25
26
|
response = Response::PollGenerateReportResponse.new(post(API_ENDPOINT))
|
26
|
-
|
27
|
-
|
27
|
+
raise PendingStatusError if response.pending?
|
28
|
+
raise FailedStatusError if response.error?
|
28
29
|
response
|
29
30
|
end
|
30
31
|
end
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module SoapyBing
|
2
3
|
module Soap
|
3
4
|
module Request
|
4
5
|
class SubmitGenerateReportRequest < Base
|
5
|
-
API_BASE_URL = 'https://reporting.api.bingads.microsoft.com'
|
6
|
+
API_BASE_URL = 'https://reporting.api.bingads.microsoft.com'
|
6
7
|
API_VERSION = 9
|
7
8
|
API_ENDPOINT =
|
8
|
-
"#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc"
|
9
|
+
"#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc"
|
9
10
|
|
10
11
|
def perform
|
11
12
|
Response::SubmitGenerateReportResponse.new(post(API_ENDPOINT))
|
data/lib/soapy_bing/soap.rb
CHANGED
data/lib/soapy_bing/version.rb
CHANGED
data/lib/soapy_bing.rb
CHANGED
data/lib/tasks/console.rake
CHANGED
data/lib/tasks/coverage.rake
CHANGED
data/lib/tasks/spec.rake
CHANGED
data/soapy_bing.gemspec
CHANGED
data/spec/simplecov_setup.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'json'
|
2
3
|
require 'csv'
|
3
4
|
|
@@ -20,7 +21,7 @@ RSpec.describe SoapyBing::Ads::Reports::Parsers::CSVParser do
|
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
context 'on malformed CSV data
|
24
|
+
context 'on malformed CSV data' do
|
24
25
|
let(:csv_data) { '"co", "' }
|
25
26
|
|
26
27
|
it 'throws exception CSV::MalformedCSVError' do
|
data/spec/soapy_bing/ads_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
RSpec.describe SoapyBing::Soap::Request::PollGenerateReportRequest do
|
2
3
|
describe '#perform' do
|
3
4
|
let(:response_body) do
|
@@ -16,13 +17,13 @@ RSpec.describe SoapyBing::Soap::Request::PollGenerateReportRequest do
|
|
16
17
|
end
|
17
18
|
|
18
19
|
let(:pending_response_body) do
|
19
|
-
response_body['Envelope']['Body']['PollGenerateReportResponse']
|
20
|
-
|
20
|
+
response_body['Envelope']['Body']['PollGenerateReportResponse'] \
|
21
|
+
['ReportRequestStatus']['Status'] = 'Pending'
|
21
22
|
response_body
|
22
23
|
end
|
23
24
|
let(:successful_response_body) do
|
24
|
-
response_body['Envelope']['Body']['PollGenerateReportResponse']
|
25
|
-
|
25
|
+
response_body['Envelope']['Body']['PollGenerateReportResponse'] \
|
26
|
+
['ReportRequestStatus']['Status'] = 'Success'
|
26
27
|
response_body
|
27
28
|
end
|
28
29
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
RSpec.describe SoapyBing::Soap::Response::Payload do
|
2
3
|
before do
|
3
4
|
stub_const(
|
@@ -12,7 +13,7 @@ RSpec.describe SoapyBing::Soap::Response::Payload do
|
|
12
13
|
|
13
14
|
describe '#payload' do
|
14
15
|
it 'memoize #extract_payload value' do
|
15
|
-
|
16
|
+
expect(subject).to receive(:extract_payload).once.and_return(true)
|
16
17
|
2.times { subject.payload }
|
17
18
|
end
|
18
19
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/dotenv.rb
CHANGED
data/spec/support/vcr.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soapy_bing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ad2games GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
|
-
rubygems_version: 2.
|
276
|
+
rubygems_version: 2.5.1
|
277
277
|
signing_key:
|
278
278
|
specification_version: 4
|
279
279
|
summary: Simple client for the Bing Ads APIs
|