bing-ads 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b9d2c1ad3927817aea14d5e9fbca74bc0fe8e215
4
+ data.tar.gz: 4164a03a0cc8d5c7b66cf617f9bed9199746f7ff
5
+ SHA512:
6
+ metadata.gz: ee7c3c7677cb20105428728338d5cb5aab2e2fbc6362dca244566f9b02d05b50e178f4e7c7e9d190f2714e1d63baaf34bef4195c5bd7bdf487dcea992205b511
7
+ data.tar.gz: 984bd0bcd26fbe5372c03cf49f10aae4199142aea929872a4ef01f3a4e59933b094771d113cd98170562cde3722cb4b9e4cea947bd8e21d0f8e911ae7109e1d1
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ # built gem files
15
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ bing-ads
@@ -0,0 +1 @@
1
+ 2.4.1
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.3
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in bing-ads.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Mohamed Osama Elnagdy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,280 @@
1
+ # Bing::Ads
2
+
3
+ A Ruby client for Bing Ads API that includes a proxy to all Bing Ads API web services and abstracts low level details of authentication with OAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'bing-ads'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install bing-ads
20
+
21
+ ## Usage
22
+
23
+ ### Campaign Management Service
24
+ #### Initialization
25
+ ```ruby
26
+ # Authentication token is not supported in sandbox, use `username` and `password` instead
27
+ # https://msdn.microsoft.com/en-us/library/dn277356.aspx
28
+
29
+ options = {
30
+ environment: :sandbox,
31
+ authentication_token: '39b290146bea6ce975c37cfc23',
32
+ developer_token: 'BBD37VB98',
33
+ customer_id: '21027149',
34
+ account_id: '5278183',
35
+ # client_settings: { logger: LOGGER::STDOUT }
36
+ }
37
+
38
+ service = Bing::Ads::API::V11::Services::CampaignManagement.new(options)
39
+ ```
40
+
41
+ #### Getting campaigns in account
42
+ ```ruby
43
+ account_id = 5278183
44
+ response = service.get_campaigns_by_account_id(account_id)
45
+ ```
46
+
47
+ #### Adding campaigns
48
+ ```ruby
49
+ account_id = 5278183
50
+ campaigns = [
51
+ {
52
+ budget_type: Bing::Ads::API::V11.constants.campaign_management.budget_limit_type.daily_budget_standard,
53
+ conversion_tracking_enabled: "false",
54
+ daily_budget: 2000,
55
+ description: 'Amsterdam-based global campaign',
56
+ name: '51 - Global - Chain - Mixed - N -en- Amsterdam - 100 - 26479',
57
+ status: Bing::Ads::API::V11.constants.campaign_management.campaign_status.paused,
58
+ time_zone: Bing::Ads::API::V11.constants.time_zones.amsterdam_berlin_bern_rome_stockholm_vienna
59
+ },
60
+ # ...
61
+ ]
62
+
63
+ response = service.add_campaigns(account_id, campaigns)
64
+ ```
65
+
66
+ #### Updating campaigns
67
+ ```ruby
68
+ account_id = 5278183
69
+ campaigns = [
70
+ {
71
+ id: 813721838,
72
+ budget_type: Bing::Ads::API::V11.constants.campaign_management.budget_limit_type.daily_budget_standard,
73
+ conversion_tracking_enabled: "false",
74
+ },
75
+ {
76
+ id: 813721849,
77
+ budget_type: Bing::Ads::API::V11.constants.campaign_management.budget_limit_type.daily_budget_standard,
78
+ conversion_tracking_enabled: "false",
79
+ },
80
+ # ...
81
+ ]
82
+
83
+ response = service.update_campaigns(account_id, campaigns)
84
+ ```
85
+
86
+ #### Deleting campaigns
87
+ ```ruby
88
+ account_id = 5278183
89
+ campaign_ids_to_delete = [813721838, 813721813, 813721911]
90
+ response = service.delete_campaigns(account_id, campaign_ids_to_delete)
91
+ ```
92
+
93
+ ---
94
+
95
+ #### Getting ad groups in campaign
96
+ ```ruby
97
+ campaign_id = 813721838
98
+ response = service.get_ad_groups_by_campaign_id(campaign_id)
99
+ ```
100
+
101
+ #### Getting ad groups in campaign by ids
102
+ ```ruby
103
+ campaign_id = 813721838
104
+ ad_group_ids = [9866221838, 9866221813, 9866221911]
105
+ response = service.get_ad_groups_by_ids(campaign_id, ad_group_ids)
106
+ ```
107
+
108
+ #### Adding ad groups to campaign
109
+ ```ruby
110
+ # You can add a maximum of 1,000 ad groups in a single call.
111
+ # Each campaign can have up to 20,000 ad groups.
112
+ campaign_id = 813721838
113
+ ad_groups = [
114
+ {
115
+ ad_distribution: Bing::Ads::API::V11.constants.campaign_management.ad_distribution.search, # required
116
+ ad_rotation: Bing::Ads::API::V11.constants.campaign_management.ad_rotation.optimize_for_clicks, # optional
117
+ bidding_scheme: Bing::Ads::API::V11.constants.campaign_management.bidding_scheme.inherit_from_parent, # optional
118
+ content_match_bid: 100, # optional
119
+ end_date: '31/12/2020',
120
+ status: Bing::Ads::API::V11.constants.campaign_management.ad_group_status.paused,
121
+ language: Bing::Ads::API::V11.constants.languages.english,
122
+ name: 'H=WHotelAmsterdam&AG=1723812002',
123
+ native_bid_adjustment: -50, # optional (-100 to 900)
124
+ remarketing_targeting_setting: Bing::Ads::API::V11.constants.campaign_management.remarketing_target_setting.bid_only, # optional
125
+ search_bid: 100, # optional
126
+ start_date: '5/7/2017',
127
+ },
128
+ # ...
129
+ # https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-adgroup.aspx
130
+ ]
131
+
132
+ response = service.add_ad_groups(campaign_id, ad_groups)
133
+ ```
134
+
135
+ #### Updating ad groups in campaign
136
+ ```ruby
137
+ # You can add a maximum of 1,000 ad groups in a single call.
138
+ # Each campaign can have up to 20,000 ad groups.
139
+ campaign_id = 813721838
140
+ ad_groups = [
141
+ {
142
+ id: 9866221838,
143
+ status: Bing::Ads::API::V11.constants.campaign_management.ad_group_status.active
144
+ },
145
+ # ...
146
+ ]
147
+
148
+ response = service.update_ad_groups(campaign_id, ad_groups)
149
+ ```
150
+
151
+ ---
152
+
153
+ #### Getting ads in ad group
154
+ ```ruby
155
+ ad_group_id = 9866221838
156
+ response = service.get_ads_by_ad_group_id(ad_group_id)
157
+ ```
158
+
159
+ #### Getting ads in ad group by ids
160
+ ```ruby
161
+ ad_group_id = 9866221838
162
+ ad_ids = [454873284248, 454873284249, 454873284250]
163
+ response = service.get_ads_by_ids(ad_group_id, ad_ids)
164
+ ```
165
+
166
+ #### Adding ads to ad group
167
+ ```ruby
168
+ # You can add a maximum of 50 ads in an ad group.
169
+ ad_group_id = 9866221838
170
+ expanded_text_ads = [
171
+ {
172
+ type: Bing::Ads::API::V11.constants.campaign_management.ad_types.expanded_text_ad, # ExpandedTextAd
173
+ path_1: 'Amsterdam',
174
+ path_2: 'Hotels',
175
+ text: 'Compare over 150 booking sites! Find guaranteed low hotel rates.',
176
+ title_part_1: 'Hotels in Amsterdam',
177
+ title_part_2: 'Best Deals. Book now',
178
+ final_urls: [
179
+ 'http://www.findhotel.net/Places/Amsterdam.htm'
180
+ ]
181
+ },
182
+ # ...
183
+ # Expanded text ads
184
+ # https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-expandedtextad.aspx
185
+ # For other ad types:
186
+ # https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-ad.aspx
187
+ ]
188
+
189
+ # Returns IDs of ads added to ad group
190
+ # { ad_ids: [], partial_errors: [] }
191
+ response = service.add_ads(ad_group_id, expanded_text_ads)
192
+ ```
193
+
194
+ #### Updating ads in ad group
195
+ ```ruby
196
+ ad_group_id = 9866221838
197
+ updated_expanded_text_ads = [
198
+ {
199
+ id: 454873284248,
200
+ final_urls: [
201
+ 'https://www.findhotel.net/Places/Amsterdam.htm'
202
+ ]
203
+ },
204
+ # ...
205
+ ]
206
+
207
+ response = service.update_ads(ad_group_id, updated_expanded_text_ads)
208
+ ```
209
+
210
+ ---
211
+
212
+ #### Getting keywords in ad group
213
+ ```ruby
214
+ ad_group_id = 9866221838
215
+ response = service.get_keywords_by_ad_group_id(ad_group_id)
216
+ ```
217
+
218
+ #### Getting keywords in ad group by ids
219
+ ```ruby
220
+ ad_group_id = 9866221838
221
+ keyword_ids = [234873284248, 234873284249, 234873284250]
222
+ response = service.get_keywords_by_ids(ad_group_id, keyword_ids)
223
+ ```
224
+
225
+ #### Adding keywords to ad group
226
+ ```ruby
227
+ ad_group_id = 9866221838
228
+ keywords = [
229
+ {
230
+ bidding_scheme: Bing::Ads::API::V11.constants.campaign_management.bidding_scheme.inherit_from_parent,
231
+ bid: 5,
232
+ # optional, ad final urls used if this is not set
233
+ final_urls: [
234
+ 'https://www.findhotel.net/Places/Amsterdam.htm?attrs=pet-friendly'
235
+ ],
236
+ match_type: Bing::Ads::API::V11.constants.campaign_management.match_types.exact, # also broad, content, phrase
237
+ status: Bing::Ads::API::V11.constants.campaign_management.keyword_statuses.active,
238
+ text: 'Pet-friendly Hotels in Amsterdam'
239
+ },
240
+ # ...
241
+ # https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-keyword.aspx
242
+ # https://msdn.microsoft.com/en-us/library/bing-ads-campaign-management-addkeywords.aspx
243
+ ]
244
+
245
+ # Returns IDs of keywords added to ad group
246
+ # { keyword_ids: [], partial_errors: [] }
247
+ response = service.add_keywords(ad_group_id, keywords)
248
+ ```
249
+
250
+ #### Updating keywords in ad group
251
+ ```ruby
252
+ ad_group_id = 9866221838
253
+ updated_keywords = [
254
+ {
255
+ id: 234873284248,
256
+ # updated attributes
257
+ },
258
+ # ...
259
+ ]
260
+
261
+ response = service.update_keywords(ad_group_id, updated_keywords)
262
+ ```
263
+
264
+ ### Bulk Service
265
+ Not yet supported
266
+
267
+ ### Customer Management Service
268
+ Not yet supported
269
+
270
+ ### Reporting Service
271
+ Not yet supported. Use: https://github.com/FindHotel/bing-ads-reporting
272
+
273
+ ## Development
274
+
275
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
276
+ To install this gem onto your local machine, run `bundle exec rake install`.
277
+
278
+ ## Contributing
279
+
280
+ Bug reports and pull requests are welcome on GitHub at https://github.com/FindHotel/bing-ads.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bing/ads"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bing/ads/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bing-ads"
8
+ spec.version = Bing::Ads::VERSION
9
+ spec.authors = ["oss92"]
10
+ spec.email = ["mohamed.o.alnagdy@gmail.com", "oss@findhotel.net"]
11
+ spec.license = 'MIT'
12
+
13
+ spec.summary = %q{Enhances the experience of developing Bing Ads applications with Ruby}
14
+ spec.description = %q{A Ruby client for Bing Ads API that includes a proxy to all Bing Ads API web services and abstracts low level details of authentication with OAuth2.}
15
+ spec.homepage = "https://github.com/FindHotel/bing-ads"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency 'savon', '~> 2.11'
25
+ spec.add_dependency 'activesupport', '~> 5.0'
26
+ spec.add_dependency 'persey', '~> 0.0.11'
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.15"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ spec.add_development_dependency "rspec", "~> 3.0"
31
+ end
@@ -0,0 +1,23 @@
1
+ require 'active_support/core_ext/string/inflections'
2
+ require 'active_support/core_ext/hash'
3
+ require 'active_support/hash_with_indifferent_access'
4
+ require 'date'
5
+ require 'persey'
6
+ require 'savon'
7
+
8
+ require 'bing/ads/api/errors'
9
+ require 'bing/ads/api/soap_client'
10
+ require 'bing/ads/api/v11'
11
+ require 'bing/ads/api/v11/constants'
12
+ require 'bing/ads/api/v11/services'
13
+
14
+ require 'bing/ads/utils'
15
+ require 'bing/ads/version'
16
+
17
+ module Bing
18
+ module Ads
19
+ # A Ruby client for Bing Ads API that includes a proxy to all
20
+ # Bing Ads API web services and abstracts low level details of
21
+ # authentication with OAuth.
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module Bing
2
+ module Ads
3
+ module API
4
+ module Errors
5
+ # Bing::Ads::API::Errors::AuthenticationParamsMissing
6
+ class AuthenticationParamsMissing < RuntimeError; end;
7
+
8
+ # Bing::Ads::API::Errors::AuthenticationTokenExpired
9
+ class AuthenticationTokenExpired < RuntimeError; end;
10
+
11
+ # Bing::Ads::API::Errors::LimitError
12
+ class LimitError < RuntimeError
13
+ def initialize(operation, limit, type)
14
+ super("can not #{operation} more than #{limit} #{type.to_s.humanize.downcase.pluralize} in a single call")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end