soapy_bing 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/soapy_bing/oauth_credentials.rb +3 -1
- data/lib/soapy_bing/version.rb +1 -1
- data/spec/soapy_bing/oauth_credentials_spec.rb +13 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 410ca0200523029aee0ca775e0c1cd2e986d8f06e8052125f0f29a2a1ab6bbca
|
4
|
+
data.tar.gz: e60d34bd896baff2a38484d7e92aac4d3eeb28d899e3d951e6fb31cd73455f9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e8de7b6c64bc206576b1715819ac7e9dd32a244197d1cc1b4e0ac33004ae559fd93b5f382a984d2e311c2c66fcdffe8f56dbdf7d10352e1f8a8d9c8a4b54fab
|
7
|
+
data.tar.gz: c4c91a28b008659e3a571359e745297975c6d743c482cd1f6b62f5814aec4b998cb3b6777bfacb7ce0303cdd0e691d87ab20e88c49cb692e541e7cea017d129a
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [1.0.1] - 2019-03-13
|
8
|
+
### Changed
|
9
|
+
- Pass along the server's error message to `TokenRefreshError`
|
10
|
+
|
7
11
|
## [1.0.0] - 2019-01-28
|
8
12
|
### Added
|
9
13
|
- This CHANGELOG
|
@@ -27,7 +27,9 @@ module SoapyBing
|
|
27
27
|
def request_access_token
|
28
28
|
resp = HTTParty.post(token_url, body: access_token_params)
|
29
29
|
|
30
|
-
|
30
|
+
if resp.code != 200
|
31
|
+
raise TokenRefreshError, "#{resp['error_description']} (#{resp['error']})"
|
32
|
+
end
|
31
33
|
|
32
34
|
resp['access_token']
|
33
35
|
end
|
data/lib/soapy_bing/version.rb
CHANGED
@@ -83,28 +83,37 @@ RSpec.describe SoapyBing::OauthCredentials do
|
|
83
83
|
|
84
84
|
describe '#access_token' do
|
85
85
|
let(:credentials) { { client_id: 'foo', client_secret: 'bar', refresh_token: 'baz' } }
|
86
|
-
let(:response)
|
86
|
+
let(:response) do
|
87
|
+
HTTParty::Response.new(
|
88
|
+
OpenStruct.new(options: {}),
|
89
|
+
OpenStruct.new(code: status_code),
|
90
|
+
-> { response_body }
|
91
|
+
)
|
92
|
+
end
|
87
93
|
|
88
94
|
before do
|
89
|
-
allow(response).to receive(:code).once.and_return(status_code)
|
90
95
|
allow(HTTParty).to receive(:post).once.and_return(response)
|
91
96
|
end
|
92
97
|
|
93
98
|
context 'when there is good response' do
|
94
99
|
let(:status_code) { 200 }
|
100
|
+
let(:response_body) { { 'access_token' => 'my-token' } }
|
95
101
|
|
96
102
|
it 'memoizes http request response' do
|
97
|
-
expect(response).to receive(:[]).once.with('access_token').and_return('my-token')
|
98
103
|
2.times { expect(oauth_credentials.access_token).to eq 'my-token' }
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
102
107
|
context 'when there is bad response' do
|
103
108
|
let(:status_code) { 401 }
|
109
|
+
let(:response_body) do
|
110
|
+
{ 'error' => 'my-error', 'error_description' => 'This is my error.' }
|
111
|
+
end
|
104
112
|
|
105
113
|
it 'throws exception in case of bad status code' do
|
106
114
|
expect { oauth_credentials.access_token }.to raise_error(
|
107
|
-
SoapyBing::OauthCredentials::TokenRefreshError
|
115
|
+
SoapyBing::OauthCredentials::TokenRefreshError,
|
116
|
+
'This is my error. (my-error)'
|
108
117
|
)
|
109
118
|
end
|
110
119
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soapy_bing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ad2games GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -299,8 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
299
|
- !ruby/object:Gem::Version
|
300
300
|
version: '0'
|
301
301
|
requirements: []
|
302
|
-
|
303
|
-
rubygems_version: 2.7.6
|
302
|
+
rubygems_version: 3.0.2
|
304
303
|
signing_key:
|
305
304
|
specification_version: 4
|
306
305
|
summary: Simple client for the Bing Ads APIs
|