class MomoPay::Request

Public Class Methods

post(endpoint, params={}) click to toggle source
# File lib/momo_pay/request.rb, line 4
def self.post(endpoint, params={})
  full_endpoint = "#{MomoPay.setup.domain}#{endpoint}"
  response = MomoPay::Http.post(full_endpoint, json: params)
  raise MomoPay::ClientError.new(full_endpoint) if response.status.client_error?
  raise MomoPay::ServerError.new(full_endpoint) if response.status.server_error?
  raise MomoPay::RequestError.new(response.parse) unless response.status.ok?
  response.parse
end
random_id() click to toggle source
# File lib/momo_pay/request.rb, line 13
def self.random_id
  "#{Time.now.strftime("%Y%m%d%H%M%S")}#{SecureRandom.hex(2)}"
end