barnesandnoble 0.2.0 → 0.3.0

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
- SHA1:
3
- metadata.gz: 1cc2f0b5a0447a44bae1e893748b26a0ee9d635a
4
- data.tar.gz: 7041259521e6cbe055e7aae5a9472412a17a2d2b
2
+ SHA256:
3
+ metadata.gz: 844e3e17adb55bc5205785195d3f5c747d2b23ae610a68fdcd6612562c947e14
4
+ data.tar.gz: f42906761a5855573c8118bc0288bc1ba0232380a9592636c4bd1bc5f16c8fe2
5
5
  SHA512:
6
- metadata.gz: 09bbf24da68e256f3b587ff0fc16e03b9936f83b029155b598195f0abe91b13f8e70a6a5ea50af4d75ed0f61caabe1fe03df5ab9ff693b796de106925ce6ffe4
7
- data.tar.gz: 1e7dd5a7aed443de6b6403408c2c31f21a1f576e5e6c19f6fcf1e6b714f382ce4c7aafcc01461e74f0148148700c655bbdac4f556d56a96d6a549a16a7a65ff5
6
+ metadata.gz: '0943217a0d1ff028fa566e7a1065077876706602894989f036bd3df562056234398ec700b955365a37082c3f69a0aaa4159d272c7fc020265c8d39a9540cfa45'
7
+ data.tar.gz: e816303077bf041614cf076b4a85f449bf806507f3edc6ea01264ff1290d61431f8a8a2d14402f0e87bb15da096fa65144e56588387beaa27c7ae3a5901051a0
@@ -1,5 +1,7 @@
1
- require "forwardable"
2
- require "barnesandnoble/request"
1
+ # frozen_string_literal: true
2
+
3
+ require 'forwardable'
4
+ require 'barnesandnoble/request'
3
5
 
4
6
  module Barnesandnoble
5
7
  class << self
@@ -1,52 +1,53 @@
1
- require "excon"
2
- require "barnesandnoble/response"
1
+ # frozen_string_literal: true
2
+
3
+ require 'excon'
4
+ require 'barnesandnoble/response'
3
5
 
4
6
  module Barnesandnoble
5
7
  class Request
6
- def initialize(app_id = ENV["BN_API_KEY"])
8
+ def initialize(app_id = ENV['BN_API_KEY'])
7
9
  @app_id = app_id
8
10
  end
9
11
 
10
- underscore = ->(str) {
11
- str.gsub(/(.)([A-Z\d])/,'\1_\2').downcase
12
+ underscore = lambda { |str|
13
+ str.gsub(/(.)([A-Z\d])/, '\1_\2').downcase
12
14
  }
13
15
 
14
- %w(ProductLookup ProductSearch Top10 GetCategories GetPwbab)
16
+ %w[ProductLookup ProductSearch Top10 GetCategories GetPwbab]
15
17
  .each do |operation|
16
- define_method(underscore.(operation)) do |options|
17
- get_product(operation, options)
18
+ define_method(underscore.call(operation)) do |options|
19
+ request_product(operation, options)
18
20
  end
19
21
  end
20
22
 
21
- %w(GetTextBookRentalInfo)
23
+ %w[GetTextBookRentalInfo]
22
24
  .each do |operation|
23
- define_method(underscore.(operation)) do |options|
24
- get_textbook(operation, options)
25
+ define_method(underscore.call(operation)) do |options|
26
+ request_textbook(operation, options)
25
27
  end
26
28
  end
27
29
 
28
30
  private
29
31
 
30
- def get_textbook(operation, options)
32
+ def request_textbook(operation, options)
31
33
  request(operation, options.merge(
32
- path: "/TextBookService/v01_00/#{operation}"
33
- ))
34
+ path: "/TextBookService/v01_00/#{operation}"
35
+ ))
34
36
  end
35
37
 
36
-
37
- def get_product(operation, options)
38
+ def request_product(operation, options)
38
39
  request(operation, options.merge(
39
- path: "/v03_00/#{operation}"
40
- ))
40
+ path: "/v03_00/#{operation}"
41
+ ))
41
42
  end
42
43
 
43
- def request(operation, options)
44
- options[:query]["AppId"] ||= @app_id
44
+ def request(_operation, options)
45
+ options[:query]['AppId'] ||= @app_id
45
46
  Response.new(http.get(options))
46
47
  end
47
48
 
48
49
  def http
49
- Excon.new("http://services.barnesandnoble.com", expects: 200)
50
+ Excon.new('http://services.barnesandnoble.com', expects: 200)
50
51
  end
51
52
  end
52
53
  end
@@ -1,10 +1,12 @@
1
- require "delegate"
2
- require "multi_xml"
1
+ # frozen_string_literal: true
2
+
3
+ require 'delegate'
4
+ require 'multi_xml'
3
5
 
4
6
  module Barnesandnoble
5
7
  class Response < SimpleDelegator
6
8
  def body
7
- __getobj__.body.force_encoding("ISO8859-1").encode("UTF-8")
9
+ __getobj__.body.force_encoding('ISO8859-1').encode('UTF-8')
8
10
  end
9
11
 
10
12
  def to_h
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Barnesandnoble
2
- VERSION = "0.2.0"
4
+ VERSION = '0.3.0'
3
5
  end
