soapy_bing 0.3.0 → 0.3.1
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/lib/soapy_bing/ads/bulk/campaigns.rb +7 -3
 - data/lib/soapy_bing/ads.rb +3 -2
 - data/lib/soapy_bing/soap/response/get_bulk_download_status_response.rb +5 -0
 - data/lib/soapy_bing/version.rb +1 -1
 - data/spec/soapy_bing/soap/response/get_bulk_download_status_response_spec.rb +60 -0
 - metadata +4 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6769b40c74197462ce64b3858e1d9685a96a2afc
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e7cd2d208675f7318e838318e9ba3f7598a95d2c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9d9c735dccb584cc54a9de1a4827a481393f24a4ab7e086c0e3ac9770d9c0d272fbedda8d8da233e2fcb8a78132663be31a3c58be26c36e1ee5525dfb1e21990
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9c19239300bc2ee50a79a3c87cdb995d24a7e37b7e029c976cc735ce7683088faed872e76f383ba9397d76b46df3175a9fa36ef40ed696cd1d6347a82a9b6aec
         
     | 
| 
         @@ -4,15 +4,19 @@ module SoapyBing 
     | 
|
| 
       4 
4 
     | 
    
         
             
                module Bulk
         
     | 
| 
       5 
5 
     | 
    
         
             
                  class Campaigns
         
     | 
| 
       6 
6 
     | 
    
         
             
                    DEFAULT_ENTITIES = %w(CampaignTargets Ads).freeze
         
     | 
| 
       7 
     | 
    
         
            -
                     
     | 
| 
      
 7 
     | 
    
         
            +
                    DEFAULT_POLLING_SETTINGS = {
         
     | 
| 
      
 8 
     | 
    
         
            +
                      tries: 20,
         
     | 
| 
      
 9 
     | 
    
         
            +
                      sleep: ->(n) { n < 7 ? 2**n : 120 }
         
     | 
| 
      
 10 
     | 
    
         
            +
                    }.freeze
         
     | 
| 
       8 
11 
     | 
    
         
             
                    NotCompleted = Class.new(StandardError)
         
     | 
| 
       9 
12 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                    attr_reader :oauth_credentials, :account, :entities, :status
         
     | 
| 
      
 13 
     | 
    
         
            +
                    attr_reader :oauth_credentials, :account, :entities, :polling_settings, :status
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
15 
     | 
    
         
             
                    def initialize(options)
         
     | 
| 
       13 
16 
     | 
    
         
             
                      @oauth_credentials = options.fetch(:oauth_credentials)
         
     | 
| 
       14 
17 
     | 
    
         
             
                      @account = options.fetch(:account)
         
     | 
| 
       15 
18 
     | 
    
         
             
                      @entities = options.fetch(:entities) || DEFAULT_ENTITIES
         
     | 
| 
      
 19 
     | 
    
         
            +
                      @polling_settings = DEFAULT_POLLING_SETTINGS.merge(options.fetch(:polling_settings) || {})
         
     | 
| 
       16 
20 
     | 
    
         
             
                    end
         
     | 
| 
       17 
21 
     | 
    
         | 
| 
       18 
22 
     | 
    
         
             
                    def rows
         
     | 
| 
         @@ -36,7 +40,7 @@ module SoapyBing 
     | 
|
| 
       36 
40 
     | 
    
         
             
                    private
         
     | 
| 
       37 
41 
     | 
    
         | 
| 
       38 
42 
     | 
    
         
             
                    def wait_status_complete
         
     | 
| 
       39 
     | 
    
         
            -
                      Retryable.retryable( 
     | 
| 
      
 43 
     | 
    
         
            +
                      Retryable.retryable(polling_settings.merge(on: NotCompleted)) do
         
     | 
| 
       40 
44 
     | 
    
         
             
                        fetch_status
         
     | 
| 
       41 
45 
     | 
    
         
             
                        raise NotCompleted if status['RequestStatus'] != 'Completed'
         
     | 
| 
       42 
46 
     | 
    
         
             
                      end
         
     | 
    
        data/lib/soapy_bing/ads.rb
    CHANGED
    
    | 
         @@ -21,11 +21,12 @@ module SoapyBing 
     | 
|
| 
       21 
21 
     | 
    
         
             
                  )
         
     | 
