soapy_bing 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +1 -0
  4. data/Rakefile +1 -0
  5. data/lib/soapy_bing/account.rb +1 -0
  6. data/lib/soapy_bing/ads/reports/base.rb +2 -1
  7. data/lib/soapy_bing/ads/reports/campaign_performance_report.rb +1 -0
  8. data/lib/soapy_bing/ads/reports/parsers/csv_parser.rb +2 -1
  9. data/lib/soapy_bing/ads/reports/parsers.rb +1 -0
  10. data/lib/soapy_bing/ads/reports.rb +1 -0
  11. data/lib/soapy_bing/ads.rb +1 -0
  12. data/lib/soapy_bing/helpers/class_name.rb +1 -0
  13. data/lib/soapy_bing/helpers/ssl_version.rb +1 -0
  14. data/lib/soapy_bing/helpers.rb +1 -0
  15. data/lib/soapy_bing/oauth_credentials.rb +6 -6
  16. data/lib/soapy_bing/param_guard.rb +2 -1
  17. data/lib/soapy_bing/soap/request/base.rb +1 -0
  18. data/lib/soapy_bing/soap/request/poll_generate_report_request.rb +6 -5
  19. data/lib/soapy_bing/soap/request/submit_generate_report_request.rb +3 -2
  20. data/lib/soapy_bing/soap/request.rb +1 -0
  21. data/lib/soapy_bing/soap/response/base.rb +1 -0
  22. data/lib/soapy_bing/soap/response/payload.rb +2 -1
  23. data/lib/soapy_bing/soap/response/poll_generate_report_response.rb +1 -0
  24. data/lib/soapy_bing/soap/response/report_status.rb +1 -0
  25. data/lib/soapy_bing/soap/response/submit_generate_report_response.rb +1 -0
  26. data/lib/soapy_bing/soap/response.rb +1 -0
  27. data/lib/soapy_bing/soap/template_renderer.rb +1 -0
  28. data/lib/soapy_bing/soap.rb +1 -0
  29. data/lib/soapy_bing/version.rb +2 -1
  30. data/lib/soapy_bing.rb +1 -0
  31. data/lib/tasks/console.rake +1 -0
  32. data/lib/tasks/coverage.rake +1 -0
  33. data/lib/tasks/spec.rake +1 -0
  34. data/soapy_bing.gemspec +1 -0
  35. data/spec/integration/soapy_bing/ads/reports/campaign_performance_report_spec.rb +1 -0
  36. data/spec/integration/soapy_bing/oauth_credentials_spec.rb +1 -0
  37. data/spec/simplecov_setup.rb +1 -0
  38. data/spec/soapy_bing/account_spec.rb +1 -0
  39. data/spec/soapy_bing/ads/reports/campaign_performance_report_spec.rb +1 -0
  40. data/spec/soapy_bing/ads/reports/parsers/csv_parser_spec.rb +2 -1
  41. data/spec/soapy_bing/ads_spec.rb +1 -0
  42. data/spec/soapy_bing/helpers/class_name_spec.rb +1 -0
  43. data/spec/soapy_bing/helpers/ssl_version_spec.rb +1 -0
  44. data/spec/soapy_bing/oauth_credentials_spec.rb +1 -0
  45. data/spec/soapy_bing/param_guard_spec.rb +1 -0
  46. data/spec/soapy_bing/soap/request/base_spec.rb +1 -0
  47. data/spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb +5 -4
  48. data/spec/soapy_bing/soap/response/base_spec.rb +1 -0
  49. data/spec/soapy_bing/soap/response/payload_spec.rb +2 -1
  50. data/spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb +1 -0
  51. data/spec/soapy_bing/soap/response/report_status_spec.rb +1 -0
  52. data/spec/soapy_bing/soap/response/submit_generate_report_response_spec.rb +1 -0
  53. data/spec/soapy_bing/soap/template_renderer_spec.rb +1 -0
  54. data/spec/spec_helper.rb +1 -0
  55. data/spec/support/dotenv.rb +1 -0
  56. data/spec/support/vcr.rb +1 -0
  57. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6caab3cc4168d35e762dc72a01dacb1ae785db50
