Skip to content

Commit 521bf13

Browse files
committed
Document methods
1 parent 68063ac commit 521bf13

8 files changed

Lines changed: 41 additions & 0 deletions

File tree

.rubocop.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ Lint/DuplicateMethods:
1313
Naming/AccessorMethodName:
1414
Enabled: false
1515
Naming/PredicateName:
16+
Enabled: false
17+
Style/AsciiComments:
1618
Enabled: false

lib/momoapi-ruby/cli.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# frozen_string_literal: true
22

3+
# This is an executable file allowing a user to use the command line interface
4+
# to pass in a callback host url and a subscription key
5+
# and get back a generated user id and API key
6+
37
require 'faraday'
48
require 'json'
59
require 'securerandom'

lib/momoapi-ruby/client.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# frozen_string_literal: true
22

3+
# Base implementation of the MTN API client
4+
5+
# Includes methods common to collections, disbursements and remittances
6+
37
require 'faraday'
48

59
require 'momoapi-ruby/config'
@@ -38,6 +42,8 @@ def handle_error(response_body, response_code)
3842
raise Error::APIError.new(response_body, response_code)
3943
end
4044

45+
# Create an access token which can then be used to
46+
# authorize and authenticate towards the other end-points of the API
4147
def get_auth_token(path, subscription_key)
4248
headers = {
4349
"Ocp-Apim-Subscription-Key": subscription_key
@@ -65,14 +71,17 @@ def prepare_get_request(path, subscription_key)
6571
send_request('get', path, headers)
6672
end
6773

74+
# get the balance on an account
6875
def get_balance(path, subscription_key)
6976
prepare_get_request(path, subscription_key)
7077
end
7178

79+
# retrieve transaction information, for transfer and payments
7280
def get_transaction_status(path, subscription_key)
7381
prepare_get_request(path, subscription_key)
7482
end
7583

84+
# check if an account holder is registered and active in the system
7685
def is_user_active(path, subscription_key)
7786
prepare_get_request(path, subscription_key)
7887
end

lib/momoapi-ruby/collection.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
# Implementation of the MTN API collections client
4+
35
require 'securerandom'
46

57
require 'momoapi-ruby/config'
@@ -22,6 +24,13 @@ def get_transaction_status(transaction_id)
2224
super(path, Momoapi.config.collection_primary_key)
2325
end
2426

27+
# This method is used to request a payment from a consumer (Payer).
28+
# The payer will be asked to authorize the payment. The transaction will
29+
# be executed once the payer has authorized the payment.
30+
# The requesttopay will be in status PENDING until the transaction
31+
# is authorized or declined by the payer or it is timed out by the system.
32+
# The status of the transaction can be validated
33+
# by using `get_transation_status`
2534
def request_to_pay(phone_number, amount, external_id,
2635
payee_note = '', payer_message = '',
2736
currency = 'EUR', **options)

lib/momoapi-ruby/config.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# frozen_string_literal: true
22

3+
# Configurations are set up in this file
4+
# for a user's MTN MoMo API user credentials
5+
36
module Momoapi
47
class Config
58
attr_accessor :environment, :base_url,

lib/momoapi-ruby/disbursement.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
# Implementation of the MTN API disbursements client
4+
35
require 'momoapi-ruby/config'
46
require 'momoapi-ruby/client'
57

@@ -20,6 +22,10 @@ def get_transaction_status(transaction_id)
2022
super(path, Momoapi.config.disbursement_primary_key)
2123
end
2224

25+
# The transfer operation is used to transfer an amount from the owner’s
26+
# account to a payee account.
27+
# The status of the transaction can be validated
28+
# by using `get_transation_status`
2329
def transfer(phone_number, amount, external_id,
2430
payee_note = '', payer_message = '',
2531
currency = 'EUR', **options)

lib/momoapi-ruby/errors.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
# Error handling for unsuccessful responses from the MTN Momo API
4+
35
module Error
46
class APIError < StandardError
57
def initialize(message, code)

lib/momoapi-ruby/remittance.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# frozen_string_literal: true
22

3+
# Implementation of the MTN API remittances client
4+
35
require 'momoapi-ruby/config'
46
require 'momoapi-ruby/client'
57

@@ -20,6 +22,10 @@ def get_transaction_status(transaction_id)
2022
super(path, Momoapi.config.remittance_primary_key)
2123
end
2224

25+
# The transfer operation is used to transfer an amount from the owner’s
26+
# account to a payee account.
27+
# The status of the transaction can be validated
28+
# by using `get_transation_status`
2329
def transfer(phone_number, amount, external_id,
2430
payee_note = '', payer_message = '',
2531
currency = 'EUR', **options)

0 commit comments

Comments
 (0)