best_buy_ruby 0.1.0 → 0.1.1

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: ccf8ed1fc5f203f69ae21880739637bacd5815c8
4
- data.tar.gz: a6c8f223588c5077ecf179b5897c4322c291c661
2
+ SHA256:
3
+ metadata.gz: a0f26749ea4f679641b57f597c1361d281fb475a2fa83909afc450885407fe3a
4
+ data.tar.gz: 0a1f91dca71325a5bfcc1ca11bbae04151280d74f21d07141308c5cf8eaa2e24
5
5
  SHA512:
6
- metadata.gz: 386d8d932c316fd59224462646d9a06bd8887a2c6cf220364d56a5f4556257fe6e1633387eca9ce3bb027e87acb14508e028e91a79e1324444f96a06b123c467
7
- data.tar.gz: 49ca31364afd7c5eddbc5987afd412bc24f548aa7b00c472075b74f3ae5babd55a8a1379099094881e74f4e69491c3b7a42d6eacccbc613a0bd28e1f76bef35d
6
+ metadata.gz: b7efec1459b1d8bbdf2ae3581f8593074a0b776b9021cdb6280b9878e823a28f1389ddf89824c24a020330990952192eb49fbb5a18b850a7b72565eb0995ded1
7
+ data.tar.gz: 531da91fab6ad2f25a374b28125cf1e03ab936edb8aeb98b912a12011023e085d4daffade76e1eaa24a95828eb7716527cab862aed3961e77a34253c64ec96d4
@@ -1,3 +1,7 @@
1
+ # 0.1.1
2
+ - Added support for non Rails projects
3
+ - Allowed APIs to use configured API key
4
+
1
5
  # 0.1.0
2
6
  - Added Products API
3
7
  - `get_all` method
@@ -1,15 +1,15 @@
1
1
  ## Contributing ##
2
2
 
