mystery_shopper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +13 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +38 -0
- data/README.md +35 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mystery_shopper/game.rb +104 -0
- data/lib/mystery_shopper/price.rb +41 -0
- data/lib/mystery_shopper/request/base.rb +21 -0
- data/lib/mystery_shopper/request/detail.rb +29 -0
- data/lib/mystery_shopper/request/price.rb +26 -0
- data/lib/mystery_shopper/response.rb +17 -0
- data/lib/mystery_shopper/utils.rb +7 -0
- data/lib/mystery_shopper/version.rb +3 -0
- data/lib/mystery_shopper.rb +8 -0
- data/mystery_shopper.gemspec +24 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bf565e99402b0102a727708d14cb546a4bfaa32ff62bcde6579db60f11362b68
|
4
|
+
data.tar.gz: '0319d47a1a90e023f37f8cea51bfe56482219b8fd60235a5e86aba09c9eb7c40'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15df1c656198673f819a2a4e7e53bcddbe16871fb2a094089c99b93d2336e851a198ffa30b88c71d5ba4900f7e68da47dad1bedd0aa3411aa1acf655b6cbc94c
|
7
|
+
data.tar.gz: cb8932c5572c5fbb361c49e267df688a477361abc75b3b7ed92b87b3a0f57e94b689b1341aedff255d89d987a4b7339156dc96185b033d23b2aa64f5b371d8de
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- https://raw.githubusercontent.com/rubocop-hq/rubocop/master/config/enabled.yml
|
3
|
+
|
4
|
+
Metrics/BlockLength:
|
5
|
+
Enabled: true
|
6
|
+
Exclude:
|
7
|
+
- spec/**/*
|
8
|
+
Style/Documentation:
|
9
|
+
Enabled: false
|
10
|
+
Style/ExpandPathArguments:
|
11
|
+
Enabled: false
|
12
|
+
Style/FrozenStringLiteralComment:
|
13
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mystery_shopper (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
jaro_winkler (1.5.1-x86_64-darwin-17)
|
11
|
+
parallel (1.12.1)
|
12
|
+
parser (2.5.1.2)
|
13
|
+
ast (~> 2.4.0)
|
14
|
+
powerpack (0.1.1)
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (10.5.0)
|
17
|
+
rubocop (0.58.1)
|
18
|
+
jaro_winkler (~> 1.5.1)
|
19
|
+
parallel (~> 1.10)
|
20
|
+
parser (>= 2.5, != 2.5.1.1)
|
21
|
+
powerpack (~> 0.1)
|
22
|
+
rainbow (>= 2.2.2, < 4.0)
|
23
|
+
ruby-progressbar (~> 1.7)
|
24
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
25
|
+
ruby-progressbar (1.9.0)
|
26
|
+
unicode-display_width (1.3.0)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
bundler (~> 1.16)
|
33
|
+
mystery_shopper!
|
34
|
+
rake (~> 10.0)
|
35
|
+
rubocop (~> 0.58)
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# MysteryShopper
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/mystery_shopper`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'mystery_shopper'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install mystery_shopper
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/mystery_shopper.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'mystery_shopper'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'mystery_shopper/utils'
|
3
|
+
require 'mystery_shopper/price'
|
4
|
+
require 'mystery_shopper/request/price'
|
5
|
+
|
6
|
+
module MysteryShopper
|
7
|
+
class Game
|
8
|
+
include Utils
|
9
|
+
|
10
|
+
def initialize(data)
|
11
|
+
@data = data
|
12
|
+
end
|
13
|
+
|
14
|
+
def categories
|
15
|
+
@categories ||= data.dig('categories', 'category')
|
16
|
+
end
|
17
|
+
|
18
|
+
def url
|
19
|
+
@url ||= "https://www.nintendo.com/games/detail/#{data.fetch('slug')}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def buy_it_now?
|
23
|
+
@buy_it_now ||= to_bool(data.fetch('buyitnow'))
|
24
|
+
end
|
25
|
+
|
26
|
+
def release_date
|
27
|
+
@release_date ||= Date.parse(data.fetch('release_date'))
|
28
|
+
end
|
29
|
+
|
30
|
+
def digital_download?
|
31
|
+
@digital_download ||= to_bool(data.fetch('digitaldownload'))
|
32
|
+
end
|
33
|
+
|
34
|
+
def free_to_start?
|
35
|
+
@free_to_start ||= to_bool(data.fetch('free_to_start'))
|
36
|
+
end
|
37
|
+
|
38
|
+
def title
|
39
|
+
@title ||= data.fetch('title')
|
40
|
+
end
|
41
|
+
|
42
|
+
def system
|
43
|
+
@system ||= data.fetch('system')
|
44
|
+
end
|
45
|
+
|
46
|
+
def id
|
47
|
+
@id ||= data.fetch('id')
|
48
|
+
end
|
49
|
+
|
50
|
+
def number_of_players
|
51
|
+
@number_of_players ||= data.fetch('number_of_players')
|
52
|
+
end
|
53
|
+
|
54
|
+
def nsuid
|
55
|
+
@nsuid ||= data.fetch('nsuid')
|
56
|
+
end
|
57
|
+
|
58
|
+
def video_link
|
59
|
+
@video_link ||= data.fetch('video_link')
|
60
|
+
end
|
61
|
+
|
62
|
+
def front_box_art
|
63
|
+
@front_box_art ||= data.fetch('front_box_art')
|
64
|
+
end
|
65
|
+
|
66
|
+
def game_code
|
67
|
+
@game_code ||= data.fetch('game_code')
|
68
|
+
end
|
69
|
+
|
70
|
+
def buy_online?
|
71
|
+
@buy_online ||= to_bool(data.fetch('buyonline'))
|
72
|
+
end
|
73
|
+
|
74
|
+
def regular_price
|
75
|
+
price_details.regular_price
|
76
|
+
end
|
77
|
+
|
78
|
+
def discount_price
|
79
|
+
price_details.discount_price
|
80
|
+
end
|
81
|
+
|
82
|
+
def sales_status
|
83
|
+
price_details.sales_status
|
84
|
+
end
|
85
|
+
|
86
|
+
def sale_start
|
87
|
+
price_details.sale_start
|
88
|
+
end
|
89
|
+
|
90
|
+
def sale_end
|
91
|
+
price_details.sale_end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
attr_reader :data
|
97
|
+
|
98
|
+
def price_details
|
99
|
+
@price_details ||= Price.new(
|
100
|
+
Request::Price.new(nsuid).get.fetch('prices').first
|
101
|
+
)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module MysteryShopper
|
4
|
+
class Price
|
5
|
+
def initialize(data)
|
6
|
+
@data = data
|
7
|
+
end
|
8
|
+
|
9
|
+
def title_id
|
10
|
+
@title_id ||= data.fetch('title_id')
|
11
|
+
end
|
12
|
+
|
13
|
+
def sales_status
|
14
|
+
@sales_status ||= data.fetch('sales_status')
|
15
|
+
end
|
16
|
+
|
17
|
+
def regular_price
|
18
|
+
@regular_price ||= data.dig('regular_price', 'raw_value').to_f
|
19
|
+
end
|
20
|
+
|
21
|
+
def discount_price
|
22
|
+
@discount_price ||= discount.fetch('raw_value').to_f
|
23
|
+
end
|
24
|
+
|
25
|
+
def sale_start
|
26
|
+
@sale_start ||= Date.parse(discount.fetch('start_datetime'))
|
27
|
+
end
|
28
|
+
|
29
|
+
def sale_end
|
30
|
+
@sale_end ||= Date.parse(discount.fetch('end_datetime'))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
attr_reader :data
|
36
|
+
|
37
|
+
def discount
|
38
|
+
@discount ||= data.fetch('discount_price')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'net/http'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module MysteryShopper
|
6
|
+
module Request
|
7
|
+
class Base
|
8
|
+
def get
|
9
|
+
JSON.parse(Net::HTTP.get(construct_uri))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def construct_uri
|
15
|
+
URI(uri).tap do |uri|
|
16
|
+
uri.query = URI.encode_www_form(params)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'mystery_shopper/request/base'
|
2
|
+
|
3
|
+
module MysteryShopper
|
4
|
+
module Request
|
5
|
+
class Detail < Base
|
6
|
+
def initialize(**options)
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
attr_reader :options
|
13
|
+
|
14
|
+
def uri
|
15
|
+
'https://www.nintendo.com/json/content/get/filter/game'
|
16
|
+
end
|
17
|
+
|
18
|
+
def params
|
19
|
+
{ limit: 50,
|
20
|
+
offset: 0,
|
21
|
+
sale: false,
|
22
|
+
availability: 'now',
|
23
|
+
sort: 'title',
|
24
|
+
direction: 'asc',
|
25
|
+
system: 'switch' }.merge(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'mystery_shopper/request/base'
|
2
|
+
|
3
|
+
module MysteryShopper
|
4
|
+
module Request
|
5
|
+
class Price < Base
|
6
|
+
def initialize(*ids, **options)
|
7
|
+
@ids = ids.join(',')
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
attr_reader :ids, :options
|
14
|
+
|
15
|
+
def uri
|
16
|
+
'https://api.ec.nintendo.com/v1/price'
|
17
|
+
end
|
18
|
+
|
19
|
+
def params
|
20
|
+
{ country: 'US',
|
21
|
+
lang: 'en',
|
22
|
+
ids: ids }.merge(options)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'mystery_shopper/game'
|
2
|
+
|
3
|
+
module MysteryShopper
|
4
|
+
class Response
|
5
|
+
def initialize(data)
|
6
|
+
@data = data
|
7
|
+
end
|
8
|
+
|
9
|
+
def games
|
10
|
+
data.dig('games', 'game').map { |game| Game.new(game) }
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
attr_reader :data
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'mystery_shopper/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'mystery_shopper'
|
7
|
+
spec.version = MysteryShopper::VERSION
|
8
|
+
spec.authors = ['Hunter Braun']
|
9
|
+
spec.email = ['hunter.braun@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'A Ruby wrapper for the Nintendo eShop API'
|
12
|
+
spec.homepage = 'https://github.com/goronfreeman/mystery_shopper'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match(%r{^(test|spec|features)/})
|
16
|
+
end
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rubocop', '~> 0.58'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mystery_shopper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hunter Braun
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.58'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.58'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- hunter.braun@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/mystery_shopper.rb
|
71
|
+
- lib/mystery_shopper/game.rb
|
72
|
+
- lib/mystery_shopper/price.rb
|
73
|
+
- lib/mystery_shopper/request/base.rb
|
74
|
+
- lib/mystery_shopper/request/detail.rb
|
75
|
+
- lib/mystery_shopper/request/price.rb
|
76
|
+
- lib/mystery_shopper/response.rb
|
77
|
+
- lib/mystery_shopper/utils.rb
|
78
|
+
- lib/mystery_shopper/version.rb
|
79
|
+
- mystery_shopper.gemspec
|
80
|
+
homepage: https://github.com/goronfreeman/mystery_shopper
|
81
|
+
licenses: []
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.7.3
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: A Ruby wrapper for the Nintendo eShop API
|
103
|
+
test_files: []
|