| 
       22 
22 
     | 
    
         
             
                end
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
     | 
    
         
            -
                def bulk_campaigns(entities = nil)
         
     | 
| 
      
 24 
     | 
    
         
            +
                def bulk_campaigns(entities = nil, polling_settings = {})
         
     | 
| 
       25 
25 
     | 
    
         
             
                  Bulk::Campaigns.new(
         
     | 
| 
       26 
26 
     | 
    
         
             
                    oauth_credentials: oauth_credentials,
         
     | 
| 
       27 
27 
     | 
    
         
             
                    account: account,
         
     | 
| 
       28 
     | 
    
         
            -
                    entities: entities
         
     | 
| 
      
 28 
     | 
    
         
            +
                    entities: entities,
         
     | 
| 
      
 29 
     | 
    
         
            +
                    polling_settings: polling_settings
         
     | 
| 
       29 
30 
     | 
    
         
             
                  )
         
     | 
| 
       30 
31 
     | 
    
         
             
                end
         
     | 
| 
       31 
32 
     | 
    
         | 
| 
         @@ -3,7 +3,12 @@ module SoapyBing 
     | 
|
| 
       3 
3 
     | 
    
         
             
              module Soap
         
     | 
| 
       4 
4 
     | 
    
         
             
                module Response
         
     | 
| 
       5 
5 
     | 
    
         
             
                  class GetBulkDownloadStatusResponse < Base
         
     | 
| 
      
 6 
     | 
    
         
            +
                    StatusFailed = Class.new(StandardError)
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       6 
8 
     | 
    
         
             
                    def extract_payload
         
     | 
| 
      
 9 
     | 
    
         
            +
                      if response['RequestStatus'] == 'Failed'
         
     | 
| 
      
 10 
     | 
    
         
            +
                        raise StatusFailed, response['Errors'].to_s
         
     | 
| 
      
 11 
     | 
    
         
            +
                      end
         
     | 
| 
       7 
12 
     | 
    
         
             
                      response.slice('PercentComplete', 'RequestStatus', 'ResultFileUrl')
         
     | 
| 
       8 
13 
     | 
    
         
             
                    end
         
     | 
| 
       9 
14 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/soapy_bing/version.rb
    CHANGED
    
    
| 
         @@ -0,0 +1,60 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
            RSpec.describe SoapyBing::Soap::Response::GetBulkDownloadStatusResponse do
         
     | 
| 
      
 3 
     | 
    
         
            +
              subject(:response) { described_class.new(response_hash) }
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              describe '#payload' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                context 'in progress status response' do
         
     | 
| 
      
 7 
     | 
    
         
            +
                  let(:response_hash) do
         
     | 
| 
      
 8 
     | 
    
         
            +
                    {
         
     | 
| 
      
 9 
     | 
    
         
            +
                      'Envelope' => {
         
     | 
| 
      
 10 
     | 
    
         
            +
                        'Body' => {
         
     | 
| 
      
 11 
     | 
    
         
            +
                          'GetBulkDownloadStatusResponse' => {
         
     | 
| 
      
 12 
     | 
    
         
            +
                            'Errors' => nil,
         
     | 
| 
      
 13 
     | 
    
         
            +
                            'PercentComplete' => '42',
         
     | 
| 
      
 14 
     | 
    
         
            +
                            'RequestStatus' => 'InProgress',
         
     | 
| 
      
 15 
     | 
    
         
            +
                            'ResultFileUrl' => nil
         
     | 
| 
      
 16 
     | 
    
         
            +
                          }
         
     | 
| 
      
 17 
     | 
    
         
            +
                        }
         
     | 
| 
      
 18 
     | 
    
         
            +
                      }
         
     | 
| 
      
 19 
     | 
    
         
            +
                    }
         
     | 
| 
      
 20 
     | 
    
         
            +
                  end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  it 'returns status and percent complete' do
         
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(response.payload).to include(
         
     | 
| 
      
 24 
     | 
    
         
            +
                      'PercentComplete' => '42',
         
     | 
| 
      
 25 
     | 
    
         
            +
                      'RequestStatus' => 'InProgress',
         
     | 
| 
      
 26 
     | 
    
         
            +
                      'ResultFileUrl' => nil
         
     | 
| 
      
 27 
     | 
    
         
            +
                    )
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                context 'failed status response' do
         
     | 
