bing_ads_ruby_sdk 1.5.2 → 1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee1dd6d1c423e271f716d5a8d71aea958a73126002eb777a765f10416a0aa095
4
- data.tar.gz: d145e027e36d473eb849a06e5eac94641f85f4c427a96a76136841e1a70a7814
3
+ metadata.gz: 10064130886df96745297db7c95d5482b3127563383425554e7ee722e36e17ff
4
+ data.tar.gz: ffd8833ecabc68e2d6ac7760891399070bbffb6f644f79b7f71275270e5e9c95
5
5
  SHA512:
6
- metadata.gz: 7b78346cc370f6c287987c32cab9f898051158b40070375d3ae9f33b29fce2538674d276b8917cf9ce6710897b8727bd43dce1ae56a2346facf0087867300d6a
7
- data.tar.gz: b3fdebf99829b5d1dafa5d30197829dabeedb8960727d0c49b7ab8b1990304f3589873137becefdc9b7f03c1ac5953c8174b76f29ee35b8323a011ea7034e70a
6
+ metadata.gz: 5dad795cb0dba423784ad86926c397740b083201bfb9c327f04763e94f34149860d857989b2e1386008ed19d96317a9ea91655b1267f39017b32fd14d34b9388
7
+ data.tar.gz: b5d31b8cd1fad4f64b91debaead3daf4878d427b5d5d17639247e732eedc125a406d16968a1dd5a3d1fc4402059268d5cffa05ee6a0c96ae153836246f232154
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in bing_ads_ruby_sdk.gemspec
4
4
  gemspec
5
5
 
6
- gem "standard", "1.25.3"
6
+ gem "standard", "1.31.1"
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
- ## Getting Started
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 below.
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
- BingAdsRubySdk.configure do |conf|
87
- conf.log = true
88
- conf.logger.level = Logger::DEBUG
89
- conf.pretty_print_xml = true
90
- # to filter sensitive data before logging
91
- conf.filters = ["AuthenticationToken", "DeveloperToken"]
92
-
93
- # Optionally allow ActiveSupport::Notifications to be emitted by Excon.
94
- # These notifications can then be sent on to your profiling system
95
- # conf.instrumentor = ActiveSupport::Notifications
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
 
@@ -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 = ">= 2.3"
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
@@ -1,3 +1,8 @@
1
+ ## V1.6 Release
2
+ - Updated documentation
3
+ - Fixed an envkey/dotenv related bug preventing the gem from starting
4
+ - Dropped support for Ruby 2
5
+
1
6
  ## V1.5.1 Release
2
7
  - Bug fix: Rake task missing
3
8
 
@@ -23,7 +23,7 @@ module BingAdsRubySdk
23
23
  # @return [nil] if the file doesn't exist.
24
24
  def read
25
25
  return nil unless File.file?("./#{filename}")
26
- JSON.parse(IO.read(filename))
26
+ JSON.parse(File.read(filename))
27
27
  end
28
28
 
29
29
  private
@@ -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("-", "_")
@@ -1,4 +1,8 @@
1
- require "dotenv/load"
1
+ begin
2
+ require "dotenv/load"
3
+ rescue LoadError
4
+ puts "Unable to load .env file, resuming..."
5
+ end
2
6
 
3
7
  namespace :bing_token do
4
8
  desc "Gets OAuth token from MS and stores it in a JSON file defined by filename parameter"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BingAdsRubySdk
4
- VERSION = "1.5.2"
4
+ VERSION = "1.6"
5
5
  DEFAULT_SDK_VERSION = :v13
6
6
  end
@@ -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, *args, &block)
24
+ def self.log(level, ...)
22
25
  return unless config.log
23
- config.logger.send(level, *args, &block)
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.5.2
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-03-27 00:00:00.000000000 Z
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: '2.3'
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.9
266
+ rubygems_version: 3.4.10
267
267
  signing_key:
268
268
  specification_version: 4
269
269
  summary: Bing Ads Ruby SDK