Skip to content

Commit

Permalink
Merge pull request #14 from taylorfinnell/auto-send-correct-version
Browse files Browse the repository at this point in the history
Allow setting HQ version number
  • Loading branch information
taylorfinnell authored Oct 19, 2019
2 parents 995f8c9 + 56a73a3 commit e6c207f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
21 changes: 18 additions & 3 deletions src/hqtrivia/auth.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,36 @@ module HqTrivia

# Given a *country* it returns the required headers
def headers(country)
HTTP::Headers{
headers = HTTP::Headers{
"Authorization" => "Bearer #{token(country)}",
"x-hq-device" => "iPhone10,4",
"x-hq-client" => "iOS/1.5.1 b157",
"accept-language" => "en-us",
"x-hq-stk" => "MQ==",
"x-hq-deviceclass" => "phone",
"x-hq-timezone" => "America/Chicago",
"user-agent" => "HQ-iOS/157 CFNetwork/987.0.7 Darwin/18.7.0",
"x-hq-country" => country,
"x-hq-lang" => "en",
"Host" => "api-quiz.hype.space",
"Connection" => "Keep-Alive",
# "Accept-Encoding" => "gzip",
}

if build_number && version_number
headers.merge!({
"x-hq-client" => "iOS/#{version_number} b#{build_number}",
"user-agent" => "HQ-iOS/#{build_number} CFNetwork/987.0.7 Darwin/18.7.0"
})
end

headers
end

private def build_number
HqTrivia.config.hq_build_number
end

private def version_number
HqTrivia.config.hq_version_number
end
end
end
4 changes: 3 additions & 1 deletion src/hqtrivia/config.cr
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module HqTrivia
class Config
property supress_missing_type_attribute_json_errors
property hq_version_number
property hq_build_number

def initialize(@supress_missing_type_attribute_json_errors = false)
def initialize(@hq_version_number : String? = nil, @hq_build_number : String? = nil, @supress_missing_type_attribute_json_errors = false)
end
end
end

0 comments on commit e6c207f

Please sign in to comment.