bing-content-api 0.3.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62c2988a5c692651b3f62b750fce936dbddf0cd5
4
- data.tar.gz: 822431fe79be49a95d517d5aca227bf58e95d6b2
3
+ metadata.gz: c3417f15cf9af8dfd72b7ee034ba801a83ab51a2
4
+ data.tar.gz: f6def0a10b0637e1e20922144117ac3814dd1727
5
5
  SHA512:
6
- metadata.gz: 2e6c2bb9f77498417ccf8ae54a3c2aedc6f4c61260c15e6e9cf390038c903aa8a921c1bcca165cb62619a91da8de8d946074e4a730d7eff646c98a740cf0071f
7
- data.tar.gz: 1241ad6361b2011431b410de23aa62a9a0e7eea60d3da1c148ace11a84f3b28a54a1e8a0fdc691bd36b0b4dcbccfec5036db1f146828e513ec3d6b8f56fdb01d
6
+ metadata.gz: dc732b9f5d0fae8606e63d95244f1f85677d3148b6ee708a2247e89f01f4829c0151e6da875b7f616cebf6facc3dd8413570ca7e1086c2a43405d6b2b781000d
7
+ data.tar.gz: 35c5e72981c5efd0839222544318f055ba8a2293ee1e11b857c952c19facbc9d25ecf4cfa976a05bd1a1e2df9b3297b52d0ed121ff962901ac272abd9d7d7f05
data/.codeclimate.yml ADDED
@@ -0,0 +1,15 @@
1
+ engines:
2
+ bundler-audit:
3
+ enabled: true
4
+ fixme:
5
+ enabled: true
6
+ rubocop:
7
+ enabled: true
8
+
9
+ ratings:
10
+ paths:
11
+ - Gemfile.lock
12
+ - "**.rb"
13
+
14
+ exclude_paths:
15
+ - "**/vendor/**/*"
data/.gitignore CHANGED
@@ -1,9 +1,7 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
- /doc/
7
5
  /pkg/
8
6
  /spec/reports/
9
7
  /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,78 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - "**/vendor/**/*"
