bing_ads_ruby_sdk 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bing_ads_ruby_sdk.gemspec +1 -1
- data/changelog.md +4 -0
- data/lib/bing_ads_ruby_sdk/api.rb +3 -1
- data/lib/bing_ads_ruby_sdk/header.rb +8 -4
- data/lib/bing_ads_ruby_sdk/oauth2/authorization_handler.rb +9 -5
- data/lib/bing_ads_ruby_sdk/services/base.rb +6 -6
- data/lib/bing_ads_ruby_sdk/version.rb +1 -1
- data/spec/bing_ads_ruby_sdk/header_spec.rb +26 -3
- data/tasks/bing_ads_ruby_sdk.rake +3 -1
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9352d8c5f77aca5732658f3bbf045528f8c813349430af4a9c05a69457df927
|
4
|
+
data.tar.gz: 14762060f02d65b3a9980d4a4b9cd988d46ef2a6163869ee1c1c443f085c4369
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3b09a5a61f94c913e54f08ff6145f51c5849f6a743a5ace400d6ba381a639497cf459733b99285f0fe58a8062add0b7f1c0b5b4a949ff2467d81ce46e7e26c9
|
7
|
+
data.tar.gz: 1bc8e7c7c10e25b2a6d4201a692133c0fa317b0c70d5fb38961d3fecc2303dc9001e88c7e112dd5b076c21961f2a31388c4886aff07d075ba78e43f7e3e335da
|
data/bing_ads_ruby_sdk.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^(spec)/})
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency 'signet', '
|
24
|
+
spec.add_runtime_dependency 'signet', '>= 0.8.1', '< 0.13.0'
|
25
25
|
spec.add_runtime_dependency 'excon', '>= 0.62.0'
|
26
26
|
spec.add_runtime_dependency 'lolsoap', '>=0.9.0'
|
27
27
|
|
data/changelog.md
CHANGED
@@ -27,12 +27,14 @@ module BingAdsRubySdk
|
|
27
27
|
environment: :production,
|
28
28
|
developer_token:,
|
29
29
|
client_id:,
|
30
|
-
oauth_store
|
30
|
+
oauth_store:,
|
31
|
+
client_secret: nil)
|
31
32
|
@version = version
|
32
33
|
@environment = environment
|
33
34
|
@header = Header.new(
|
34
35
|
developer_token: developer_token,
|
35
36
|
client_id: client_id,
|
37
|
+
client_secret: client_secret,
|
36
38
|
store: oauth_store
|
37
39
|
)
|
38
40
|
end
|
@@ -6,9 +6,10 @@ module BingAdsRubySdk
|
|
6
6
|
# @param developer_token
|
7
7
|
# @param client_id
|
8
8
|
# @param store instance of a store
|
9
|
-
def initialize(developer_token:, client_id:, store:)
|
9
|
+
def initialize(developer_token:, client_id:, store:, client_secret: nil)
|
10
10
|
@developer_token = developer_token
|
11
11
|
@client_id = client_id
|
12
|
+
@client_secret = client_secret
|
12
13
|
@oauth_store = store
|
13
14
|
@customer = {}
|
14
15
|
end
|
@@ -20,7 +21,9 @@ module BingAdsRubySdk
|
|
20
21
|
"DeveloperToken" => developer_token,
|
21
22
|
"CustomerId" => customer[:customer_id],
|
22
23
|
"CustomerAccountId" => customer[:account_id]
|
23
|
-
}
|
24
|
+
}.tap do |hash|
|
25
|
+
hash["ClientSecret"] = client_secret if client_secret
|
26
|
+
end
|
24
27
|
end
|
25
28
|
|
26
29
|
def set_customer(account_id:, customer_id:)
|
@@ -31,13 +34,14 @@ module BingAdsRubySdk
|
|
31
34
|
|
32
35
|
private
|
33
36
|
|
34
|
-
attr_reader :oauth_store, :developer_token, :client_id, :customer
|
37
|
+
attr_reader :oauth_store, :developer_token, :client_id, :customer, :client_secret
|
35
38
|
|
36
39
|
def auth_handler
|
37
40
|
@auth_handler ||= ::BingAdsRubySdk::OAuth2::AuthorizationHandler.new(
|
38
41
|
developer_token: developer_token,
|
39
42
|
client_id: client_id,
|
40
|
-
store: oauth_store
|
43
|
+
store: oauth_store,
|
44
|
+
client_secret: client_secret
|
41
45
|
)
|
42
46
|
end
|
43
47
|
end
|
@@ -9,8 +9,10 @@ module BingAdsRubySdk
|
|
9
9
|
# @param developer_token
|
10
10
|
# @param client_id
|
11
11
|
# @param store [Store]
|
12
|
-
def initialize(developer_token:, client_id:, store:)
|
13
|
-
@client =
|
12
|
+
def initialize(developer_token:, client_id:, store:, client_secret: nil)
|
13
|
+
@client = Signet::OAuth2::Client.new(
|
14
|
+
client_params(developer_token, client_id, client_secret)
|
15
|
+
)
|
14
16
|
@store = store
|
15
17
|
refresh_from_store
|
16
18
|
end
|
@@ -73,15 +75,17 @@ module BingAdsRubySdk
|
|
73
75
|
query_params.find { |arg| arg.first.casecmp("CODE").zero? }
|
74
76
|
end
|
75
77
|
|
76
|
-
def
|
77
|
-
|
78
|
+
def client_params(developer_token, client_id, client_secret)
|
79
|
+
{
|
78
80
|
authorization_uri: 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize',
|
79
81
|
token_credential_uri: 'https://login.microsoftonline.com/common/oauth2/v2.0/token',
|
80
82
|
redirect_uri: 'https://login.microsoftonline.com/common/oauth2/nativeclient',
|
81
83
|
developer_token: developer_token,
|
82
84
|
client_id: client_id,
|
83
85
|
scope: 'offline_access'
|
84
|
-
}
|
86
|
+
}.tap do |hash|
|
87
|
+
hash[:client_secret] = client_secret if client_secret
|
88
|
+
end
|
85
89
|
end
|
86
90
|
|
87
91
|
def token_data
|
@@ -23,6 +23,11 @@ module BingAdsRubySdk
|
|
23
23
|
postprocess(response)
|
24
24
|
end
|
25
25
|
|
26
|
+
def call_wrapper(action, message, *response_nesting)
|
27
|
+
response = call(action, message)
|
28
|
+
wrap_array(dig_response(response, response_nesting))
|
29
|
+
end
|
30
|
+
|
26
31
|
def self.service
|
27
32
|
raise 'implement me'
|
28
33
|
end
|
@@ -31,11 +36,6 @@ module BingAdsRubySdk
|
|
31
36
|
|
32
37
|
attr_reader :soap_client
|
33
38
|
|
34
|
-
def call_wrapper(action, message, *response_nesting)
|
35
|
-
response = call(action, message)
|
36
|
-
wrap_array(dig_response(response, response_nesting))
|
37
|
-
end
|
38
|
-
|
39
39
|
def preprocess(message, operation_name)
|
40
40
|
order(
|
41
41
|
soap_client.wsdl_wrapper(operation_name),
|
@@ -80,4 +80,4 @@ module BingAdsRubySdk
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
-
end
|
83
|
+
end
|
@@ -1,6 +1,14 @@
|
|
1
1
|
RSpec.describe BingAdsRubySdk::Header do
|
2
2
|
let(:oauth_store) { double(:oauth_store) }
|
3
|
-
let(:
|
3
|
+
let(:client_secret) { 'pa$$w0rd' }
|
4
|
+
let(:subject) do
|
5
|
+
described_class.new(
|
6
|
+
developer_token: '123abc',
|
7
|
+
client_id: '1a-2b-3c',
|
8
|
+
client_secret: client_secret,
|
9
|
+
store: oauth_store,
|
10
|
+
)
|
11
|
+
end
|
4
12
|
let(:auth_handler) do
|
5
13
|
double(:auth_handler, fetch_or_refresh: 'yes/we/can')
|
6
14
|
end
|
@@ -9,6 +17,7 @@ RSpec.describe BingAdsRubySdk::Header do
|
|
9
17
|
expect(::BingAdsRubySdk::OAuth2::AuthorizationHandler).to receive(:new).with(
|
10
18
|
developer_token: '123abc',
|
11
19
|
client_id: '1a-2b-3c',
|
20
|
+
client_secret: client_secret,
|
12
21
|
store: oauth_store
|
13
22
|
).and_return auth_handler
|
14
23
|
end
|
@@ -19,10 +28,23 @@ RSpec.describe BingAdsRubySdk::Header do
|
|
19
28
|
"AuthenticationToken" => 'yes/we/can',
|
20
29
|
"DeveloperToken" => '123abc',
|
21
30
|
"CustomerId" => nil,
|
22
|
-
"CustomerAccountId" => nil
|
31
|
+
"CustomerAccountId" => nil,
|
32
|
+
"ClientSecret" => client_secret
|
23
33
|
)
|
24
34
|
end
|
25
35
|
|
36
|
+
context "without client_secret" do
|
37
|
+
let(:client_secret) { nil }
|
38
|
+
it do
|
39
|
+
expect(subject.content).to eq(
|
40
|
+
"AuthenticationToken" => 'yes/we/can',
|
41
|
+
"DeveloperToken" => '123abc',
|
42
|
+
"CustomerId" => nil,
|
43
|
+
"CustomerAccountId" => nil
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
26
48
|
it 'sets customer' do
|
27
49
|
subject.set_customer(customer_id: 777, account_id: 666 )
|
28
50
|
|
@@ -30,7 +52,8 @@ RSpec.describe BingAdsRubySdk::Header do
|
|
30
52
|
"AuthenticationToken" => 'yes/we/can',
|
31
53
|
"DeveloperToken" => '123abc',
|
32
54
|
"CustomerId" => 777,
|
33
|
-
"CustomerAccountId" => 666
|
55
|
+
"CustomerAccountId" => 666,
|
56
|
+
"ClientSecret" => client_secret
|
34
57
|
)
|
35
58
|
end
|
36
59
|
end
|
@@ -2,16 +2,18 @@ require 'dotenv/load'
|
|
2
2
|
|
3
3
|
namespace :bing_token do
|
4
4
|
desc "Gets and stores Bing OAuth token in file"
|
5
|
-
task :get, [:filename, :bing_developer_token, :bing_client_id] do |task, args|
|
5
|
+
task :get, [:filename, :bing_developer_token, :bing_client_id, :bing_client_secret] do |task, args|
|
6
6
|
|
7
7
|
filename = args[:filename] || ENV.fetch('BING_STORE_FILENAME')
|
8
8
|
developer_token = args[:bing_developer_token] || ENV.fetch('BING_DEVELOPER_TOKEN')
|
9
9
|
bing_client_id = args[:bing_client_id] || ENV.fetch('BING_CLIENT_ID')
|
10
|
+
bing_client_secret = args[:bing_client_secret] || ENV.fetch('BING_CLIENT_SECRET', nil)
|
10
11
|
|
11
12
|
store = ::BingAdsRubySdk::OAuth2::FsStore.new(filename)
|
12
13
|
auth = BingAdsRubySdk::OAuth2::AuthorizationHandler.new(
|
13
14
|
developer_token: developer_token,
|
14
15
|
client_id: bing_client_id,
|
16
|
+
client_secret: bing_client_secret,
|
15
17
|
store: store
|
16
18
|
)
|
17
19
|
puts "Go to #{auth.code_url}",
|
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.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Effilab
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: signet
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: 0.8.1
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.13.0
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: 0.8.1
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.13.0
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: excon
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|