class Peperusha::C2bRegisterUrls

Public Instance Methods

call() click to toggle source
# File lib/peperusha/c2b_register_urls.rb, line 18
def call
  path = 'mpesa/c2b/v1/registerurl'
  response = Peperusha::Client.invoke_post_request(token, path, attributes)

  if response.status == 200
    data = JSON.parse(response.body)
    context.body = data
  else
    client_errors = Peperusha::Client.build_errors_collection(response)
    context.fail!(errors: client_errors)
  end
end

Private Instance Methods

attributes() click to toggle source
# File lib/peperusha/c2b_register_urls.rb, line 40
def attributes
  {
    'ConfirmationURL': confirmation_url,
    'ResponseType': 'Canceled',
    'ShortCode': business_number,
    'ValidationURL': validation_url
  }
end
check_if_params_missing() click to toggle source
# File lib/peperusha/c2b_register_urls.rb, line 33
def check_if_params_missing
  errors = []
  errors << 'confirmation_url.missing' if confirmation_url.nil?
  errors << 'business_number.missing' if business_number.nil?
  errors
end