Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
Fix bugs and issues for bulk download
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantvithani committed Nov 28, 2018
1 parent 2ce0617 commit b55c103
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
1 change: 1 addition & 0 deletions lib/bing/ads/api/v12/data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
require_relative './data/campaign'
require_relative './data/keyword'
require_relative './data/report_request'
require_relative './data/bulk_request'
20 changes: 5 additions & 15 deletions lib/bing/ads/api/v12/data/bulk_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,11 @@ def prepare(bulk_request_row)
)
bulk_request_row[:download_entities] =
prepare_download_entities(
levels: bulk_request_row.delete(:levels),
levels: bulk_request_row.delete(:levels)
)
bulk_request_row.execpt!(:levels)
bulk_request_row.except!(:levels)
bulk_request = Bing::Ads::Utils.sort_keys(bulk_request_row, KEYS_ORDER)
namespace_identifier = Bing::Ads::API::V12::NAMESPACE_IDENTIFIER
{
get_campaigns_by_account_ids: Bing::Ads::Utils.camelcase_keys(bulk_request),
:attributes! => {
get_campaigns_by_account_ids: {
'xmlns:i' => 'http://www.w3.org/2001/XMLSchema-instance',
'i:type' => "#{namespace_identifier}:GetCampaignsByAccountIds"
}
}
}
Bing::Ads::Utils.camelcase_keys(bulk_request)
end

private
Expand All @@ -49,9 +40,8 @@ def prepare_account_ids(account_ids:)

def prepare_download_entities(levels:)
levels = %w[campaign] if levels.nil? || levels.empty?
return levels.map do |e|
Bing::Ads::API::V12.constants.bulk.download_entities.send(e)
end
entities = levels.map(&:pluralize).map(&:camelcase)
{ download_entity: entities }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bing/ads/api/v12/services/bulk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def download_campaigns_by_account_ids(options)
payload = Bing::Ads::API::V12::Data::BulkRequest.prepare(options)
response = call(__method__, payload)
response_body = response_body(response, __method__)
response_body.slice(:request_id, :download_url)
response_body.slice(:download_request_id)
end

# def download_campaigns_by_campaign_ids(options)
Expand Down

0 comments on commit b55c103

Please sign in to comment.