module BSB::AusPayNet::Client

Constants

LEADER_WIDTH
OUTPUT_PARAM_WIDTH
Response

Public Class Methods

fetch_all_bsbs() click to toggle source
# File lib/bsb/aus_pay_net/client.rb, line 15
def self.fetch_all_bsbs
  subscription_key = ENV.fetch('AUSPAYNET_SUB_KEY', nil)
  if subscription_key.nil?
    raise MissingSubscriptionKeyError, "the environment variable 'AUSPAYNET_SUB_KEY' must be present"
  end

  conn = Faraday.new(
    url: 'https://auspaynet-bicbsb-api-prod.azure-api.net',
    headers: {
      'Content-Type': 'application/json',
      'Ocp-Apim-Subscription-Key': subscription_key
    }
  ) do |faraday|
    faraday.response :raise_error
  end

  response = conn.post('/bsbquery/manual/paths/invoke') do |req|
    req.body = { outputparam: ' ' * OUTPUT_PARAM_WIDTH }.to_json
  end

  Response.new(body: response.body[LEADER_WIDTH..])
end