Class: Cliptic::Main::Fetch::Request
- Inherits:
-
Object
- Object
- Cliptic::Main::Fetch::Request
- Defined in:
- lib/cliptic/main.rb
Direct Known Subclasses
Constant Summary collapse
- URL =
"https://data.puzzlexperts.com/puzzleapp-v3/data.php"
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(date: Date.today, psid: 100000160) ⇒ Request
constructor
A new instance of Request.
- #raw ⇒ Object
- #send_request ⇒ Object
- #valid_input? ⇒ Boolean
Constructor Details
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
135 136 137 |
# File 'lib/cliptic/main.rb', line 135 def data @data end |
Instance Method Details
#raw ⇒ Object
146 147 148 149 150 |
# File 'lib/cliptic/main.rb', line 146 def raw @raw || Curl.get(URL, data) do |curl| curl.ssl_verify_peer = false end.body end |
#send_request ⇒ Object
139 140 141 |
# File 'lib/cliptic/main.rb', line 139 def send_request valid_input? ? raw : (raise Cliptic::Errors::Invalid_Date.new(data[:date])) end |
#valid_input? ⇒ Boolean
142 143 144 145 |
# File 'lib/cliptic/main.rb', line 142 def valid_input? JSON.parse(raw, symbolize_names:true) .dig(:cells, 0, :meta, :data).length > 0 end |