Skip to content

Commit

Permalink
add country
Browse files Browse the repository at this point in the history
  • Loading branch information
agretta committed Jan 29, 2025
1 parent 1e3adb6 commit fb4412b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/ttdrest/concerns/advertiser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def build_advertiser_data(partner_id, advertiser_id, name, params = {})
if !params[:domain_address].blank?
advertiser_data["DomainAddress"] = params[:domain_address]
end
if !params[:country].blank?
advertiser_data["Country"] = params[:country]
end
if !params[:currency_code].nil?
advertiser_data = advertiser_data.merge({"CurrencyCode" => params[:currency_code]})
end
Expand Down
42 changes: 41 additions & 1 deletion spec/ttdrest/concerns/advertiser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
let(:advertiser_id) { 'bar' }
let(:name) { 'Test Advertiser' }
let(:domain_address) { 'https://www.terminus.com' }
let(:country) { 'US' }

let(:params) do
{
domain_address: domain_address
domain_address: domain_address,
country: country
}
end

Expand Down Expand Up @@ -108,6 +110,44 @@
end
end
end

describe 'country' do
it 'determines the value of Country' do
expect(
client.build_advertiser_data(partner_id, advertiser_id, name, params)
).to include({ "Country" => 'US' })
end

context 'when nil' do
let(:country) { nil }

it 'does not contain the key at all' do
expect(
client.build_advertiser_data(partner_id, advertiser_id, name, params)
).to_not include("Country")
end
end

context 'when empty' do
let(:domain_address) { '' }

it 'does not contain the key at all' do
expect(
client.build_advertiser_data(partner_id, advertiser_id, name, params)
).to_not include("Country")
end
end

context 'when the key is not provided at all' do
let(:params) { {} }

it 'does not contain the key' do
expect(
client.build_advertiser_data(partner_id, advertiser_id, name, params)
).to_not include("Country")
end
end
end
end
end
end
Expand Down

0 comments on commit fb4412b

Please sign in to comment.