@@ -1,8 +1,7 @@
1
- require "minitest/autorun"
2
- require "minitest/pride"
3
- require "pry"
1
+ # frozen_string_literal: true
4
2
 
5
- require_relative "../lib/barnesandnoble"
3
+ require 'minitest/autorun'
4
+ require_relative '../lib/barnesandnoble'
6
5
 
7
6
  class TestBarnesandnoble < Minitest::Test
8
7
  def setup
@@ -11,59 +10,59 @@ class TestBarnesandnoble < Minitest::Test
11
10
 
12
11
  def test_product_lookup
13
12
  res = @req.product_lookup(query: {
14
- "Ean" => "9781593083342",
15
- "ProductCode" => "Book"
16
- })
13
+ 'Ean' => '9781593083342',
14
+ 'ProductCode' => 'Book'
15
+ })
17
16
  refute_empty res.to_h
18
17
  end
19
18
 
20
19
  def test_get_categories
21
20
  res = @req.get_categories(query: {
22
- "Ean" => "9781593083342",
23
- "ProductCode" => "Book"
24
- })
21
+ 'Ean' => '9781593083342',
22
+ 'ProductCode' => 'Book'
23
+ })
25
24
  refute_empty res.to_h
26
25
  end
27
26
 
28
27
  def test_people_who_bought_also_bought
29
- skip("Does not work")
28
+ skip('Does not work')
30
29
  res = @req.get_pwbab(query: {
31
- "Ean" => "9780345546883",
32
- "ProductCode" => "Book"
33
- })
30
+ 'Ean' => '9780345546883',
31
+ 'ProductCode' => 'Book'
32
+ })
34
33
  refute_empty res.to_h
35
34
  end
36
35
 
37
36
  def test_top_10
38
37
  res = @req.top_10(query: {
39
- "Top10SearchDomain" => "Book"
40
- })
38
+ 'Top10SearchDomain' => 'Book'
39
+ })
41
40
  refute_empty res.to_h
42
41
  end
43
42
 
44
43
  def test_product_search
45
44
  res = @req.product_search(query: {
46
- "SearchType" => "Book",
47
- "Start" => 1,
48
- "Size" => 5,
49
- "ProductSort" => "Bestselling",
50
- "Keyword" => "Deleuze"
51
- })
45
+ 'SearchType' => 'Book',
46
+ 'Start' => 1,
47
+ 'Size' => 5,
48
+ 'ProductSort' => 'Bestselling',
49
+ 'Keyword' => 'Deleuze'
50
+ })
52
51
  refute_empty res.to_h
53
52
  end
54
53
 
55
54
  def test_get_text_book_rental_info
56
55
  res = @req.get_text_book_rental_info(query: {
57
- "Ean" => "9781118230718"
58
- })
56
+ 'Ean' => '9781118230718'
57
+ })
59
58
  refute_empty res.to_h
60
59
  end
61
60
 
62
61
  def test_handles_unicode_characters
63
62
  res = @req.product_lookup(query: {
64
- "ProductCode" => "Book",
65
- "Ean" => "0942299663"
66
- })
67
- assert_equal "La Jetée", res.to_h["ProductLookupResponse"]["ProductLookupResult"]["Product"]["Titles"]["Title"]["title"]
63
+ 'ProductCode' => 'Book',
64
+ 'Ean' => '0942299663'
65
+ })
66
+ assert_equal 'La Jetée', res.to_h['ProductLookupResponse']['ProductLookupResult']['Product']['Titles']['Title']['title']
68
67
  end
69
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: barnesandnoble
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Marquez
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-23 00:00:00.000000000 Z
12
+ date: 2020-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: multi_xml
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - "~>"
19
- - !ruby/object:Gem::Version
20
- version: 0.5.5
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - "~>"
26
- - !ruby/object:Gem::Version
27
- version: 0.5.5
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: excon
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -40,13 +26,13 @@ dependencies:
40
26
  - !ruby/object:Gem::Version
41
27
  version: '0'
42
28
  - !ruby/object:Gem::Dependency
43
- name: minitest
29
+ name: multi_xml
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
32
  - - ">="
47
33
  - !ruby/object:Gem::Version
48
34
  version: '0'
49
- type: :development
35
+ type: :runtime
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
@@ -54,7 +40,7 @@ dependencies:
54
40
  - !ruby/object:Gem::Version
55
41
  version: '0'
56
42
  - !ruby/object:Gem::Dependency
57
- name: rake
43
+ name: minitest
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - ">="
@@ -68,7 +54,7 @@ dependencies:
68
54
  - !ruby/object:Gem::Version
69
55
  version: '0'
70
56
  - !ruby/object:Gem::Dependency
71
- name: pry
57
+ name: rake
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
60
  - - ">="
@@ -107,18 +93,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: '1.9'
96
+ version: '2.3'
111
97
  required_rubygems_version: !ruby/object:Gem::Requirement
112
98
  requirements:
113
99
  - - ">="
114
100
  - !ruby/object:Gem::Version
115
101
  version: '0'
116
102
  requirements: []
117
- rubyforge_project:
118
- rubygems_version: 2.3.0
103
+ rubygems_version: 3.1.2
119
104
  signing_key:
120
105
  specification_version: 4
121
106
  summary: A Ruby wrapper for Barnes and Noble Product Web Services
122
107
  test_files:
123
108
  - test/test_barnesandnoble.rb
124
- has_rdoc: