Class: YandexWidget::Requests

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_widget/requests.rb

Constant Summary collapse

BASE_URL =
'https://payment.yandex.net/api/v3/payments/'

Instance Method Summary collapse

Constructor Details

#initialize(path, idempotence_key = nil, params: {}) ⇒ Requests

Returns a new instance of Requests.



5
6
7
8
9
# File 'lib/yandex_widget/requests.rb', line 5

def initialize(path, idempotence_key = nil, params: {})
  @url = BASE_URL + path
  @idempotence_key = idempotence_key
  @params = params
end

Instance Method Details

#init_clientObject



11
12
13
14
# File 'lib/yandex_widget/requests.rb', line 11

def init_client
  HTTParty.post(@url, body: @params.to_json, headers: default_headers,
                      basic_auth: auth, format: :json).parsed_response
end

#request_infoObject



16
17
18
# File 'lib/yandex_widget/requests.rb', line 16

def request_info
  HTTParty.get(@url, basic_auth: auth, format: :json).parsed_response
end

#set_statusObject



20
21
22
23
# File 'lib/yandex_widget/requests.rb', line 20

def set_status
  HTTParty.post(@url, body: @params.to_json, headers: default_headers,
                      basic_auth: auth, format: :json)
end