class Mpayer::Payable

Public Class Methods

new(user_no, token) click to toggle source
# File lib/mpayer/payable.rb, line 9
def initialize(user_no, token)
  @user_no = user_no
  @token   = token
  @auth    = WSSE::header(@user_no, @token)
  @header  = {'Content-Type'=> 'application/json', 'Accept' => 'application/json', 'X-WSSE' => "#{@auth}" }
end

Public Instance Methods

all() click to toggle source
# File lib/mpayer/payable.rb, line 16
def all
  @payables_url = "#{@@base_uri}/payables/all.json"
  HTTParty.get(@payables_url.to_str, headers: @header)
end
delete(payable_id) click to toggle source
# File lib/mpayer/payable.rb, line 26
def delete(payable_id)
  @delete_payable_url = "#{@@base_uri}/payables/#{payable_id}"
  HTTParty.delete(@delete_payable_url.to_str, body: json_msg.to_json, headers: @header)
end
fetch_batch_records(*args) click to toggle source
# File lib/mpayer/payable.rb, line 31
def fetch_batch_records(*args)
        @headers = { 'Content-Type' => 'application/x-www-form-urlencoded', 'X-WSSE' => WSSE::header(@user_no, @token) }
  @batch_records_url = "#{@@base_uri}/batch"
  json_msg = "requests=#{args[0].to_json}"
  HTTParty.post(@batch_records_url.to_str, body: json_msg, headers: @headers)
end
get_payable_by_ids(*args) click to toggle source
# File lib/mpayer/payable.rb, line 38
def get_payable_by_ids(*args)
  @payables_url = "/payables/all.json?payable_ids=#{args.join(',')}"
  HTTParty.get(@payables_url.to_str, headers: @header)
end
group_payable_items(account_id) click to toggle source
# File lib/mpayer/payable.rb, line 48
def group_payable_items(account_id)
  @payable_items_url = "#{@@base_uri}/accounts/#{@account_id}/payable_items.json?ac_type=terminal_ac&per_page=100"
  HTTParty.get(@payable_items_url.to_str, headers: @header)
end
new(json_msg) click to toggle source
# File lib/mpayer/payable.rb, line 21
def new(json_msg)
  @new_payable_url = "#{@@base_uri}/payables"
  HTTParty.post(@new_payable_url.to_str, body: json_msg.to_json, headers: @header)
end
payable_items(account_id) click to toggle source
# File lib/mpayer/payable.rb, line 43
def payable_items(account_id)
  @payable_items_url = "#{@@base_uri}/accounts/#{account_id}/payable_items.json?per_page=100"
  HTTParty.get(@payable_items_url.to_str, headers: @header)
end