4
- data.tar.gz: 0ca68c7d3d8878d44b45ac511aefa17f968371dd
3
+ metadata.gz: 75bb3e63ec854d756a3d216b9ddcd0ad8742aa80
4
+ data.tar.gz: 596a7c5f4d3c5f1f15611d7e98fbea0b0498d985
5
5
  SHA512:
6
- metadata.gz: 28c1bbfbf10a09dff58afee0bc9f741beed3b3fd6a9d0e54044cde72b34abb568400a855d880a3c79b310ed1e4e23ac1230ae3934d53044b81ca7998ff03da19
7
- data.tar.gz: da4aa75a352a6fb9cb15b9116d79c01fb59a4d07cbf89eeb766708d78a27f6407777848ae20cc725935fe3aaa45f2f3ddbec63d71cb93213268ec1e750667b3e
6
+ metadata.gz: 44998a329b39fda44bff367952ee29ca0e0f5a1df9ee15b38fe8ded6137a98e3b152273cefe8c87c453ff9fd118f7716abe627c2ef94ed44708888f770ace2f1
7
+ data.tar.gz: 11fe49b2c467a48dacfdc2d9b68cb296fc00759fefa4c867425fa531a0a19476220a661a10503439398adf0bbd125abdec78cab37733e8c88e6900ed5047673e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.3.1
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  gemspec
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rubygems'
2
3
  require 'bundler/setup'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  class Account
3
4
  attr_reader :developer_token, :account_id, :customer_id
@@ -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
- fail UnknownParserError, class_name unless Parsers.constants.include?(class_name)
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 'date'
2
3
 
3
4
  module SoapyBing
@@ -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
- fail FormatError if body.size != payload_rows_number
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
@@ -1 +1,2 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/ads/reports/parsers/csv_parser'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/ads/reports/parsers'
2
3
  require 'soapy_bing/ads/reports/base'
3
4
  require 'soapy_bing/ads/reports/campaign_performance_report'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/ads/reports'
2
3
 
3
4
  module SoapyBing
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  module Helpers
3
4
  module ClassName
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'openssl'
2
3
 
3
4
  module SoapyBing
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/helpers/class_name'
2
3
  require 'soapy_bing/helpers/ssl_version'
@@ -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'.freeze
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
- if resp.code == 200
28
- resp['access_token']
29
- else
30
- fail TokenRefreshError
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)]) || fail(ParamRequiredError, err_msg(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
  require 'httparty'
2
3
 
3
4
  module SoapyBing
@@ -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'.freeze
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".freeze
13
+ "#{API_BASE_URL}/Api/Advertiser/Reporting/V#{API_VERSION}/ReportingService.svc"
13
14
 
14
- POLLING_TRIES = 40
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
- fail PendingStatusError if response.pending?
27
- fail FailedStatusError if response.error?
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'.freeze
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".freeze
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))
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/soap/request/base'
2
3
  require 'soapy_bing/soap/request/submit_generate_report_request'
3
4
  require 'soapy_bing/soap/request/poll_generate_report_request'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  module Soap
3
4
  module Response
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  module Soap
3
4
  module Response
@@ -7,7 +8,7 @@ module SoapyBing
7
8
  end
8
9
 
9
10
  def extract_payload
10
- fail NotImplementedError
11
+ raise NotImplementedError
11
12
  end
12
13
  end
13
14
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  module Soap
3
4
  module Response
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  module Soap
3
4
  module Response
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
3
  module Soap
3
4
  module Response
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/soap/response/payload'
2
3
  require 'soapy_bing/soap/response/report_status'
3
4
  require 'soapy_bing/soap/response/base'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'ostruct'
2
3
  require 'erubis'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'soapy_bing/soap/template_renderer'
2
3
  require 'soapy_bing/soap/request'
3
4
  require 'soapy_bing/soap/response'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SoapyBing