6
+
7
+ Rails:
8
+ Enabled: true
9
+
10
+ RSpec/NestedGroups:
11
+ Enabled: false
12
+
13
+ Style/MultilineMethodCallIndentation:
14
+ Enabled: false
15
+
16
+ # Because https://www.viget.com/articles/just-use-double-quoted-ruby-strings
17
+ Style/StringLiterals:
18
+ Enabled: false
19
+
20
+ # Because that way you avoid spurious Git diff touching already-present array elements.
21
+ #
22
+ # For example, if we have:
23
+ #
24
+ # [ [
25
+ # item1, item1,
26
+ # item2, => item2,
27
+ # item3,
28
+ # ] ]
29
+ #
30
+ # See how item2 would have been "touched" if it didn't have a trailing comma.
31
+ Style/TrailingCommaInLiteral:
32
+ Enabled: false
33
+
34
+ # We have large monitors, yo.
35
+ Metrics/LineLength:
36
+ Enabled: false
37
+
38
+ Metrics/ClassLength:
39
+ Enabled: false
40
+
41
+ Metrics/ModuleLength:
42
+ Enabled: false
43
+
44
+ RSpec/ExampleLength:
45
+ Enabled: false
46
+
47
+ # Stop moaning about missing class documentation comments.
48
+ Documentation:
49
+ Enabled: false
50
+
51
+ # These are from our Code Climate config.
52
+ Lint/AssignmentInCondition:
53
+ Enabled: false
54
+ Style/SpaceInsideHashLiteralBraces:
55
+ Enabled: false
56
+ Style/EmptyLinesAroundClassBody:
57
+ Enabled: false
58
+ Style/EmptyLinesAroundBlockBody:
59
+ Enabled: false
60
+ Style/SpaceInsideParens:
61
+ Enabled: false
62
+ Style/SpaceInsideBrackets:
63
+ Enabled: false
64
+ Style/SpaceAroundEqualsInParameterDefault:
65
+ Enabled: false
66
+ Style/NegatedIf:
67
+ Enabled: false
68
+ Metrics/BlockLength:
69
+ Enabled: false
70
+ Metrics/MethodLength:
71
+ Enabled: false
72
+ Metrics/AbcSize:
73
+ Enabled: false
74
+ Max: 20
75
+ Rails/HttpPositionalArguments:
76
+ Enabled: false
77
+ Style/FrozenStringLiteralComment:
78
+ Enabled: false
data/Gemfile.lock ADDED
@@ -0,0 +1,102 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bing-content-api (0.3.2)
5
+ httpi (~> 2.4, >= 2.4.2)
6
+ oauth2 (~> 1.3, >= 1.3.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (5.0.2)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (~> 0.7)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ addressable (2.5.1)
17
+ public_suffix (~> 2.0, >= 2.0.2)
18
+ ast (2.3.0)
19
+ concurrent-ruby (1.0.5)
20
+ crack (0.4.3)
21
+ safe_yaml (~> 1.0.0)
22
+ diff-lcs (1.3)
23
+ factory_girl (4.8.0)
24
+ activesupport (>= 3.0.0)
25
+ faraday (0.11.0)
26
+ multipart-post (>= 1.2, < 3)
27
+ hashdiff (0.3.2)
28
+ httpclient (2.8.3)
29
+ httpi (2.4.2)
30
+ rack
31
+ socksify
32
+ i18n (0.8.1)
33
+ jwt (1.5.6)
34
+ minitest (5.10.1)
35
+ multi_json (1.12.1)
36
+ multi_xml (0.6.0)
37
+ multipart-post (2.0.0)
38
+ oauth2 (1.3.1)
39
+ faraday (>= 0.8, < 0.12)
40
+ jwt (~> 1.0)
41
+ multi_json (~> 1.3)
42
+ multi_xml (~> 0.5)
43
+ rack (>= 1.2, < 3)
44
+ parser (2.4.0.0)
45
+ ast (~> 2.2)
46
+ powerpack (0.1.1)
47
+ public_suffix (2.0.5)
48
+ rack (2.0.1)
49
+ rainbow (2.2.2)
50
+ rake
51
+ rake (10.5.0)
52
+ rspec (3.5.0)
53
+ rspec-core (~> 3.5.0)
54
+ rspec-expectations (~> 3.5.0)
55
+ rspec-mocks (~> 3.5.0)
56
+ rspec-core (3.5.4)
57
+ rspec-support (~> 3.5.0)
58
+ rspec-expectations (3.5.0)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.5.0)
61
+ rspec-mocks (3.5.0)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.5.0)
64
+ rspec-support (3.5.0)
65
+ rubocop (0.48.1)
66
+ parser (>= 2.3.3.1, < 3.0)
67
+ powerpack (~> 0.1)
68
+ rainbow (>= 1.99.1, < 3.0)
69
+ ruby-progressbar (~> 1.7)
70
+ unicode-display_width (~> 1.0, >= 1.0.1)
71
+ rubocop-rspec (1.15.1)
72
+ rubocop (>= 0.42.0)
73
+ ruby-progressbar (1.8.1)
74
+ safe_yaml (1.0.4)
75
+ socksify (1.7.1)
76
+ thread_safe (0.3.6)
77
+ tzinfo (1.2.3)
78
+ thread_safe (~> 0.1)
79
+ unicode-display_width (1.2.1)
80
+ vcr (3.0.3)
81
+ webmock (3.0.1)
82
+ addressable (>= 2.3.6)
83
+ crack (>= 0.3.2)
84
+ hashdiff
85
+
86
+ PLATFORMS
87
+ ruby
88
+
89
+ DEPENDENCIES
90
+ bing-content-api!
91
+ bundler (~> 1.14)
92
+ factory_girl (~> 4.0)
93
+ httpclient (~> 2.8, >= 2.8.3)
94
+ rake (~> 10.0)
95
+ rspec (~> 3.0)
96
+ rubocop
97
+ rubocop-rspec
98
+ vcr (~> 3.0, >= 3.0.3)
99
+ webmock (~> 3.0, >= 3.0.1)
100
+
101
+ BUNDLED WITH
102
+ 1.14.6
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Bing::Content::Api
2
2
 
