diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index a854911..9affb48 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,7 @@
+* 6.0.0
+ Remove curb in favor of httparty
+ BREAKING CHANGE: Remove InsightService
+
* 5.0.0
Fully using API V13
BREAKING CHANGE: AdInsightService class removed, use ReportingService instead
diff --git a/README.md b/README.md
index 17f7b13..fbc2b00 100644
--- a/README.md
+++ b/README.md
@@ -31,72 +31,9 @@ service = BingAdsReporting::BulkService.new({
})
```
-#### Insight Service(actual AdInsight Serive) - [Bing Ads API reference for Bulk Service](https://docs.microsoft.com/en-us/advertising/ad-insight-service/ad-insight-service-reference?view=bingads-13)
-
-```ruby
-service = BingAdsReporting::InsightService.new(auth_settings, logger, request_class)
-```
-
-##### Request Class example
-
-For which report in AdInsightService API, which one has different SOAP request.
-
-Bellow an example of the request for [Auction Insight report](https://docs.microsoft.com/en-us/advertising/ad-insight-service/getauctioninsightdata?view=bingads-13#request-soap).
-
-```ruby
-class AuctionInsightRequest
- attr_reader :period, :options
-
- def initialize(period, options)
- @period = period
- @options = options
- end
-
- def self.message(period, options)
- new(period, options).message
- end
-
- def message
- {
- 'EntityType' => options[:entity_type],
- 'SearchParameters' => {
- 'SearchParameter' => {
- 'EndDate' => {
- 'Day' => '10',
- 'Month' => '02',
- 'Year' => '2018'
- },
- 'StartDate' => {
- 'Day' => '10',
- 'Month' => '01',
- 'Year' => '2018'
- },
- '@i:type' => 'tns:DateRangeSearchParameter'
- }
- },
- '@xsi:type' => 'tns:DateRangeSearchParameter'
- }
- end
-end
-```
-
-#### AdInsight Service(DEPRECATED)
-
-Use `ReportingService` instead.
-
-```ruby
-service = BingAdsReporting::AdInsightService.new({
- developerToken: '',
- applicationToken: '',
- authenticationToken: '',
- :accountId: '',
- customerId: ''
-})
-```
-
## Create report and get it's ID
-### Ad Reporting Service
+### Reporting Service
```ruby
period = Datebox::Period.new('2013-07-01', '2013-07-03')
@@ -117,7 +54,6 @@ id = service.generate_report({report_type: 'DownloadCampaignsByAccountIds'
download_entities: ['Keywords']},
{})
```
-
### Get Report
Get report URL for download by report ID if it's ready
@@ -131,17 +67,3 @@ or get its content by ID (also once ready)
```ruby
service.report_body(id) if service.report_ready?(id)
```
-
-## InsightService
-
-### Get Auction Insight Results
-
-```ruby
-result = service.generate_report({report_type: AuctionInsightData, entity_type: 'Account'})
-```
-
-### Get Auction Insight Results for Keywords
-
-```ruby
-result = service.generate_report({report_type: AuctionInsightData, entity_type: 'Account', entity_ids: [1, 2, 3]})
-```
diff --git a/bing-ads-reporting.gemspec b/bing-ads-reporting.gemspec
index bc6a175..1bd19e6 100644
--- a/bing-ads-reporting.gemspec
+++ b/bing-ads-reporting.gemspec
@@ -16,10 +16,10 @@ Gem::Specification.new do |gem|
gem.test_files = [] # gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ['lib']
- gem.add_dependency 'curb', '~> 0.9.10'
- gem.add_dependency 'datebox', '~> 0.5.0'
- gem.add_dependency 'oauth2', '~> 1.4.1'
- gem.add_dependency 'savon', '~> 2.12.0'
+ gem.add_dependency 'httparty', '~> 0.17.0'
+ gem.add_dependency 'datebox', '~> 0.5.0'
+ gem.add_dependency 'oauth2', '~> 1.4.1'
+ gem.add_dependency 'savon', '~> 2.12.0'
gem.add_development_dependency 'reek', '~> 5.4.0'
gem.add_development_dependency 'rspec', '~> 3.4.0'
diff --git a/lib/bing-ads-reporting/downloader.rb b/lib/bing-ads-reporting/downloader.rb
index 1b47590..a845fdc 100644
--- a/lib/bing-ads-reporting/downloader.rb
+++ b/lib/bing-ads-reporting/downloader.rb
@@ -14,14 +14,8 @@ def self.fetch_report(report_url)
def fetch_report
logger.debug "Downloading Bing report from: #{report_url}"
- curl.perform
- curl.body_str
- end
-
- private
-
- def curl
- @curl ||= Curl::Easy.new(report_url)
+ response = HTTParty.get(report_url)
+ response.body
end
end
end
diff --git a/lib/bing-ads-reporting/insight_service.rb b/lib/bing-ads-reporting/insight_service.rb
deleted file mode 100644
index 34a7064..0000000
--- a/lib/bing-ads-reporting/insight_service.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-require_relative 'service_core'
-
-module BingAdsReporting
- class InsightService < ServiceCore
- WDSL = 'https://adinsight.api.bingads.microsoft.com/Api/Advertiser/AdInsight/v13/AdInsightService.svc?singleWsdl'.freeze
- FAILED_STATUS = 'Error'.freeze
- SUCCESS_STATUS = 'Success'.freeze
- attr_reader :request_class
-
- def initialize(settings, logger = nil, request_class)
- @request_class = request_class
-
- super(settings, logger)
- end
-
- def generate_report(report_settings, report_params)
- options = default_options(report_settings).merge(report_params)
- response = call_operation(options)
-
- response_result(response, options)
- end
-
- private
-
- def wdsl
- WDSL
- end
-
- def failed_status
- FAILED_STATUS
- end
-
- def success_status
- SUCCESS_STATUS
- end
-
- def response_result(response, options)
- tag = response_tag(options)
- response.body[tag]
- end
-
- def response_tag(options)
- "#{report_operation(options)}_response".to_sym
- end
-
- def report_operation(options)
- BingHelper.camel_case_to_sym(options[:report_type])
- end
-
- def generate_report_message(options)
- period = options[:period]
-
- request_class.message(period, options)
- end
- end
-end
diff --git a/lib/bing-ads-reporting/version.rb b/lib/bing-ads-reporting/version.rb
index 1263c55..669f899 100644
--- a/lib/bing-ads-reporting/version.rb
+++ b/lib/bing-ads-reporting/version.rb
@@ -1,3 +1,3 @@
module BingAdsReporting
- VERSION = '5.0.0'.freeze
+ VERSION = '6.0.0'.freeze
end
diff --git a/lib/bing_ads_reporting.rb b/lib/bing_ads_reporting.rb
index f1457c6..654e101 100644
--- a/lib/bing_ads_reporting.rb
+++ b/lib/bing_ads_reporting.rb
@@ -1,7 +1,6 @@
require_relative 'bing-ads-reporting/bing_helper'
require_relative 'bing-ads-reporting/bing_settings'
require_relative 'bing-ads-reporting/soap_error_helper'
-require_relative 'bing-ads-reporting/insight_service'
require_relative 'bing-ads-reporting/bulk_service'
require_relative 'bing-ads-reporting/reporting_service'
require_relative 'bing-ads-reporting/version'
diff --git a/spec/bing-ads-reporting/ad_insight_service_spec.rb b/spec/bing-ads-reporting/ad_insight_service_spec.rb
deleted file mode 100644
index e49cb73..0000000
--- a/spec/bing-ads-reporting/ad_insight_service_spec.rb
+++ /dev/null
@@ -1,192 +0,0 @@
-require 'spec_helper'
-require 'savon'
-require 'nori'
-require 'datebox'
-require 'curl'
-
-describe BingAdsReporting::AdInsightService do
- let(:dev_token) { '0000000123DF' }
- let(:app_token) { '0000000SD313' }
- let(:auth_token) { 'MS12399031jj' }
- let(:account_id) { '123458' }
- let(:customer_id) { '6667434' }
- let(:report_id) { '30000003027034680' }
- let(:period) { Datebox::Period.new('2019-06-28', '2019-06-30') }
- let(:nori) { Nori.new(strip_namespaces: true, convert_tags_to: ->(tag) { tag.snakecase.to_sym }) }
- let(:service) { described_class.new(account_settings) }
- let(:encoded_response) { nori.parse(xml_response)[:envelope][:body] }
- let(:response_double) { instance_double('Savon::Response', header: {}, body: encoded_response) }
- let(:account_settings) do
- {
- developerToken: dev_token,
- applicationToken: app_token,
- authenticationToken: auth_token,
- accountId: account_id,
- customerId: customer_id
- }
- end
-
- before do
- allow_any_instance_of(Savon::Client).to receive(:call) { response_double }
- end
-
- describe '#generate_report' do
- subject(:report_test) { service.generate_report(account_settings, period: period) }
-
- context 'when requesting report submission' do
- let(:xml_response) do
- '
-
-
- d012a57e-8d84-456f-9562-b223a6d6a348
-
-
-
-
- 30000003027034680
-
-
- '
- end
-
- it { expect(report_test).to eq(report_id) }
- end
-
- context 'when request error happen' do
- let(:error_hash) do
- {
- fault: {
- faultcode: 's:Server',
- faultstring: 'Invalid client data. Check the SOAP fault details for more information',
- detail: {
- api_fault_detail: {
- :tracking_id => 'c782ddaa-b735-404e-8111-b61f1776ae71',
- :batch_errors => nil,
- :operation_errors => {
- operation_error: {
- code: '2010',
- details: nil,
- error_code: 'InvalidCustomDateRangeEnd',
- message: 'The specified report time contains an invalid custom date range end.
- Please submit a report request with valid start and end dates for the custom date range.'
- }
- },
- :@xmlns => 'https://bingads.microsoft.com/Reporting/v12',
- :"@xmlns:i" => 'http://www.w3.org/2001/XMLSchema-instance'
- }
- }
- }
- }
- end
- let(:response_double) { instance_double('Savon::Response', body: '') }
- let(:savon_exception) do
- Savon::SOAPFault.new(response_double, nori)
- end
-
- before do
- allow_any_instance_of(Savon::SOAPFault).to receive(:to_s).and_return('Error Message')
- allow_any_instance_of(Savon::SOAPFault).to receive(:to_hash) { error_hash }
- allow_any_instance_of(Savon::Client).to receive(:call).and_raise(savon_exception)
- end
-
- it { expect { report_test }.to raise_exception(Savon::SOAPFault) }
- end
-
- context 'when the token is expired' do
- let(:error_hash) do
- {
- fault: {
- faultcode: 's:Server',
- faultstring: 'Invalid client data. Check the SOAP fault details for more information',
- detail: {
- api_fault_detail: {
- :tracking_id => 'c782ddaa-b735-404e-8111-b61f1776ae71',
- :batch_errors => nil,
- :operation_errors => {
- operation_error: {
- code: '2010',
- details: nil,
- error_code: 'AuthenticationTokenExpired',
- message: 'Authentication token is expired.'
- }
- },
- :@xmlns => 'https://bingads.microsoft.com/Reporting/v12',
- :"@xmlns:i" => 'http://www.w3.org/2001/XMLSchema-instance'
- }
- }
- }
- }
- end
- let(:response_double) { instance_double('Savon::Response', body: '') }
- let(:savon_exception) do
- Savon::SOAPFault.new(response_double, nori)
- end
-
- before do
- allow_any_instance_of(Savon::SOAPFault).to receive(:to_s).and_return('Error Message')
- allow_any_instance_of(Savon::SOAPFault).to receive(:to_hash) { error_hash }
- allow_any_instance_of(Savon::Client).to receive(:call).and_raise(savon_exception)
- end
-
- it do
- expect { report_test }.to(
- raise_exception(
- BingAdsReporting::AuthenticationTokenExpired,
- 'Authentication token is expired.'
- )
- )
- end
- end
- end
-
- describe '#report_ready?' do
- let(:id) { '123123' }
-
- subject(:report_test) { service.report_ready?(id) }
-
- context 'when the report is ready' do
- let(:xml_response) { BingSoapHelper.poll_report_ready }
-
- it { is_expected.to be true }
- end
-
- context 'when the report fails' do
- let(:xml_response) { BingSoapHelper.poll_report_error }
-
- it { expect { report_test }.to raise_exception(RuntimeError) }
- end
- end
-
- describe '#report_body' do
- subject(:report_body) { service.report_body(report_id) }
-
- before do
- allow_any_instance_of(Curl::Easy).to receive(:perform).and_return(true)
- allow_any_instance_of(Curl::Easy).to receive(:body_str).and_return('REPORT_DATA')
- end
-
- context 'when report is ready' do
- let(:xml_response) { BingSoapHelper.poll_report_ready }
-
- it { is_expected.to eq('REPORT_DATA') }
- end
-
- context 'when report is not ready' do
- let(:xml_response) { BingSoapHelper.poll_report_without_url }
-
- it { is_expected.to eq(nil) }
- end
-
- context 'when report is not ready' do
- let(:xml_response) { BingSoapHelper.poll_report_not_ready }
-
- it { expect { report_body }.to raise_exception(RuntimeError) }
- end
-
- context 'when report download fails' do
- let(:xml_response) { BingSoapHelper.poll_report_error }
-
- it { expect { report_body }.to raise_exception(RuntimeError) }
- end
- end
-end
diff --git a/spec/bing-ads-reporting/bulk_service_spec.rb b/spec/bing-ads-reporting/bulk_service_spec.rb
index 1340009..aacbdad 100644
--- a/spec/bing-ads-reporting/bulk_service_spec.rb
+++ b/spec/bing-ads-reporting/bulk_service_spec.rb
@@ -2,7 +2,7 @@
require 'savon'
require 'nori'
require 'datebox'
-require 'curl'
+require 'httparty'
describe BingAdsReporting::BulkService do
let(:dev_token) { '0000000123DF' }
@@ -75,8 +75,7 @@
subject(:report_body) { service.report_body(report_id) }
before do
- allow_any_instance_of(Curl::Easy).to receive(:perform).and_return(true)
- allow_any_instance_of(Curl::Easy).to receive(:body_str).and_return('REPORT_DATA')
+ allow_any_instance_of(HTTParty::Response).to receive(:body).and_return('REPORT_DATA')
end
context 'when report is ready' do
diff --git a/spec/bing-ads-reporting/reporting_service_spec.rb b/spec/bing-ads-reporting/reporting_service_spec.rb
index 188f07c..5646533 100644
--- a/spec/bing-ads-reporting/reporting_service_spec.rb
+++ b/spec/bing-ads-reporting/reporting_service_spec.rb
@@ -2,7 +2,7 @@
require 'savon'
require 'nori'
require 'datebox'
-require 'curl'
+require 'httparty'
describe BingAdsReporting::ReportingService do
let(:dev_token) { '0000000123DF' }
@@ -75,8 +75,7 @@
subject(:report_body) { service.report_body(report_id) }
before do
- allow_any_instance_of(Curl::Easy).to receive(:perform).and_return(true)
- allow_any_instance_of(Curl::Easy).to receive(:body_str).and_return('REPORT_DATA')
+ allow_any_instance_of(HTTParty::Response).to receive(:body).and_return('REPORT_DATA')
end
context 'when report is ready' do
diff --git a/spec/support/bing_soap_helper.rb b/spec/support/bing_soap_helper.rb
index 66f0029..4610502 100644
--- a/spec/support/bing_soap_helper.rb
+++ b/spec/support/bing_soap_helper.rb
@@ -26,9 +26,7 @@ def self.poll_report_ready
-
- https://dvsrdl.api.bingads.microsoft.com/ReportDownload/Download.aspx?q=FBqXVvpqWWQ26Tg3Qk2Kj%2fuF%2fl%2f1TpU3%2f9yGytBUbumcfnHv6tJ%2fcrS5QmcZBcCofYr5SHnz547sx8oc7GcT3pLQ%2fV7wVOy74goZiTpEBszi924kJTtnhDhQHFfcoQTdscNpCq7H%2frM842mw9HyxntlNWNi1o5aWENXh1jHk55LWz3l7D7Foe82izhbtNHf%2f%2buGXBqN2%2bLjhsN6b3Wyybfz6oQaZ%2b2Mm27NH2rMPbwUslFIJvpfDzEnG3CLtEJ2Bb1scQ8vCRtvJPOhcS3ZrTHs39lIM0YAP78J%2bkGu2Xji9HhAHb7yK%2fDJh7o64rPa%2f1PwbZdxPUXUU4FkVFLSyM07nQ9F3osQ2cxvdO%2fAfm4HI0hi5K2JfxiiBCvyN2R0%2b7VQ6vUQw%2b0HWmdMar6Z8k1quZjfWR%2fU9CeCNkkx%2bL2uwtkMhIEomTiXdoLB5o5dAQSM7rOsnZ5jh%2f2AC1AMO%2bWRRLfAAN2lEN8o6cYWEF4duDg2BgRHuV6xSorFcxExUUxRty%2b0pNb2cL%2bdXPuK5tbaDfVls0iKbbMhZs%2fSBYMOVOyfXBbGDyXDIb5o709iPgTjgGHKn4Gnqqf0LTvC1SBcwuZVdbaLt9MXZ5XsktoQ76kIWF%2bmAuFw2tWbR4yScxgWvVqLsDiH%2fIalb95QGErZxypT9xPumGRgNaQ6wzaNrmXcgZWZjr%2fW1wbwGy0WvP%2bkyWOHIBnFiktnt2zhCYaEb7VCfs0n8wQFCwM%2bvDaiUSk7rO%2foHP%2f%2b1lx0H7R76gtNde4BhBlpIeDsO%2bUwizcDPSWUF3rqj2TwygYjNAWH8
-
+ https://api.bingads.microsoft.com/ReportDownload/Download.aspx?q=FBqXV8
Success
@@ -130,9 +128,7 @@ def self.poll_bulk_service_completed
100
Completed
-
- https://bingadsappsstorageprod.blob.core.windows.net/bulkdownloadresultfiles/bulkfile.tsv
-
+ https://bingadsappsstorageprod.blob.core.windows.net/bulkdownloadresultfiles/bulkfile.tsv
'