google-ads-common 0.11.0 → 0.11.1
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 +5 -13
- data/ChangeLog +5 -0
- data/lib/ads_common/auth/oauth2_handler.rb +7 -3
- data/lib/ads_common/auth/oauth2_service_account_handler.rb +7 -3
- data/lib/ads_common/http.rb +31 -0
- data/lib/ads_common/version.rb +1 -1
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OTVmZjM4ZGQxZGU5M2RlMTYxZTZjZGQzMTA5ODkwYWM1NzNmNjY3ZA==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aca8bb491bb1979f93711715859c97790db6fdf9
|
4
|
+
data.tar.gz: 78ffbb5fa2fbda4985340f38a8ad9632756e5ce9
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YjcyZmI2OGM5MjdlOTNkMzc1ZmFiOGI1MDQ0ZTViMTYyYzY5OTBiNTMxODcy
|
11
|
-
YWIwODViYTFjZGExMzgyYzIzYTdmNzJlMTk0OGU2ZjM3N2IwOWU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzJkZTkxZWRkZmM1MGZlMTlhZmIzZmE3ZTM2OWE1YWJlODc0NzIxODEyMGI1
|
14
|
-
ZGQ3ODBiODVjZWY0NGE2OTQxNjUwN2U5MmI1MzYyOTQzZmE1MzcwMzZiNmY3
|
15
|
-
NzNmODIyYTY4NDJjMWZiYzcxZDU3NmQxZTI5MmRhZjIzMGJlN2U=
|
6
|
+
metadata.gz: 2a2daef0667e200028665475490329dfe8cba0b90d737d9b07ef77819e42922d0f2a30fb5243192ae259137fefb53f8c3e40f95906db823740bd766a14bf7f39
|
7
|
+
data.tar.gz: 96ec439dbabb8ad81b4085460f2329e8d6ecebb8635fe0103471dc892423277d32dd3a5086aea4e3f724cb46a443fe373609f19cf94e54669dc294d397aaf909
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.11.1:
|
2
|
+
- Added streaming get and post options to AdsCommon::Http.
|
3
|
+
- Added ability to support put requests to AdsCommon::Http.
|
4
|
+
- Added support for additional scopes when generating OAuth2 tokens.
|
5
|
+
|
1
6
|
0.11.0:
|
2
7
|
- Updated to use 'ads_savon' library over 'savon'.
|
3
8
|
- Add support for services to return SOAP XML without making a request. This
|
@@ -46,7 +46,11 @@ module AdsCommon
|
|
46
46
|
#
|
47
47
|
def initialize(config, scope)
|
48
48
|
super(config)
|
49
|
-
@
|
49
|
+
@scopes = []
|
50
|
+
@scopes << scope unless scope.nil?
|
51
|
+
additional_scopes = @config.read('authentication.oauth2_extra_scopes')
|
52
|
+
@scopes += additional_scopes if additional_scopes.is_a?(Array)
|
53
|
+
@client = nil
|
50
54
|
end
|
51
55
|
|
52
56
|
# Invalidates the stored token if the required credential has changed.
|
@@ -112,7 +116,7 @@ module AdsCommon
|
|
112
116
|
# - AdsCommon::Errors::AuthError if validation fails
|
113
117
|
#
|
114
118
|
def validate_credentials(credentials)
|
115
|
-
if @
|
119
|
+
if @scopes.empty?
|
116
120
|
raise AdsCommon::Errors::AuthError, 'Scope is not specified.'
|
117
121
|
end
|
118
122
|
|
@@ -163,7 +167,7 @@ module AdsCommon
|
|
163
167
|
oauth_options = OAUTH2_CONFIG.merge({
|
164
168
|
:client_id => credentials[:oauth2_client_id],
|
165
169
|
:client_secret => credentials[:oauth2_client_secret],
|
166
|
-
:scope => @
|
170
|
+
:scope => @scopes.join(' '),
|
167
171
|
:redirect_uri => credentials[:oauth2_callback] || DEFAULT_CALLBACK,
|
168
172
|
:state => credentials[:oauth2_state]
|
169
173
|
}).reject {|k, v| v.nil?}
|
@@ -42,7 +42,11 @@ module AdsCommon
|
|
42
42
|
#
|
43
43
|
def initialize(config, scope)
|
44
44
|
super(config)
|
45
|
-
@
|
45
|
+
@scopes = []
|
46
|
+
@scopes << scope unless scope.nil?
|
47
|
+
additional_scopes = @config.read('authentication.oauth2_extra_scopes')
|
48
|
+
@scopes += additional_scopes if additional_scopes.is_a?(Array)
|
49
|
+
@client = nil
|
46
50
|
end
|
47
51
|
|
48
52
|
# Invalidates the stored token if the required credential has changed.
|
@@ -101,7 +105,7 @@ module AdsCommon
|
|
101
105
|
# - AdsCommon::Errors::AuthError if validation fails
|
102
106
|
#
|
103
107
|
def validate_credentials(credentials)
|
104
|
-
if @
|
108
|
+
if @scopes.empty?
|
105
109
|
raise AdsCommon::Errors::AuthError, 'Scope is not specified.'
|
106
110
|
end
|
107
111
|
|
@@ -172,7 +176,7 @@ module AdsCommon
|
|
172
176
|
:issuer => credentials[:oauth2_issuer],
|
173
177
|
:signing_key => credentials[:oauth2_key],
|
174
178
|
:person => credentials[:oauth2_prn],
|
175
|
-
:scope => @
|
179
|
+
:scope => @scopes.join(' '),
|
176
180
|
})
|
177
181
|
return Signet::OAuth2::Client.new(oauth_options)
|
178
182
|
end
|
data/lib/ads_common/http.rb
CHANGED
@@ -43,6 +43,15 @@ module AdsCommon
|
|
43
43
|
return get_response(url, config, headers).body
|
44
44
|
end
|
45
45
|
|
46
|
+
# Performs a get on a URL, using all of the connection options in the
|
47
|
+
# client library, sending the response piecemeal to the given block.
|
48
|
+
def self.get_stream(url, config, headers = nil, &block)
|
49
|
+
request = prepare_request(url, config, headers)
|
50
|
+
request.on_body(&block)
|
51
|
+
HTTPI.get(request)
|
52
|
+
return nil
|
53
|
+
end
|
54
|
+
|
46
55
|
# Performs a post on a URL, using all of the connection options in the
|
47
56
|
# client library, returning a HTTPI::Response.
|
48
57
|
def self.post_response(url, data, config, headers = nil)
|
@@ -56,6 +65,28 @@ module AdsCommon
|
|
56
65
|
return post_response(url, data, config, headers).body
|
57
66
|
end
|
58
67
|
|
68
|
+
# Performs a post on a URL, using all of the connection options in the
|
69
|
+
# client library, sending the response piecemeal to the given block.
|
70
|
+
def self.post_stream(url, data, config, headers = nil, &block)
|
71
|
+
request = prepare_request(url, config, headers, data)
|
72
|
+
request.on_body(&block)
|
73
|
+
HTTPI.post(request)
|
74
|
+
return nil
|
75
|
+
end
|
76
|
+
|
77
|
+
# Performs a put on a URL, using all of the connection options in the
|
78
|
+
# client library, returning a HTTPI::Response.
|
79
|
+
def self.put_response(url, data, config, headers = nil)
|
80
|
+
request = prepare_request(url, config, headers, data)
|
81
|
+
return HTTPI.put(request)
|
82
|
+
end
|
83
|
+
|
84
|
+
# Performs a put on a URL, using all of the connection options in the
|
85
|
+
# client library, returning the response body as a string.
|
86
|
+
def self.put(url, data, config, headers = nil)
|
87
|
+
return put_response(url, data, config, headers).body
|
88
|
+
end
|
89
|
+
|
59
90
|
private
|
60
91
|
|
61
92
|
# Returns a suitably configured request object for a given URL and options.
|
data/lib/ads_common/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-ads-common
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Gomes
|
@@ -10,62 +10,62 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: google-ads-savon
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 1.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: 1.0.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: httpi
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - ~>
|
33
|
+
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '2.3'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - ~>
|
40
|
+
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '2.3'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: signet
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 0.6.0
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ~>
|
54
|
+
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: 0.6.0
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rake
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: 10.4.2
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: 10.4.2
|
71
71
|
description: Essential utilities shared by all Ads Ruby client libraries
|
@@ -119,17 +119,17 @@ require_paths:
|
|
119
119
|
- lib
|
120
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
126
|
requirements:
|
127
|
-
- -
|
127
|
+
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: 1.3.6
|
130
130
|
requirements: []
|
131
131
|
rubyforge_project: google-ads-common
|
132
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.4.8
|
133
133
|
signing_key:
|
134
134
|
specification_version: 4
|
135
135
|
summary: Common code for Google Ads APIs
|