| 
      
 32 
     | 
    
         
            +
                  let(:response_hash) do
         
     | 
| 
      
 33 
     | 
    
         
            +
                    {
         
     | 
| 
      
 34 
     | 
    
         
            +
                      'Envelope' => {
         
     | 
| 
      
 35 
     | 
    
         
            +
                        'Body' => {
         
     | 
| 
      
 36 
     | 
    
         
            +
                          'GetBulkDownloadStatusResponse' => {
         
     | 
| 
      
 37 
     | 
    
         
            +
                            'Errors' => [
         
     | 
| 
      
 38 
     | 
    
         
            +
                              'OperationError' => {
         
     | 
| 
      
 39 
     | 
    
         
            +
                                'Code' => '0',
         
     | 
| 
      
 40 
     | 
    
         
            +
                                'ErrorCode' => 'InternalError',
         
     | 
| 
      
 41 
     | 
    
         
            +
                                'Message' => 'An internal error has occurred'
         
     | 
| 
      
 42 
     | 
    
         
            +
                              }
         
     | 
| 
      
 43 
     | 
    
         
            +
                            ],
         
     | 
| 
      
 44 
     | 
    
         
            +
                            'PercentComplete' => '0',
         
     | 
| 
      
 45 
     | 
    
         
            +
                            'RequestStatus' => 'Failed',
         
     | 
| 
      
 46 
     | 
    
         
            +
                            'ResultFileUrl' => nil
         
     | 
| 
      
 47 
     | 
    
         
            +
                          }
         
     | 
| 
      
 48 
     | 
    
         
            +
                        }
         
     | 
| 
      
 49 
     | 
    
         
            +
                      }
         
     | 
| 
      
 50 
     | 
    
         
            +
                    }
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  it 'raises a StatusFailed exception with error message' do
         
     | 
| 
      
 54 
     | 
    
         
            +
                    expect { response.payload }.to raise_error(
         
     | 
| 
      
 55 
     | 
    
         
            +
                      described_class::StatusFailed, /An internal error has occurred/
         
     | 
| 
      
 56 
     | 
    
         
            +
                    )
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
    
        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.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.1
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - ad2games GmbH
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-09-19 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: erubis
         
     | 
| 
         @@ -284,6 +284,7 @@ files: 
     | 
|
| 
       284 
284 
     | 
    
         
             
            - spec/soapy_bing/soap/request/base_spec.rb
         
     | 
| 
       285 
285 
     | 
    
         
             
            - spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb
         
     | 
| 
       286 
286 
     | 
    
         
             
            - spec/soapy_bing/soap/response/base_spec.rb
         
     | 
| 
      
 287 
     | 
    
         
            +
            - spec/soapy_bing/soap/response/get_bulk_download_status_response_spec.rb
         
     | 
| 
       287 
288 
     | 
    
         
             
            - spec/soapy_bing/soap/response/payload_spec.rb
         
     | 
| 
       288 
289 
     | 
    
         
             
            - spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb
         
     | 
| 
       289 
290 
     | 
    
         
             
            - spec/soapy_bing/soap/response/report_status_spec.rb
         
     | 
| 
         @@ -352,6 +353,7 @@ test_files: 
     | 
|
| 
       352 
353 
     | 
    
         
             
            - spec/soapy_bing/soap/request/base_spec.rb
         
     | 
| 
       353 
354 
     | 
    
         
             
            - spec/soapy_bing/soap/request/poll_generate_report_request_spec.rb
         
     | 
| 
       354 
355 
     | 
    
         
             
            - spec/soapy_bing/soap/response/base_spec.rb
         
     | 
| 
      
 356 
     | 
    
         
            +
            - spec/soapy_bing/soap/response/get_bulk_download_status_response_spec.rb
         
     | 
| 
       355 
357 
     | 
    
         
             
            - spec/soapy_bing/soap/response/payload_spec.rb
         
     | 
| 
       356 
358 
     | 
    
         
             
            - spec/soapy_bing/soap/response/poll_generate_report_response_spec.rb
         
     | 
| 
       357 
359 
     | 
    
         
             
            - spec/soapy_bing/soap/response/report_status_spec.rb
         
     |