3
+ [![Code Climate](https://codeclimate.com/github/redbubble/bing-content-api/badges/gpa.svg)](https://codeclimate.com/github/redbubble/bing-content-api)
4
+ [![Build Status](https://travis-ci.org/redbubble/bing-content-api.svg?branch=master)](https://travis-ci.org/redbubble/bing-content-api)
5
+
3
6
  This Gem is intended to be an as-thin-as-possible wrapper around the
4
7
  Bing Ads Content API.
5
8
 
@@ -112,6 +115,19 @@ contributors are expected to adhere to
112
115
  the [Contributor Covenant](http://contributor-covenant.org) code of
113
116
  conduct.
114
117
 
118
+ Maintainers
119
+ -------
120
+
121
+
122
+
123
+ [![](doc/redbubble.png)][redbubble]
124
+
125
+ The Bing Content API gem is maintained and funded
126
+ by [Redbubble][redbubble].
127
+
128
+ paul.david@redbubble.com
129
+
130
+ [redbubble]: https://www.redbubble.com
115
131
 
116
132
  ## License
117
133
 
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,17 +1,18 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'bing/content/api/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = 'bing-content-api'
8
- spec.version = Bing::Content::Api::VERSION
9
- spec.authors = ['Paul David']
10
- spec.email = ['paul.david@redbubble.com']
8
+ spec.name = 'bing-content-api'
9
+ spec.version = Bing::Content::Api::VERSION
10
+ spec.authors = ['Paul David']
11
+ spec.email = ['paul.david@redbubble.com']
11
12
 
12
- spec.summary = %q{Interface with Bing Content API for managing Shopping Ads.}
13
- spec.homepage = 'https://github.com/redbubble/bing-content-api'
14
- spec.license = 'WTFPL'
13
+ spec.summary = 'Interface with Bing Content API for managing Shopping Ads.'
14
+ spec.homepage = 'https://github.com/redbubble/bing-content-api'
15
+ spec.license = 'WTFPL'
15
16
 
16
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
18
  # to allow pushing to a single host or delete this section to allow pushing to any host.
@@ -22,16 +23,18 @@ Gem::Specification.new do |spec|
22
23
  "public gem pushes."
23
24
  end
24
25
 
25
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
27
  f.match(%r{^(test|spec|features)/})
27
28
  end
28
- spec.bindir = 'exe'
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.bindir = 'exe'
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
31
  spec.require_paths = ['lib']
31
32
 
32
33
  spec.add_development_dependency 'bundler', '~> 1.14'
33
34
  spec.add_development_dependency 'rake', '~> 10.0'
34
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
+ spec.add_development_dependency 'rubocop'
37
+ spec.add_development_dependency 'rubocop-rspec'
35
38
  spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
36
39
  spec.add_development_dependency 'factory_girl', '~> 4.0'
37
40
  spec.add_development_dependency 'httpclient', '~> 2.8', '>= 2.8.3'
data/doc/redbubble.png ADDED
Binary file
@@ -23,7 +23,7 @@ module Bing
23
23
  end
24
24
 
25
25
  def all_products
26
- @operations.map { |op| op.product }
26
+ @operations.map(&:product)
27
27
  end
28
28
 
29
29
  def product_by_batch_id(id)
@@ -31,10 +31,7 @@ module Bing
31
31
  end
32
32
 
33
33
  def to_body
34
- json_operations = @operations.map do |op|
35
- op.bing_operation
36
- end
37
-
34
+ json_operations = @operations.map(&:bing_operation)
38
35
  { entries: json_operations }.to_json
39
36
  end
40
37
  end
@@ -8,7 +8,7 @@ module Bing
8
8
  attr_reader :action
9
9
 
10
10
  def initialize(batch_id, product, action=:insert)
11
- raise "Please select a valid operation." unless [:insert, :delete].include? action
11
+ raise "Please select a valid operation." unless %i(insert delete).include? action
12
12
 
13
13
  @batch_id = batch_id
14
14
  @product = product
@@ -9,6 +9,7 @@ module Bing
9
9
  def execute(batch)
10
10
  post_body = batch.to_body
11
11
  http_response = @connector.post('/products/batch', post_body)
12
+ raise http_response.body if http_response.error?
12
13
  body = JSON.parse(http_response.body)
13
14
  entries = body["entries"]
14
15
 
@@ -22,14 +22,15 @@ module Bing
22
22
 
23
23
  def generate_user_authorisation_url
24
24
  oauth_client.auth_code.authorize_url(
25
- :state => "ArizonaIsAState",
26
- :scope => "bingads.manage")
25
+ state: "ArizonaIsAState",
26
+ scope: "bingads.manage"
27
+ )
27
28
  end
28
29
 
29
30
  def fetch_token_with_code!(verified_url)
30
31
  @token = oauth_client.auth_code.get_token(
31
32
  extract_code(verified_url),
32
- :redirect_uri => REDIRECT_URI
33
+ redirect_uri: REDIRECT_URI
33
34
  )
34
35
  self.refresh_token = @token.refresh_token
35
36
  end
@@ -44,6 +45,14 @@ module Bing
44
45
  JSON.parse(response.body)["resources"]
45
46
  end
46
47
 
48
+ def connector
49
+ refresh_token! unless @connector
50
+ @connector ||= Bing::Content::Api::Connector.new(@developer_token,
51
+ @token.token,
52
+ @merchant_id,
53
+ @catalogue_id)
54
+ end
55
+
47
56
  private
48
57
 
49
58
  def refresh_token!
@@ -54,7 +63,7 @@ module Bing
54
63
  end
55
64
 
56
65
  def refresh_token=(value)
57
- if @refresh_token_callback then
66
+ if @refresh_token_callback
58
67
  @refresh_token_callback.call(value)
59
68
  else
60
69
  puts "WARNING: this is the default refresh_token_callback."
@@ -69,21 +78,14 @@ module Bing
69
78
  /code=([0-9a-zA-Z\-]+)&/.match(redirected_url)[1]
70
79
  end
71
80
 
72
- def connector
73
- refresh_token! unless @connector
74
- @connector ||= Bing::Content::Api::Connector.new(@developer_token,
75
- @token.token,
76
- @merchant_id,
77
- @catalogue_id)
78
- end
79
-
80
81
  def oauth_client
81
- @oauth_client ||= OAuth2::Client.new(@client_id,
82
+ @oauth_client ||= OAuth2::Client.new(
83
+ @client_id,
82
84
  nil, # client secret isn't applicable for our use
83
- :site => 'https://login.live.com',
84
- :authorize_url => '/oauth20_authorize.srf',
85
- :token_url => '/oauth20_token.srf',
86
- :redirect_uri => REDIRECT_URI
85
+ site: 'https://login.live.com',
86
+ authorize_url: '/oauth20_authorize.srf',
87
+ token_url: '/oauth20_token.srf',
88
+ redirect_uri: REDIRECT_URI
87
89
  )
88
90
  end
89
91
  end
@@ -5,19 +5,19 @@ module Bing
5
5
  attr_reader :failures, :successes
6
6
 
7
7
  def initialize(response_entries, batch)
8
- @failures = batch.all_products
8
+ @failures = []
9
9
  @successes = []
10
10
 
11
11
  response_entries.each do |entry|
12
12
  id = entry["batchId"].to_i
13
- add_success(batch.product_by_batch_id(id))
13
+ error = entry["errors"]
14
+ if error
15
+ failures << { response: entry, product: batch.product_by_batch_id(id) }
16
+ else
17
+ successes << { response: entry, product: batch.product_by_batch_id(id) }
18
+ end
14
19
  end
15
20
  end
16
-
17
- def add_success(product)
18
- @failures.delete_if { |prod| prod.offer_id == product.offer_id }
19
- @successes << product
20
- end
21
21
  end
22
22
  end
23
23
  end
@@ -1,7 +1,7 @@
1
1
  module Bing
2
2
  module Content
3
3
  module Api
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2".freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bing-content-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul David
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-02 00:00:00.000000000 Z
11
+ date: 2017-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: vcr
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -173,17 +201,21 @@ executables: []
173
201
  extensions: []
174
202
  extra_rdoc_files: []
175
203
  files:
204
+ - ".codeclimate.yml"
176
205
  - ".gitignore"
177
206
  - ".rspec"
207
+ - ".rubocop.yml"
178
208
  - ".travis.yml"
179
209
  - CODE_OF_CONDUCT.md
180
210
  - Gemfile
211
+ - Gemfile.lock
181
212
  - LICENSE.txt
182
213
  - README.md
183
214
  - Rakefile
184
215
  - bin/console
185
216
  - bin/setup
186
217
  - bing-content-api.gemspec
218
+ - doc/redbubble.png
187
219
  - lib/bing/content/api.rb
188
220
  - lib/bing/content/api/batch.rb
189
221
  - lib/bing/content/api/batch_operation.rb