2
- VERSION = '0.0.4'.freeze
3
+ VERSION = '0.0.5'
3
4
  end
data/lib/soapy_bing.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'httparty'
2
3
  require 'retryable'
3
4
  require 'active_support'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  desc 'Start the IRB console (short-cut alias: "c")'
2
3
  task :console do
3
4
  sh 'irb -I . -I ./lib -I ./spec -r ./spec/spec_helper.rb'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  desc 'Run specs and collect code coverage'
2
3
  task :coverage do
3
4
  ENV['COVERAGE'] = 'true'
data/lib/tasks/spec.rake CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rspec/core/rake_task'
2
3
  RSpec::Core::RakeTask.new(:spec)
3
4
 
data/soapy_bing.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'soapy_bing/version'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'json'
2
3
 
3
4
  RSpec.describe SoapyBing::Ads::Reports::CampaignPerformanceReport do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::OauthCredentials do
2
3
  describe '#access_token' do
3
4
  context 'on successful respose', :integration do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  if ENV['CI'] || ENV['COVERAGE']
2
3
  require 'simplecov'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Account do
2
3
  describe '#initialize' do
3
4
  subject { described_class.new(account) }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'date'
2
3
 
3
4
  RSpec.describe SoapyBing::Ads::Reports::CampaignPerformanceReport do
@@ -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 'do
24
+ context 'on malformed CSV data' do
24
25
  let(:csv_data) { '"co", "' }
25
26
 
26
27
  it 'throws exception CSV::MalformedCSVError' do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Ads do
2
3
  let(:oauth) do
3
4
  { client_id: 'foo', client_secret: 'bar', refresh_token: 'baz' }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Helpers::ClassName do
2
3
  describe '#class_name' do
3
4
  subject do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Helpers::SSLVersion do
2
3
  describe '#ssl_version' do
3
4
  subject { stub_const('MyClass', Class.new.include(described_class)).new.ssl_version }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::OauthCredentials do
2
3
  describe '#initialize' do
3
4
  subject { described_class.new(credentials) }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::ParamGuard do
2
3
  describe '#require!' do
3
4
  let(:param_guard) { described_class.new(options, env_namespace: 'MY') }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Soap::Request::Base do
2
3
  let(:req_context) { { foo: 'Bar' } }
3
4
  subject { described_class.new(context: req_context) }
@@ -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']['ReportRequestStatus']
20
- .merge!('Status' => 'Pending')
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']['ReportRequestStatus']
25
- .merge!('Status' => 'Success')
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::Base do
2
3
  before { stub_const('MyCustomResponse', Class.new(described_class) {}) }
3
4
  let(:response_body) { 'Some response body' }
@@ -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
- expect_any_instance_of(MyCustomResponse).to receive(:extract_payload).once.and_return(true)
16
+ expect(subject).to receive(:extract_payload).once.and_return(true)
16
17
  2.times { subject.payload }
17
18
  end
18
19
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Soap::Response::PollGenerateReportResponse do
2
3
  let(:url) { 'http://my-site.com' }
3
4
  let(:response_hash) do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Soap::Response::ReportStatus do
2
3
  before do
3
4
  stub_const(
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Soap::Response::SubmitGenerateReportResponse do
2
3
  let(:request_id) { 'foobarbazqux' }
3
4
  let(:response_hash) do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  RSpec.describe SoapyBing::Soap::TemplateRenderer do
2
3
  describe '::TEMPLATE_PATH' do
3
4
  let(:files) { Dir.glob(File.join(described_class::TEMPLATE_PATH, '*.erb.xml')) }
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'simplecov_setup'
2
3
 
3
4
  require 'bundler/setup'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'dotenv'
2
3
 
3
4
  Dotenv.load('.env.local', '.env')
data/spec/support/vcr.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cgi'
2
3
  require 'vcr'
3
4
  require 'active_support/core_ext/hash/conversions'
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
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: 2015-11-17 00:00:00.000000000 Z
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.4.5.1
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