best_buy_ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.reek.yml +127 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +74 -0
  6. data/.travis.yml +33 -0
  7. data/CHANGELOG.md +10 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/CONTRIBUTING.md +42 -0
  10. data/Gemfile +5 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +83 -0
  13. data/Rakefile +6 -0
  14. data/best_buy_ruby.gemspec +42 -0
  15. data/bin/console +15 -0
  16. data/bin/setup +8 -0
  17. data/docs/categories_api.md +25 -0
  18. data/docs/general_overview.md +67 -0
  19. data/docs/products_api.md +85 -0
  20. data/docs/stores_api.md +68 -0
  21. data/lib/best_buy.rb +34 -0
  22. data/lib/best_buy/base.rb +13 -0
  23. data/lib/best_buy/base/version.rb +7 -0
  24. data/lib/best_buy/base_api.rb +46 -0
  25. data/lib/best_buy/categories.rb +23 -0
  26. data/lib/best_buy/config.rb +17 -0
  27. data/lib/best_buy/helpers/api_helper.rb +13 -0
  28. data/lib/best_buy/helpers/conditions/category_condition.rb +19 -0
  29. data/lib/best_buy/helpers/conditions/max_price_condition.rb +19 -0
  30. data/lib/best_buy/helpers/conditions/min_price_condition.rb +19 -0
  31. data/lib/best_buy/helpers/conditions/new_condition.rb +19 -0
  32. data/lib/best_buy/helpers/conditions/pre_owned_condition.rb +19 -0
  33. data/lib/best_buy/helpers/conditions/refurbished_condition.rb +19 -0
  34. data/lib/best_buy/models/address.rb +23 -0
  35. data/lib/best_buy/models/base_category.rb +12 -0
  36. data/lib/best_buy/models/category.rb +20 -0
  37. data/lib/best_buy/models/collection_header.rb +20 -0
  38. data/lib/best_buy/models/collections_response.rb +19 -0
  39. data/lib/best_buy/models/image.rb +16 -0
  40. data/lib/best_buy/models/offer.rb +18 -0
  41. data/lib/best_buy/models/product.rb +39 -0
  42. data/lib/best_buy/models/shipping_level_of_service.rb +13 -0
  43. data/lib/best_buy/models/store.rb +26 -0
  44. data/lib/best_buy/products.rb +53 -0
  45. data/lib/best_buy/search_query_builder.rb +21 -0
  46. data/lib/best_buy/stores.rb +30 -0
  47. data/lib/generators/best_buy/config/config_generator.rb +13 -0
  48. data/lib/generators/best_buy/config/templates/config.rb +5 -0
  49. metadata +234 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ccf8ed1fc5f203f69ae21880739637bacd5815c8