3
- You can contribute to this repo if you have an issue, found a bug or think there's some functionality required that would add value to the gem. To do so, please check if there's not already an [issue](https://github.com/rootstrap/gem-base/issues) for that, if you find there's not, create a new one with as much detail as possible.
3
+ You can contribute to this repo if you have an issue, found a bug or think there's some functionality required that would add value to the gem. To do so, please check if there's not already an [issue](https://github.com/rootstrap/best_buy_ruby/issues) for that, if you find there's not, create a new one with as much detail as possible.
4
4
 
5
5
  If you want to contribute with code as well, please follow the next steps:
6
6
 
7
- 1. Read, understand and agree to our [code of conduct](https://github.com/rootstrap/gem-base/blob/master/CODE_OF_CONDUCT.md)
7
+ 1. Read, understand and agree to our [code of conduct](https://github.com/rootstrap/best_buy_ruby/blob/master/CODE_OF_CONDUCT.md)
8
8
  2. [Fork the repo](https://help.github.com/articles/about-forks/)
9
9
  3. Clone the project into your machine:
10
- `$ git clone git@github.com:[YOUR GITHUB USERNAME]/gem-base.git`
10
+ `$ git clone git@github.com:rootstrap/best_buy_ruby.git`
11
11
  4. Access the repo:
12
- `$ cd gem-base`
12
+ `$ cd best_buy_ruby`
13
13
  5. Create your feature/bugfix branch:
14
14
  `$ git checkout -b your_new_feature`
15
15
  or
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020 Juan Manuel Ramallo
3
+ Copyright (c) 2020 Rootstrap
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -30,11 +30,11 @@ This will create this file: `config/initializers/best_buy.rb`
30
30
 
31
31
  ## Usage
32
32
 
33
- The gem can be used to access Best Buy [APIs](general-overview.md):
33
+ The gem can be used to access Best Buy [APIs](docs/general_overview.md):
34
34
 
35
- - [Products](products-api.md)
36
- - [Stores](stores-api.md)
37
- - [Categories](categories-api.md)
35
+ - [Products](docs/products_api.md)
36
+ - [Stores](docs/stores_api.md)
37
+ - [Categories](docs/categories_api.md)
38
38
 
39
39
  Example:
40
40
 
@@ -73,7 +73,7 @@ The gem is available as open source under the terms of the [MIT License](https:/
73
73
 
74
74
  ## Code of Conduct
75
75
 
76
- Everyone interacting in the RubyGemTemplate project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/gem-base/blob/master/CODE_OF_CONDUCT.md).
76
+ Everyone interacting in the Best Buy Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rootstrap/best_buy_ruby/blob/master/CODE_OF_CONDUCT.md).
77
77
 
78
78
  ## Credits
79
79
 
@@ -27,16 +27,16 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ['lib']
28
28
 
29
29
  # Production dependencies
30
- spec.add_dependency 'activesupport', '~> 6.0.2.1'
31
- spec.add_dependency 'faraday', '~> 1.0.0'
30
+ spec.add_dependency 'activesupport', ['>= 4', '< 7']
31
+ spec.add_dependency 'faraday', '~> 1.0'
32
32
 
33
33
  # Development dependencies
34
- spec.add_development_dependency 'ammeter'
35
- spec.add_development_dependency 'railties'
36
- spec.add_development_dependency 'rake'
37
- spec.add_development_dependency 'reek'
38
- spec.add_development_dependency 'rspec'
39
- spec.add_development_dependency 'rubocop'
40
- spec.add_development_dependency 'simplecov'
41
- spec.add_development_dependency 'webmock'
34
+ spec.add_development_dependency 'ammeter', '~> 1.1'
35
+ spec.add_development_dependency 'railties', '~> 6.0'
36
+ spec.add_development_dependency 'rake', '~> 13.0'
37
+ spec.add_development_dependency 'reek', '~> 5.6'
38
+ spec.add_development_dependency 'rspec', '~> 3.9'
39
+ spec.add_development_dependency 'rubocop', '~> 0.80'
40
+ spec.add_development_dependency 'simplecov', '~> 0.17.1'
41
+ spec.add_development_dependency 'webmock', '~> 3.8'
42
42
  end
@@ -22,4 +22,4 @@ Attributes:
22
22
 
23
23
  ## Interface
24
24
 
25
- (For more methods, check the [common API interface](general_overview.md#common-methods))
25
+ (For more methods, check the [common API interface](general_overview.md#common-interface))
@@ -8,6 +8,31 @@ The different APIs accessible by this gem are:
8
8
 
9
9
  In spite of having each their own specification, they all share some basics listed here.
10
10
 
11
+ ## API key usage
12
+
13
+ All APIs can be initialized by passing the API key in the `new` method
14
+
15
+ ```ruby
16
+ BestBuy::Products.new(your_api_key)
17
+ ```
18
+ But the key can also be set up in a `configure` method available for the `BestBuy` module:
19
+ ```ruby
20
+ BestBuy.configure do |config|
21
+ config.api_key = 'your_api_key'
22
+ end
23
+ ```
24
+ Then, the next time you instantiate any API you can omit the key:
25
+
26
+ ```ruby
27
+ BestBuy::Products.new
28
+ ```
29
+ For Ruby on Rails projects you can run:
30
+
31
+ $ rails generate best_buy:config
32
+
33
+ To generate this file: `config/initializers/best_buy.rb`, where you can write the configuration code.
34
+
35
+ For non Ruby on Rails projects, you can still write the configuration code wherever you like, as long as you make sure it runs before trying to access the APIs.
11
36
  ## Common interface
12
37
 
13
38
  This method can be used with any of the APIs:
@@ -56,7 +56,7 @@ Attributes:
56
56
 
57
57
  ## Interface
58
58
 
59
- (For more methods, check the [common API interface](general_overview.md#common-methods))
59
+ (For more methods, check the [common API interface](general_overview.md#common-interface))
60
60
 
61
61
  #### `get_by(conditions)`
62
62
 
@@ -49,7 +49,7 @@ store.address # returns '50 Holyoke St'
49
49
 
50
50
  ## Interface
51
51
 
52
- (For more methods, check the [common API interface](general_overview.md#common-methods))
52
+ (For more methods, check the [common API interface](general_overview.md#common-interface))
53
53
 
54
54
  #### `find(store_id)`
55
55
 
@@ -6,6 +6,8 @@ require 'active_support/core_ext/module/delegation'
6
6
  require 'active_support/core_ext/string'
7
7
  require 'faraday'
8
8
 
9
+ require 'best_buy/exceptions/api_key_not_found'
10
+
9
11
  require 'best_buy/helpers/api_helper'
10
12
  require 'best_buy/helpers/conditions/category_condition'
11
13
  require 'best_buy/helpers/conditions/max_price_condition'
@@ -14,6 +16,7 @@ require 'best_buy/helpers/conditions/new_condition'
14
16
  require 'best_buy/helpers/conditions/pre_owned_condition'
15
17
  require 'best_buy/helpers/conditions/refurbished_condition'
16
18
 
19
+ require 'best_buy/config'
17
20
  require 'best_buy/base_api'
18
21
  require 'best_buy/categories'
19
22
  require 'best_buy/products'
@@ -31,4 +34,4 @@ require 'best_buy/models/product'
31
34
  require 'best_buy/models/shipping_level_of_service'
32
35
  require 'best_buy/models/store'
33
36
 
34
- require 'generators/best_buy/config/config_generator'
37
+ require 'generators/best_buy/config/config_generator' if defined? Rails::Generators
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BestBuy
4
4
  module Base
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -11,7 +11,9 @@ module BestBuy
11
11
 
12
12
  attr_reader :api_key
13
13
 
14
- def initialize(api_key)
14
+ def initialize(api_key = BestBuy.config.api_key)
15
+ raise Exceptions::ApiKeyNotFound unless api_key
16
+
15
17
  @api_key = api_key
16
18
  end
17
19
 
@@ -6,6 +6,10 @@ module BestBuy
6
6
  yield config
7
7
  end
8
8
 
9
+ def reset_configuration
10
+ @config = Config.new
11
+ end
12
+
9
13
  def config
10
14
  @config ||= Config.new
11
15
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BestBuy
4
+ module Exceptions
5
+ class ApiKeyNotFound < StandardError
6
+ def message
7
+ 'No API key configured. Either configure it in config/initializers/best_buy.rb '\
8
+ 'or pass it as a parameter when creating the API instance.'
9
+ end
10
+ end
11
+ end
12
+ end
metadata CHANGED
@@ -1,155 +1,161 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: best_buy_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Damilano
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-07 00:00:00.000000000 Z
11
+ date: 2020-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 6.0.2.1
22
+ version: '7'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: 6.0.2.1
29
+ version: '4'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: faraday
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 1.0.0
39
+ version: '1.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 1.0.0
46
+ version: '1.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: ammeter
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ">="
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0'
53
+ version: '1.1'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ">="
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
60
+ version: '1.1'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: railties
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ">="
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
67
+ version: '6.0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ">="
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '0'
74
+ version: '6.0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rake
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ">="
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '0'
81
+ version: '13.0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ">="
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '0'
88
+ version: '13.0'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: reek
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ">="
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '0'
95
+ version: '5.6'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ">="
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '0'
102
+ version: '5.6'
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: rspec
99
105
  requirement: !ruby/object:Gem::Requirement
100
106
  requirements:
101
- - - ">="
107
+ - - "~>"
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: '3.9'
104
110
  type: :development
105
111
  prerelease: false
106
112
  version_requirements: !ruby/object:Gem::Requirement
107
113
  requirements:
108
- - - ">="
114
+ - - "~>"
109
115
  - !ruby/object:Gem::Version
110
- version: '0'
116
+ version: '3.9'
111
117
  - !ruby/object:Gem::Dependency
112
118
  name: rubocop
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
- - - ">="
121
+ - - "~>"
116
122
  - !ruby/object:Gem::Version
117
- version: '0'
123
+ version: '0.80'
118
124
  type: :development
119
125
  prerelease: false
120
126
  version_requirements: !ruby/object:Gem::Requirement
121
127
  requirements:
122
- - - ">="
128
+ - - "~>"
123
129
  - !ruby/object:Gem::Version
124
- version: '0'
130
+ version: '0.80'
125
131
  - !ruby/object:Gem::Dependency
126
132
  name: simplecov
127
133
  requirement: !ruby/object:Gem::Requirement
128
134
  requirements:
129
- - - ">="
135
+ - - "~>"
130
136
  - !ruby/object:Gem::Version
131
- version: '0'
137
+ version: 0.17.1
132
138
  type: :development
133
139
  prerelease: false
134
140
  version_requirements: !ruby/object:Gem::Requirement
135
141
  requirements:
136
- - - ">="
142
+ - - "~>"
137
143
  - !ruby/object:Gem::Version
138
- version: '0'
144
+ version: 0.17.1
139
145
  - !ruby/object:Gem::Dependency
140
146
  name: webmock
141
147
  requirement: !ruby/object:Gem::Requirement
142
148
  requirements:
143
- - - ">="
149
+ - - "~>"
144
150
  - !ruby/object:Gem::Version
145
- version: '0'
151
+ version: '3.8'
146
152
  type: :development
147
153
  prerelease: false
148
154
  version_requirements: !ruby/object:Gem::Requirement
149
155
  requirements:
150
- - - ">="
156
+ - - "~>"
151
157
  - !ruby/object:Gem::Version
152
- version: '0'
158
+ version: '3.8'
153
159
  description:
154
160
  email:
155
161
  - sandro.damilano@rootstrap.com
@@ -182,6 +188,7 @@ files:
182
188
  - lib/best_buy/base_api.rb
183
189
  - lib/best_buy/categories.rb
184
190
  - lib/best_buy/config.rb
191
+ - lib/best_buy/exceptions/api_key_not_found.rb
185
192
  - lib/best_buy/helpers/api_helper.rb
186
193
  - lib/best_buy/helpers/conditions/category_condition.rb
187
194
  - lib/best_buy/helpers/conditions/max_price_condition.rb
@@ -226,8 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
226
233
  - !ruby/object:Gem::Version
227
234
  version: '0'
228
235
  requirements: []
229
- rubyforge_project:
230
- rubygems_version: 2.5.2.3
236
+ rubygems_version: 3.1.2
231
237
  signing_key:
232
238
  specification_version: 4
233
239
  summary: A wrapper for Best Buy APIs.