Module: Prtscr::V3

Included in:
Prtscr
Defined in:
lib/prtscr/v3.rb

Overview

Version 2:

Instance Method Summary collapse

Instance Method Details

#v3(data) ⇒ Object



6
7
8
# File 'lib/prtscr/v3.rb', line 6

def v3(data)
  "https://prtscr.ru/v3/screenshot.#{data[:format]}?#{v3_query(data)}"
end

#v3_query(data) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/prtscr/v3.rb', line 19

def v3_query(data)
  ::URI.encode_www_form(
    {
      url: data[:url],
      key: data[:key],
      sign: v3_sign(data),
      width: data[:width],
      height: data[:height],
      scale: data[:scale]
    }.compact
  )
end

#v3_sign(data) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/prtscr/v3.rb', line 10

def v3_sign(data)
  ::Digest::MD5.hexdigest(
    [
      data[:url], data[:format], data[:key], data[:width],
      data[:height], data[:scale], data[:secret]
    ].map(&:to_s).join
  )
end