4
+ data.tar.gz: a6c8f223588c5077ecf179b5897c4322c291c661
5
+ SHA512:
6
+ metadata.gz: 386d8d932c316fd59224462646d9a06bd8887a2c6cf220364d56a5f4556257fe6e1633387eca9ce3bb027e87acb14508e028e91a79e1324444f96a06b123c467
7
+ data.tar.gz: 49ca31364afd7c5eddbc5987afd412bc24f548aa7b00c472075b74f3ae5babd55a8a1379099094881e74f4e69491c3b7a42d6eacccbc613a0bd28e1f76bef35d
@@ -0,0 +1,21 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ .idea/
14
+
15
+ .DS_Store
16
+
17
+ Gemfile.lock
18
+ .ruby-version
19
+
20
+ # File created by the generators tests
21
+ spec/generators/tmp/
@@ -0,0 +1,127 @@
1
+ detectors:
2
+ Attribute:
3
+ enabled: false
4
+ exclude: []
5
+ BooleanParameter:
6
+ enabled: true
7
+ exclude: []
8
+ ClassVariable:
9
+ enabled: false
10
+ exclude: []
11
+ ControlParameter:
12
+ enabled: true
13
+ exclude: []
14
+ DataClump:
15
+ enabled: true
16
+ exclude: []
17
+ max_copies: 2
18
+ min_clump_size: 2
19
+ DuplicateMethodCall:
20
+ enabled: true
21
+ exclude: []
22
+ max_calls: 1
23
+ allow_calls: []
24
+ FeatureEnvy:
25
+ enabled: true
26
+ exclude: []
27
+ InstanceVariableAssumption:
28
+ enabled: false
29
+ IrresponsibleModule:
30
+ enabled: false
31
+ exclude: []
32
+ LongParameterList:
33
+ enabled: true
34
+ exclude: []
35
+ max_params: 4
36
+ overrides:
37
+ initialize:
38
+ max_params: 5
39
+ LongYieldList:
40
+ enabled: true
41
+ exclude: []
42
+ max_params: 3
43
+ ManualDispatch:
44
+ enabled: true
45
+ exclude: []
46
+ MissingSafeMethod:
47
+ enabled: false
48
+ exclude: []
49
+ ModuleInitialize:
50
+ enabled: true
51
+ exclude: []
52
+ NestedIterators:
53
+ enabled: true
54
+ exclude: []
55
+ max_allowed_nesting: 2
56
+ ignore_iterators: []
57
+ NilCheck:
58
+ enabled: false
59
+ exclude: []
60
+ RepeatedConditional:
61
+ enabled: true
62
+ exclude: []
63
+ max_ifs: 3
64
+ SubclassedFromCoreClass:
65
+ enabled: true
66
+ exclude: []
67
+ TooManyConstants:
68
+ enabled: true
69
+ exclude: []
70
+ max_constants: 5
71
+ TooManyInstanceVariables:
72
+ enabled: true
73
+ exclude: []
74
+ max_instance_variables: 9
75
+ TooManyMethods:
76
+ enabled: true
77
+ exclude: []
78
+ max_methods: 25
79
+ TooManyStatements:
80
+ enabled: true
81
+ exclude:
82
+ - initialize
83
+ max_statements: 12
84
+ UncommunicativeMethodName:
85
+ enabled: true
86
+ exclude: []
87
+ reject:
88
+ - "/^[a-z]$/"
89
+ - "/[0-9]$/"
90
+ - "/[A-Z]/"
91
+ accept: []
92
+ UncommunicativeModuleName:
93
+ enabled: true
94
+ exclude: []
95
+ reject:
96
+ - "/^.$/"
97
+ - "/[0-9]$/"
98
+ accept:
99
+ - Inline::C
100
+ - "/V[0-9]/"
101
+ UncommunicativeParameterName:
102
+ enabled: true
103
+ exclude: []
104
+ reject:
105
+ - "/^.$/"
106
+ - "/[0-9]$/"
107
+ - "/[A-Z]/"
108
+ accept: []
109
+ UncommunicativeVariableName:
110
+ enabled: true
111
+ exclude: []
112
+ reject:
113
+ - "/^.$/"
114
+ - "/[0-9]$/"
115
+ - "/[A-Z]/"
116
+ accept:
117
+ - _
118
+ UnusedParameters:
119
+ enabled: true
120
+ exclude: []
121
+ UnusedPrivateMethod:
122
+ enabled: false
123
+ UtilityFunction:
124
+ enabled: false
125
+
126
+ exclude_paths:
127
+ - config
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,74 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'best_buy_ruby.gemspec'
4
+
5
+ Documentation:
6
+ Enabled: false
7
+
8
+ Layout/SpaceBeforeFirstArg:
9
+ Exclude:
10
+
11
+ Lint/AmbiguousBlockAssociation:
12
+ Exclude:
13
+ - spec/**/*
14
+
15
+ Metrics/AbcSize:
16
+ # The ABC size is a calculated magnitude, so this number can be an Integer or
17
+ # a Float.
18
+ Max: 15
19
+
20
+ Metrics/BlockLength:
21
+ CountComments: false # count full line comments?
22
+ Max: 25
23
+ Exclude:
24
+ - config/**/*
25
+ - spec/**/*
26
+ ExcludedMethods:
27
+ - class_methods
28
+
29
+ Metrics/BlockNesting:
30
+ Max: 4
31
+
32
+ Metrics/ClassLength:
33
+ CountComments: false # count full line comments?
34
+ Max: 200
35
+
36
+ # Avoid complex methods.
37
+ Metrics/CyclomaticComplexity:
38
+ Max: 7
39
+
40
+ Metrics/MethodLength:
41
+ CountComments: false # count full line comments?
42
+ Max: 24
43
+
44
+ Metrics/ModuleLength:
45
+ CountComments: false # count full line comments?
46
+ Max: 200
47
+
48
+ Metrics/LineLength:
49
+ Max: 100
50
+ # To make it possible to copy or click on URIs in the code, we allow lines
51
+ # containing a URI to be longer than Max.
52
+ AllowURI: true
53
+ URISchemes:
54
+ - http
55
+ - https
56
+
57
+ Metrics/ParameterLists:
58
+ Max: 5
59
+ CountKeywordArgs: false
60
+
61
+ Metrics/PerceivedComplexity:
62
+ Max: 12
63
+
64
+ Style/Alias:
65
+ EnforcedStyle: prefer_alias_method
66
+
67
+ Style/FrozenStringLiteralComment:
68
+ Enabled: true
69
+
70
+ Style/ModuleFunction:
71
+ Enabled: false
72
+
73
+ Naming/PredicateName:
74
+ Enabled: false
@@ -0,0 +1,33 @@
1
+ ---
2
+ language: ruby
3
+
4
+ before_install:
5
+ - gem install bundler -v "~> 2.1.4"
6
+
7
+ rvm:
8
+ - 2.5.0
9
+ - 2.6.0
10
+ - 2.7.0
11
+ - ruby-head
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+
17
+ sudo: false
18
+
19
+ env:
20
+ global:
21
+ - CC_TEST_REPORTER_ID=1944071d462e1895d6766a91fda6090a1238bd94303b9dffdbbf33da77f2f965
22
+
23
+ before_script:
24
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
25
+ - chmod +x ./cc-test-reporter
26
+ - ./cc-test-reporter before-build
27
+
28
+ script:
29
+ - bundle exec rake code_analysis
30
+ - bundle exec rspec
31
+
32
+ after_script:
33
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -0,0 +1,10 @@
1
+ # 0.1.0
2
+ - Added Products API
3
+ - `get_all` method
4
+ - `get_by` method
5
+ - Added Categories API
6
+ - `get_all` method
7
+ - Added Stores API
8
+ - `get_all` method
9
+ - `find` method
10
+ - Added generator for Rails projects
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at [YOUR EMAIL]. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
@@ -0,0 +1,42 @@
1
+ ## Contributing ##
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.
4
+
5
+ If you want to contribute with code as well, please follow the next steps:
6
+
7
+ 1. Read, understand and agree to our [code of conduct](https://github.com/rootstrap/gem-base/blob/master/CODE_OF_CONDUCT.md)
8
+ 2. [Fork the repo](https://help.github.com/articles/about-forks/)
9
+ 3. Clone the project into your machine:
10
+ `$ git clone git@github.com:[YOUR GITHUB USERNAME]/gem-base.git`
11
+ 4. Access the repo:
12
+ `$ cd gem-base`
13
+ 5. Create your feature/bugfix branch:
14
+ `$ git checkout -b your_new_feature`
15
+ or
16
+ `$ git checkout -b fix/your_fix` in case of a bug fix
17
+ (if your PR is to address an existing issue, it would be good to name the branch after the issue, for example: if you are trying to solve issue 182, then a good idea for the branch name would be `182_your_new_feature`)
18
+ 6. Write tests for your changes (feature/bug)
19
+ 7. Code your (feature/bugfix)
20
+ 8. Run the code analysis tool by doing:
21
+ `$ rake code_analysis`
22
+ 9. Run the tests:
23
+ `$ bundle exec rspec`
24
+ All tests must pass. If all tests (both code analysis and rspec) do pass, then you are ready to go to the next step:
25
+ 10. Commit your changes:
26
+ `$ git commit -m 'Your feature or bugfix title'`
27
+ 11. Push to the branch `$ git push origin your_new_feature`
28
+ 12. Create a new [pull request](https://help.github.com/articles/creating-a-pull-request/)
29
+
30
+ Some helpful guides that will help you know how we work:
31
+ 1. [Code review](https://github.com/rootstrap/tech-guides/tree/master/code-review)
32
+ 2. [GIT workflow](https://github.com/rootstrap/tech-guides/tree/master/git)
33
+ 3. [Ruby style guide](https://github.com/rootstrap/tech-guides/tree/master/ruby)
34
+ 4. [Rails style guide](https://github.com/rootstrap/tech-guides/blob/master/ruby/rails.md)
35
+ 5. [RSpec style guide](https://github.com/rootstrap/tech-guides/blob/master/ruby/rspec/README.md)
36
+
37
+ For more information or guides like the ones mentioned above, please check our [tech guides](https://github.com/rootstrap/tech-guides). Keep in mind that the more you know about these guides, the easier it will be for your code to get approved and merged.
38
+
39
+ Note: We work with one commit per pull request, so if you make your commit and realize you were missing something or want to add something more to it, don't create a new commit with the changes, but use `$ git commit --amend` instead. This same principle also applies for when changes are requested on an open pull request.
40
+
41
+
42
+ Thank you very much for your time and for considering helping in this project.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Juan Manuel Ramallo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,83 @@
1
+ # Best Buy Ruby
2
+
3
+ [![Build Status](https://travis-ci.com/rootstrap/best_buy_ruby.svg?token=7i1Qbv4PM7uB4Ljqux8D&branch=master)](https://travis-ci.com/rootstrap/best_buy_ruby)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d8dacb0f44a9379fee2d/maintainability)](https://codeclimate.com/github/rootstrap/best_buy_ruby/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d8dacb0f44a9379fee2d/test_coverage)](https://codeclimate.com/github/rootstrap/best_buy_ruby/test_coverage)
6
+
7
+ This is a Ruby gem for accessing all the different [Best Buy APIs](https://bestbuyapis.github.io/api-documentation).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'best_buy_ruby'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle install
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install best_buy_ruby
24
+
25
+ On a Ruby on Rails project, you can also use a generator to create the gem's initializer:
26
+
27
+ $ rails generate best_buy:config
28
+
29
+ This will create this file: `config/initializers/best_buy.rb`
30
+
31
+ ## Usage
32
+
33
+ The gem can be used to access Best Buy [APIs](general-overview.md):
34
+
35
+ - [Products](products-api.md)
36
+ - [Stores](stores-api.md)
37
+ - [Categories](categories-api.md)
38
+
39
+ Example:
40
+
41
+ ```
42
+ products_api = BestBuy::Products.new(your_api_key)
43
+
44
+ products_api.get_by(min_price: 6.5, max_price: 11, item_condition: "New")
45
+ ```
46
+
47
+ ## Future Features
48
+
49
+ - [Commerce API](https://bestbuyapis.github.io/api-documentation/#commerce-api)
50
+ - [Buying Options API](https://bestbuyapis.github.io/api-documentation/#buying-options-open-box-api)
51
+ - [Recommendations API](https://bestbuyapis.github.io/api-documentation/#recommendations-api)
52
+ - [Sorting options](https://bestbuyapis.github.io/api-documentation/#sort)
53
+ - [Facets](https://bestbuyapis.github.io/api-documentation/#facets)
54
+ - Stores API
55
+
56
+ - [Area function](https://bestbuyapis.github.io/api-documentation/#area-function)
57
+
58
+ (A detailed backlog can be found in our Github Projects [board](https://github.com/rootstrap/best_buy_ruby/projects/1))
59
+
60
+ ## Development
61
+
62
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
63
+
64
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
65
+
66
+ ## Contributing
67
+
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rootstrap/best_buy_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/rootstrap/best_buy_ruby/blob/master/CODE_OF_CONDUCT.md).
69
+
70
+ ## License
71
+
72
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
73
+
74
+ ## Code of Conduct
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).
77
+
78
+ ## Credits
79
+
80
+ Rails Api Base is maintained by [Rootstrap](http://www.rootstrap.com) with the help of our
81
+ [contributors](https://github.com/rootstrap/best_buy_ruby/contributors).
82
+
83
+ [<img src="https://s3-us-west-1.amazonaws.com/rootstrap.com/img/rs.png" width="100"/>](http://www.rootstrap.com)