bing_ads_ruby_sdk 1.5.2 → 1.6
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/Gemfile +1 -1
- data/README.md +84 -14
- data/bing_ads_ruby_sdk.gemspec +1 -1
- data/changelog.md +5 -0
- data/lib/bing_ads_ruby_sdk/oauth2/fs_store.rb +1 -1
- data/lib/bing_ads_ruby_sdk/string_utils.rb +2 -0
- data/lib/bing_ads_ruby_sdk/tasks/bing_ads_ruby_sdk.rake +5 -1
- data/lib/bing_ads_ruby_sdk/version.rb +1 -1
- data/lib/bing_ads_ruby_sdk.rb +5 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10064130886df96745297db7c95d5482b3127563383425554e7ee722e36e17ff
|
4
|
+
data.tar.gz: ffd8833ecabc68e2d6ac7760891399070bbffb6f644f79b7f71275270e5e9c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5dad795cb0dba423784ad86926c397740b083201bfb9c327f04763e94f34149860d857989b2e1386008ed19d96317a9ea91655b1267f39017b32fd14d34b9388
|
7
|
+
data.tar.gz: b5d31b8cd1fad4f64b91debaead3daf4878d427b5d5d17639247e732eedc125a406d16968a1dd5a3d1fc4402059268d5cffa05ee6a0c96ae153836246f232154
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -16,7 +16,8 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install bing_ads_ruby_sdk
|
18
18
|
|
19
|
-
##
|
19
|
+
## Usage
|
20
|
+
### Getting Started
|
20
21
|
|
21
22
|
In order to use Microsoft's advertising API you need to
|
22
23
|
[get your API credentials from MS](https://learn.microsoft.com/en-us/advertising/guides/get-started?view=bingads-13).
|
@@ -33,7 +34,6 @@ bin/rake bing_token:get['credentials.json',YOUR_DEVELOPER_TOKEN,YOUR_CLIENT_ID,Y
|
|
33
34
|
bin/rake bing_token:get['credentials.json',ABC1234,3431b6d0-a2ac-48e1-a1c5-1d0b82f3187f,SECRETVALUEHERE]
|
34
35
|
```
|
35
36
|
|
36
|
-
|
37
37
|
Then to use the api:
|
38
38
|
```ruby
|
39
39
|
store = ::BingAdsRubySdk::OAuth2::FsStore.new('my_token.json')
|
@@ -44,6 +44,22 @@ api = BingAdsRubySdk::Api.new(
|
|
44
44
|
)
|
45
45
|
```
|
46
46
|
|
47
|
+
### Configuration
|
48
|
+
```ruby
|
49
|
+
BingAdsRubySdk.configure do |conf|
|
50
|
+
conf.log = true
|
51
|
+
conf.logger.level = Logger::DEBUG
|
52
|
+
conf.pretty_print_xml = true
|
53
|
+
# to filter sensitive data before logging
|
54
|
+
conf.filters = ["AuthenticationToken", "DeveloperToken"]
|
55
|
+
|
56
|
+
# Optionally allow ActiveSupport::Notifications to be emitted by Excon.
|
57
|
+
# These notifications can then be sent on to your profiling system
|
58
|
+
# conf.instrumentor = ActiveSupport::Notifications
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
### Account creation and management
|
47
63
|
If you want to create an account using the API:
|
48
64
|
```ruby
|
49
65
|
api.customer_management.signup_customer(
|
@@ -54,7 +70,7 @@ api.customer_management.signup_customer(
|
|
54
70
|
```
|
55
71
|
|
56
72
|
Otherwise you can [use existing account IDs as explained here](https://learn.microsoft.com/en-us/advertising/guides/get-started?view=bingads-13#get-ids),
|
57
|
-
or use the `customer_management` endpoint as explained
|
73
|
+
or use the `customer_management` endpoint as explained above.
|
58
74
|
|
59
75
|
Once you have your MS Advertising customer and account ids:
|
60
76
|
```ruby
|
@@ -80,22 +96,76 @@ The methods implemented contain additional code to ease data manipulation but an
|
|
80
96
|
|
81
97
|
```
|
82
98
|
|
99
|
+
### Reporting
|
100
|
+
You can generate the report following the
|
101
|
+
[process recommended by Microsoft](https://learn.microsoft.com/en-us/advertising/guides/request-download-report?view=bingads-13):
|
102
|
+
|
103
|
+
That would mean coding something like this:
|
83
104
|
|
84
|
-
## Configure the gem
|
85
105
|
```ruby
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
106
|
+
submission_response = api.reporting
|
107
|
+
.call(:submit_generate_report,
|
108
|
+
account_performance_report_request: {
|
109
|
+
exclude_report_header: true,
|
110
|
+
exclude_report_footer: true,
|
111
|
+
exclude_column_headers: true,
|
112
|
+
format: "Csv",
|
113
|
+
aggregation: "Daily",
|
114
|
+
filter: nil,
|
115
|
+
columns: [
|
116
|
+
{
|
117
|
+
account_performance_report_column: "TimePeriod"
|
118
|
+
},
|
119
|
+
{
|
120
|
+
account_performance_report_column: "AccountId"
|
121
|
+
},
|
122
|
+
{
|
123
|
+
account_performance_report_column: "DeviceType"
|
124
|
+
},
|
125
|
+
{
|
126
|
+
account_performance_report_column: "Clicks"
|
127
|
+
}
|
128
|
+
],
|
129
|
+
scope: {
|
130
|
+
# Your account ID here
|
131
|
+
account_ids: [{long: 1000000}]
|
132
|
+
},
|
133
|
+
time: {
|
134
|
+
custom_date_range_start: {
|
135
|
+
day: 7,
|
136
|
+
month: 5,
|
137
|
+
year: 2023
|
138
|
+
},
|
139
|
+
custom_date_range_end: {
|
140
|
+
day: 8,
|
141
|
+
month: 5,
|
142
|
+
year: 2023
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
)
|
147
|
+
|
148
|
+
report_request_id = submission_response.fetch(:report_request_id)
|
149
|
+
|
150
|
+
# Then you can poll the API to check the status of the report generation
|
151
|
+
poll_response = api.reporting.call(:poll_generate_report, report_request_id: report_request_id)
|
152
|
+
|
153
|
+
# When it is ready you can download it
|
154
|
+
report_request_status = poll_response.fetch(:report_request_status)
|
155
|
+
|
156
|
+
report_generation_status = report_request_status[:status].downcase.to_sym
|
157
|
+
# => One of these: :pending, :error, :success
|
158
|
+
|
159
|
+
if report_generation_status == :success
|
160
|
+
url = report_request_status[:report_download_url]
|
161
|
+
# => The URL to download the report (with the library of your choice)
|
96
162
|
end
|
97
163
|
```
|
98
164
|
|
165
|
+
🛈 Report request example [here in the API docs](https://learn.microsoft.com/en-us/advertising/reporting-service/accountperformancereportrequest?view=bingads-13)
|
166
|
+
|
167
|
+
🛈 Hint: convert parameter names from PascalCase to snake_case when consulting the API docs
|
168
|
+
|
99
169
|
## Development
|
100
170
|
You can run `bin/console` for an interactive prompt that will allow you to experiment.
|
101
171
|
|
data/bing_ads_ruby_sdk.gemspec
CHANGED
@@ -4,7 +4,7 @@ require "bing_ads_ruby_sdk/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "bing_ads_ruby_sdk"
|
7
|
-
spec.required_ruby_version = ">=
|
7
|
+
spec.required_ruby_version = ">= 3"
|
8
8
|
|
9
9
|
spec.version = BingAdsRubySdk::VERSION
|
10
10
|
spec.authors = %w[Effilab developers]
|
data/changelog.md
CHANGED
@@ -7,6 +7,8 @@ module BingAdsRubySdk
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.snakize(string)
|
10
|
+
raise "Unexpected string length : #{string.length} for string '#{string[0..200]}...'" if string.length > 1000
|
11
|
+
|
10
12
|
string.gsub(MULTIPLE_CAPSREGEX, MATCHING_PATTERN)
|
11
13
|
.gsub(SPLIT_REGEX, MATCHING_PATTERN)
|
12
14
|
.tr("-", "_")
|
data/lib/bing_ads_ruby_sdk.rb
CHANGED
@@ -10,6 +10,9 @@ require "bing_ads_ruby_sdk/string_utils"
|
|
10
10
|
require "bing_ads_ruby_sdk/railtie" if defined?(Rails)
|
11
11
|
|
12
12
|
module BingAdsRubySdk
|
13
|
+
TYPE_KEY = "@type"
|
14
|
+
ROOT_PATH = File.join(__dir__, "..")
|
15
|
+
|
13
16
|
def self.config
|
14
17
|
@configuration ||= BingAdsRubySdk::Configuration.new
|
15
18
|
end
|
@@ -18,9 +21,9 @@ module BingAdsRubySdk
|
|
18
21
|
yield(config)
|
19
22
|
end
|
20
23
|
|
21
|
-
def self.log(level,
|
24
|
+
def self.log(level, ...)
|
22
25
|
return unless config.log
|
23
|
-
config.logger.send(level,
|
26
|
+
config.logger.send(level, ...)
|
24
27
|
end
|
25
28
|
|
26
29
|
def self.root_path
|
@@ -30,7 +33,4 @@ module BingAdsRubySdk
|
|
30
33
|
def self.type_key
|
31
34
|
TYPE_KEY
|
32
35
|
end
|
33
|
-
|
34
|
-
TYPE_KEY = "@type"
|
35
|
-
ROOT_PATH = File.join(__dir__, "..")
|
36
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bing_ads_ruby_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Effilab
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: signet
|
@@ -256,14 +256,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
256
|
requirements:
|
257
257
|
- - ">="
|
258
258
|
- !ruby/object:Gem::Version
|
259
|
-
version: '
|
259
|
+
version: '3'
|
260
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - ">="
|
263
263
|
- !ruby/object:Gem::Version
|
264
264
|
version: '0'
|
265
265
|
requirements: []
|
266
|
-
rubygems_version: 3.4.
|
266
|
+
rubygems_version: 3.4.10
|
267
267
|
signing_key:
|
268
268
|
specification_version: 4
|
269
269
|
summary: Bing Ads Ruby SDK
|