Class: MoneyOnline::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/money_online/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Request

Returns a new instance of Request.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
# File 'lib/money_online/request.rb', line 5

def initialize(params)
  @params = {
    :currency => "RUB"
  }.merge(params)

  raise ArgumentError, "MoneyOnline::Request requires amount, user_id, system_id, order_id and currency" unless params_valid?
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/money_online/request.rb', line 3

def params
  @params
end

Instance Method Details

#mapped_paramsObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/money_online/request.rb', line 13

def mapped_params
  {
    :project         => MoneyOnline.config.project,
    :amount          => params[:amount],
    :nickname        => params[:user_id],
    :nick_extra      => params[:user_extra],
    :mode_type       => params[:system_id],
    :order_id        => params[:order_id],
    :paymentCurrency => params[:currency]
  }
end

#params_valid?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/money_online/request.rb', line 29

def params_valid?
  not [:amount, :user_id, :system_id, :order_id, :currency].any? { |attribute| params[attribute].blank? }
end

#urlObject



25
26
27
# File 'lib/money_online/request.rb', line 25

def url
  "http://www.onlinedengi.ru/wmpaycheck.php?#{MoneyOnline.build_query(mapped_params)}"
end