valorant_daily_store 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f8218782433c124d7e6c1df1df74584fabe07ed0ac8c8e5d3c0ee7daf4edb821
4
+ data.tar.gz: ed263fb90ee5bbd98261fecf1da67fc12a4d01a0dc6e9a8e035b85ca235691c7
5
+ SHA512:
6
+ metadata.gz: 7fca8c260a6246fa0954f6abf6f48022819e0f23d42b4c998b934b5866c6da607d6dfeaa2d16394e53dd7b4aac8102ddc7322c976888f053ce82596ad2983bf0
7
+ data.tar.gz: 27461d1462d5c1714e3d4294a27efe94c92693d52bab5a6245007adec66fb84240d664dc347e9c701cf709e6e358a75c82d6f9c7dccb69338af6393a9e97d309
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@commitlint/config-conventional"]
3
+ }
data/.husky/commit-msg ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx --no-install commitlint --edit "$1"
data/.husky/pre-commit ADDED
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ bundle exec rake
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.standard.yml ADDED
@@ -0,0 +1,2 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.1.0
data/.versionrc.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "types": [
3
+ { "type": "feat", "section": "Features" },
4
+ { "type": "fix", "section": "Bug Fixes" },
5
+ { "type": "chore", "hidden": true },
6
+ { "type": "docs", "hidden": true },
7
+ { "type": "style", "hidden": true },
8
+ { "type": "refactor", "hidden": true },
9
+ { "type": "perf", "hidden": true },
10
+ { "type": "test", "hidden": true }
11
+ ],
12
+ "commitUrlFormat": "https://github.com/Vegann/valorant_daily_store/commits/{{hash}}",
13
+ "compareUrlFormat": "https://github.com/Vegann/valorant_daily_store/compare/{{previousTag}}...{{currentTag}}",
14
+ "bumpFiles": [
15
+ {
16
+ "filename": "./lib/valorant_daily_store/version.rb",
17
+ "updater": "gem-version-updater.js"
18
+ },
19
+ {
20
+ "filename": "./Gemfile.lock",
21
+ "updater": "gemfile-lock-updater.js"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "ruby.format": "standard",
3
+ "ruby.lint": { "standard": true, "rubocop": false }
4
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,52 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [1.0.3](https://github.com/Vegann/valorant_daily_store/compare/v1.0.2...v1.0.3) (2022-01-29)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * github action didn't run on tag ([6ea57f2](https://github.com/Vegann/valorant_daily_store/commits/6ea57f2fd23f6b90abecfbccb2706ca7b46e3417))
11
+
12
+ ### [1.0.2](https://github.com/Vegann/valorant_daily_store/compare/v1.0.1...v1.0.2) (2022-01-29)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * forgot to change the updater ([09939ee](https://github.com/Vegann/valorant_daily_store/commits/09939ee8e60b3f55ad594b6ef99f6ff5ebe7f277))
18
+
19
+ ### [1.0.1](https://github.com/Vegann/valorant_daily_store/compare/v1.0.0...v1.0.1) (2022-01-29)
20
+
21
+
22
+ ### Features
23
+
24
+ * bump version in Gemfile.lock on release ([30ea1eb](https://github.com/Vegann/valorant_daily_store/commits/30ea1eb7886b2eb5f27ed2f9053af8d47afbf134))
25
+ * merge 2 workflows ([bd9cba1](https://github.com/Vegann/valorant_daily_store/commits/bd9cba1b42c6b753db05ee4520a8587dc244aafd))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * gem version updater ([e15a281](https://github.com/Vegann/valorant_daily_store/commits/e15a281da104261ccbba96ec42b11210a8fbad8a))
31
+ * remove precommit hook from standard-version ([2f5be5e](https://github.com/Vegann/valorant_daily_store/commits/2f5be5eebe994a2703c119ed16cf3267e9cd5793))
32
+ * version in Gemfile.lock was not updated ([f5717fd](https://github.com/Vegann/valorant_daily_store/commits/f5717fde33ca1fb7a15d8b02729a4cbb97e2d3d6))
33
+
34
+ ## 1.0.0 (2022-01-29)
35
+
36
+
37
+ ### Features
38
+
39
+ * bump gem version automatically ([39e7791](https://github.com/Vegann/valorant_daily_store/commits/39e77918277aef1e141680cb9ea2f0f9e92110f1))
40
+ * github action to publish gem ([0790111](https://github.com/Vegann/valorant_daily_store/commits/079011111d16544f8bd6362eab69b7c28908d9c7))
41
+ * initial commit ([25eabca](https://github.com/Vegann/valorant_daily_store/commits/25eabcafd0619024a965fabe9658c197d2c4748d))
42
+ * update readme ([758f538](https://github.com/Vegann/valorant_daily_store/commits/758f538de89bf3ca5632e4de5be4036c707baa5e))
43
+
44
+
45
+ ### Bug Fixes
46
+
47
+ * github actions ([cf82bd3](https://github.com/Vegann/valorant_daily_store/commits/cf82bd37e69c5d7514473850e8d14dc70bda7ba9))
48
+ * version in the gem version ([4f669a6](https://github.com/Vegann/valorant_daily_store/commits/4f669a678eed9b73f428f54ad7e617724d91b8bf))
49
+
50
+ ## [0.1.0] - 2022-01-28
51
+
52
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ - Demonstrating empathy and kindness toward other people
14
+ - Being respectful of differing opinions, viewpoints, and experiences
15
+ - Giving and gracefully accepting constructive feedback
16
+ - Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ - Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ - The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ - Trolling, insulting or derogatory comments, and personal or political attacks
24
+ - Public or private harassment
25
+ - Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ - Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at git@vegann.anonaddy.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,100 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ valorant_daily_store (1.0.3)
5
+ faraday (~> 2.1)
6
+ faraday-cookie_jar (~> 0.0.7)
7
+ thor (~> 1.2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.8.0)
13
+ public_suffix (>= 2.0.2, < 5.0)
14
+ ast (2.4.2)
15
+ coderay (1.1.3)
16
+ crack (0.4.5)
17
+ rexml
18
+ diff-lcs (1.5.0)
19
+ domain_name (0.5.20190701)
20
+ unf (>= 0.0.5, < 1.0.0)
21
+ faraday (2.1.0)
22
+ faraday-net_http (~> 2.0)
23
+ ruby2_keywords (>= 0.0.4)
24
+ faraday-cookie_jar (0.0.7)
25
+ faraday (>= 0.8.0)
26
+ http-cookie (~> 1.0.0)
27
+ faraday-net_http (2.0.1)
28
+ hashdiff (1.0.1)
29
+ http-cookie (1.0.4)
30
+ domain_name (~> 0.5)
31
+ method_source (1.0.0)
32
+ parallel (1.21.0)
33
+ parser (3.1.0.0)
34
+ ast (~> 2.4.1)
35
+ pry (0.14.1)
36
+ coderay (~> 1.1)
37
+ method_source (~> 1.0)
38
+ public_suffix (4.0.6)
39
+ rainbow (3.1.1)
40
+ rake (13.0.6)
41
+ regexp_parser (2.2.0)
42
+ rexml (3.2.5)
43
+ rspec (3.10.0)
44
+ rspec-core (~> 3.10.0)
45
+ rspec-expectations (~> 3.10.0)
46
+ rspec-mocks (~> 3.10.0)
47
+ rspec-core (3.10.2)
48
+ rspec-support (~> 3.10.0)
49
+ rspec-expectations (3.10.2)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.10.0)
52
+ rspec-mocks (3.10.3)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.10.0)
55
+ rspec-support (3.10.3)
56
+ rubocop (1.25.0)
57
+ parallel (~> 1.10)
58
+ parser (>= 3.1.0.0)
59
+ rainbow (>= 2.2.2, < 4.0)
60
+ regexp_parser (>= 1.8, < 3.0)
61
+ rexml
62
+ rubocop-ast (>= 1.15.1, < 2.0)
63
+ ruby-progressbar (~> 1.7)
64
+ unicode-display_width (>= 1.4.0, < 3.0)
65
+ rubocop-ast (1.15.1)
66
+ parser (>= 3.0.1.1)
67
+ rubocop-performance (1.13.2)
68
+ rubocop (>= 1.7.0, < 2.0)
69
+ rubocop-ast (>= 0.4.0)
70
+ ruby-progressbar (1.11.0)
71
+ ruby2_keywords (0.0.5)
72
+ standard (1.7.0)
73
+ rubocop (= 1.25.0)
74
+ rubocop-performance (= 1.13.2)
75
+ thor (1.2.1)
76
+ unf (0.1.4)
77
+ unf_ext
78
+ unf_ext (0.0.8)
79
+ unicode-display_width (2.1.0)
80
+ vcr (6.0.0)
81
+ webmock (3.14.0)
82
+ addressable (>= 2.8.0)
83
+ crack (>= 0.3.2)
84
+ hashdiff (>= 0.4.0, < 2.0.0)
85
+
86
+ PLATFORMS
87
+ x86_64-linux
88
+
89
+ DEPENDENCIES
90
+ bundler (~> 2.3.3)
91
+ pry (~> 0.14.1)
92
+ rake (~> 13.0)
93
+ rspec (~> 3.0)
94
+ standard (~> 1.3)
95
+ valorant_daily_store!
96
+ vcr (~> 6.0)
97
+ webmock (~> 3.14)
98
+
99
+ BUNDLED WITH
100
+ 2.3.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Vegann
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.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Valorant Daily Store
2
+
3
+ This gem will let you see your daily store without opening the game
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'valorant_daily_store'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install valorant_daily_store
20
+
21
+ ## Usage
22
+
23
+ ```sh
24
+ valorant_daily_store get -u username -p password -l language -r region
25
+ ```
26
+
27
+ ## Development
28
+
29
+ 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.
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 the created tag, 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/Vegann/valorant_daily_store. 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/Vegann/valorant_daily_store/blob/main/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the ValorantDailyStore project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Vegann/valorant_daily_store/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "standard/rake"
9
+
10
+ task default: %i[spec standard]
data/bin/console ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "valorant_daily_store"
6
+ require "pry"
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+ npm i
8
+
9
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'valorant_daily_store/cli'
4
+
5
+ ValorantDailyStore::CLI.start(ARGV)
@@ -0,0 +1,16 @@
1
+ module.exports.readVersion = function (contents) {
2
+ const regex = /VERSION = "(\d+\.\d+\.\d+)"/g
3
+
4
+ const result = contents.matchAll(regex)
5
+
6
+ return [...result][0][1]
7
+ }
8
+
9
+ module.exports.writeVersion = function (contents, version) {
10
+ const newContent = contents.replace(
11
+ /VERSION = "(\d+\.\d+\.\d+)"/,
12
+ `VERSION = "${version}"`
13
+ )
14
+
15
+ return newContent
16
+ }
@@ -0,0 +1,16 @@
1
+ module.exports.readVersion = function (contents) {
2
+ const regex = /valorant_daily_store \((\d+\.\d+\.\d+)\)/g
3
+
4
+ const result = contents.matchAll(regex)
5
+
6
+ return [...result][0][1]
7
+ }
8
+
9
+ module.exports.writeVersion = function (contents, version) {
10
+ const newContent = contents.replace(
11
+ /valorant_daily_store \(\d+\.\d+\.\d+\)/,
12
+ `valorant_daily_store (${version})`
13
+ )
14
+
15
+ return newContent
16
+ }
@@ -0,0 +1,25 @@
1
+ require "thor"
2
+ require_relative "./data"
3
+ require_relative "./consts"
4
+ require "json"
5
+
6
+ module ValorantDailyStore
7
+ class CLI < Thor
8
+ def self.exit_on_failure?
9
+ true
10
+ end
11
+
12
+ desc "get", "Get your daily Valorant shop"
13
+ option :username, type: :string, required: true, banner: "Riot username", aliases: ["-u"]
14
+ option :password, type: :string, required: true, banner: "Riot password", aliases: ["-p"]
15
+ option :region, type: :string, required: true, banner: "Account's region", aliases: ["-r"]
16
+ option :language, type: :string, required: false, banner: "Language used to translate weapons name", default: "en-US", aliases: ["-l"], enum: ValorantDailyStore::VALORANT_API_LANGUAGES
17
+
18
+ def get
19
+ response = Data.new(username: options[:username], password: options[:password], region: options[:region], language: options[:language]).get
20
+ puts JSON.pretty_generate(response)
21
+ rescue => e
22
+ puts "ERROR: #{e.message}"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module ValorantDailyStore
2
+ VALORANT_API_LANGUAGES = ["ar-AE", "de-DE", "en-US", "es-ES", "es-MX", "fr-FR", "id-ID", "it-IT", "ja-JP", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "th-TH", "tr-TR", "vi-VN", "zh-CN", "zh-TW"].freeze
3
+ end
@@ -0,0 +1,163 @@
1
+ require "faraday"
2
+ require "faraday-cookie_jar"
3
+ require_relative "./skin"
4
+ require_relative "./consts"
5
+ require_relative "./errors"
6
+
7
+ module ValorantDailyStore
8
+ class Data
9
+ def initialize(region:, username:, password:, language: "en-US")
10
+ @region = region
11
+ @username = username
12
+ @password = password
13
+
14
+ if ValorantDailyStore::VALORANT_API_LANGUAGES.include?(language)
15
+ @language = language
16
+ else
17
+ raise UnsupportedLanguage
18
+ end
19
+ end
20
+
21
+ def get
22
+ set_starting_cookies
23
+ get_token
24
+ get_entitlements_token
25
+ get_player_id
26
+ get_skin_ids
27
+ get_offers
28
+ prepare_skins
29
+ end
30
+
31
+ private
32
+
33
+ def set_starting_cookies
34
+ response = auth_conn.post("/api/v1/authorization", {nonce: "1", client_id: "play-valorant-web-prod", redirect_uri: "https://playvalorant.com/opt_in", response_type: "token id_token"})
35
+ if response.status != 200
36
+ raise AuthorizationCookiesError
37
+ end
38
+ nil
39
+ end
40
+
41
+ def get_token
42
+ response = auth_conn.put("/api/v1/authorization", {type: "auth", username: username, password: password})
43
+
44
+ @token = response.body&.dig("response", "parameters", "uri")&.match(/access_token=((?:[a-zA-Z]|\d|\.|-|_)*).*id_token=((?:[a-zA-Z]|\d|\.|-|_)*).*expires_in=(\d*)/i)&.captures&.dig(0)
45
+
46
+ if response.status != 200 || token.nil?
47
+ raise AuthorizaionTokenError
48
+ end
49
+ nil
50
+ end
51
+
52
+ def get_entitlements_token
53
+ response = entitlements_conn.post("/api/token/v1", {})
54
+
55
+ @entitlements_token = response.body&.dig("entitlements_token")
56
+
57
+ if response.status != 200 || entitlements_token.nil?
58
+ raise EntitlementsTokenError
59
+ end
60
+ nil
61
+ end
62
+
63
+ def get_player_id
64
+ response = auth_conn.get("/userinfo", {}) do |req|
65
+ req.headers["Authorization"] = "Bearer #{token}"
66
+ end
67
+
68
+ @player_id = response.body&.dig("sub")
69
+
70
+ if response.status != 200 || player_id.nil?
71
+ raise PlayerIdError
72
+ end
73
+ nil
74
+ end
75
+
76
+ def get_skin_ids
77
+ response = store_conn.get("/store/v2/storefront/#{player_id}")
78
+
79
+ @skin_ids = response.body&.dig("SkinsPanelLayout", "SingleItemOffers")
80
+
81
+ if response.status != 200 || skin_ids.nil?
82
+ raise SkinIdsError
83
+ end
84
+ nil
85
+ end
86
+
87
+ def get_offers
88
+ response = store_conn.get("/store/v1/offers/", {})
89
+
90
+ @offers = response.body&.dig("Offers")
91
+
92
+ if response.status != 200 || offers.nil?
93
+ raise OffersError
94
+ end
95
+ nil
96
+ end
97
+
98
+ def prepare_skins
99
+ skins = []
100
+ skin_ids.each do |skin_id|
101
+ offer = offers.find { |o| o["OfferID"] == skin_id }
102
+
103
+ continue if offer.nil?
104
+ _, price = offer["Cost"].first
105
+
106
+ response = valorant_api_conn.get("/v1/weapons/skinlevels/#{skin_id}/?language=#{language}")
107
+
108
+ if response.status != 200 || response.body["status"] != 200
109
+ raise ValorantApiError
110
+ end
111
+
112
+ name = response.body["data"]["displayName"]
113
+ photo = response.body["data"]["displayIcon"]
114
+ video = response.body["data"]["streamedVideo"]
115
+
116
+ skins.push(Skin.new(name:, photo:, video:, price:))
117
+ end
118
+ skins
119
+ end
120
+
121
+ def auth_conn
122
+ @auth_conn ||= Faraday.new(url: "https://auth.riotgames.com") do |builder|
123
+ builder.use :cookie_jar
124
+ builder.response :json
125
+ builder.request :json
126
+ builder.adapter Faraday.default_adapter
127
+ builder.headers["User-Agent"] = "RiotClient/43.0.1.4195386.4190634 rso-auth (Windows;10;;Professional, x64)"
128
+ end
129
+ end
130
+
131
+ def entitlements_conn
132
+ @entitlements_conn ||= Faraday.new("https://entitlements.auth.riotgames.com") do |builder|
133
+ builder.response :json
134
+ builder.request :json
135
+ builder.adapter Faraday.default_adapter
136
+ builder.headers["Authorization"] = "Bearer #{token}"
137
+ builder.headers["User-Agent"] = "RiotClient/43.0.1.4195386.4190634 rso-auth (Windows;10;;Professional, x64)"
138
+ end
139
+ end
140
+
141
+ def store_conn
142
+ @store_conn ||= Faraday.new("https://pd.#{region}.a.pvp.net") do |builder|
143
+ builder.response :json
144
+ builder.request :json
145
+ builder.adapter Faraday.default_adapter
146
+ builder.headers["Authorization"] = "Bearer #{token}"
147
+ builder.headers["User-Agent"] = "RiotClient/43.0.1.4195386.4190634 rso-auth (Windows;10;;Professional, x64)"
148
+ builder.headers["X-Riot-Entitlements-JWT"] = entitlements_token
149
+ end
150
+ end
151
+
152
+ def valorant_api_conn
153
+ # v1/weapons/skinlevels/
154
+ @valorant_api_conn ||= Faraday.new("https://valorant-api.com") do |builder|
155
+ builder.response :json
156
+ builder.request :json
157
+ builder.adapter Faraday.default_adapter
158
+ end
159
+ end
160
+
161
+ attr_reader :username, :password, :region, :token, :entitlements_token, :player_id, :skin_ids, :offers, :language
162
+ end
163
+ end