ncba 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c2985b943ce6f8eb7a475862aca38ab456fb3b0d569c8d46f3351b7d7d395bbd
4
+ data.tar.gz: 8e747096fce7455129e32d2c5ab9b54c74e79ad768f8bc50effdff98e9d4e599
5
+ SHA512:
6
+ metadata.gz: 62b5060de3d6fc39e0fee5d41234942090c2314caaeb810dd1a9962ce3787d42d11c266f14f52acbc7ffdf62be60e4ea33ebe5aa1ee1e89215972e30f107a022
7
+ data.tar.gz: d6a74f12384ddb7a72569a16e29ea58f9a2f5a6f76c06f65056460b89101e6c8883b60cbdc381d0f150f8da95cca5ead9c98e43f68c3e1fcb2b6fa4bfd2e6205
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: single_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.0.0] - 2021-10-28
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at info@berjis.tech. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in ncba.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.21'
13
+
14
+ gem 'faraday'
15
+ gem 'faraday_middleware'
16
+
17
+ group :development, :test do
18
+ gem 'dotenv-rails'
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,146 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ncba (0.1.0)
5
+ activesupport (>= 5.0.0)
6
+ faraday (>= 1.1)
7
+ faraday_middleware (~> 1.1)
8
+ openssl (>= 2.1)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionpack (7.0.1)
14
+ actionview (= 7.0.1)
15
+ activesupport (= 7.0.1)
16
+ rack (~> 2.0, >= 2.2.0)
17
+ rack-test (>= 0.6.3)
18
+ rails-dom-testing (~> 2.0)
19
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
+ actionview (7.0.1)
21
+ activesupport (= 7.0.1)
22
+ builder (~> 3.1)
23
+ erubi (~> 1.4)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
+ activesupport (7.0.1)
27
+ concurrent-ruby (~> 1.0, >= 1.0.2)
28
+ i18n (>= 1.6, < 2)
29
+ minitest (>= 5.1)
30
+ tzinfo (~> 2.0)
31
+ ast (2.4.2)
32
+ builder (3.2.4)
33
+ concurrent-ruby (1.1.9)
34
+ crass (1.0.6)
35
+ diff-lcs (1.5.0)
36
+ dotenv (2.7.6)
37
+ dotenv-rails (2.7.6)
38
+ dotenv (= 2.7.6)
39
+ railties (>= 3.2)
40
+ erubi (1.10.0)
41
+ faraday (1.9.3)
42
+ faraday-em_http (~> 1.0)
43
+ faraday-em_synchrony (~> 1.0)
44
+ faraday-excon (~> 1.1)
45
+ faraday-httpclient (~> 1.0)
46
+ faraday-multipart (~> 1.0)
47
+ faraday-net_http (~> 1.0)
48
+ faraday-net_http_persistent (~> 1.0)
49
+ faraday-patron (~> 1.0)
50
+ faraday-rack (~> 1.0)
51
+ faraday-retry (~> 1.0)
52
+ ruby2_keywords (>= 0.0.4)
53
+ faraday-em_http (1.0.0)
54
+ faraday-em_synchrony (1.0.0)
55
+ faraday-excon (1.1.0)
56
+ faraday-httpclient (1.0.1)
57
+ faraday-multipart (1.0.3)
58
+ multipart-post (>= 1.2, < 3)
59
+ faraday-net_http (1.0.1)
60
+ faraday-net_http_persistent (1.2.0)
61
+ faraday-patron (1.0.0)
62
+ faraday-rack (1.0.0)
63
+ faraday-retry (1.0.3)
64
+ faraday_middleware (1.2.0)
65
+ faraday (~> 1.0)
66
+ i18n (1.9.1)
67
+ concurrent-ruby (~> 1.0)
68
+ loofah (2.13.0)
69
+ crass (~> 1.0.2)
70
+ nokogiri (>= 1.5.9)
71
+ method_source (1.0.0)
72
+ minitest (5.15.0)
73
+ multipart-post (2.1.1)
74
+ nokogiri (1.13.1-x86_64-linux)
75
+ racc (~> 1.4)
76
+ openssl (3.0.0)
77
+ parallel (1.21.0)
78
+ parser (3.1.0.0)
79
+ ast (~> 2.4.1)
80
+ racc (1.6.0)
81
+ rack (2.2.3)
82
+ rack-test (1.1.0)
83
+ rack (>= 1.0, < 3)
84
+ rails-dom-testing (2.0.3)
85
+ activesupport (>= 4.2.0)
86
+ nokogiri (>= 1.6)
87
+ rails-html-sanitizer (1.4.2)
88
+ loofah (~> 2.3)
89
+ railties (7.0.1)
90
+ actionpack (= 7.0.1)
91
+ activesupport (= 7.0.1)
92
+ method_source
93
+ rake (>= 12.2)
94
+ thor (~> 1.0)
95
+ zeitwerk (~> 2.5)
96
+ rainbow (3.1.1)
97
+ rake (13.0.6)
98
+ regexp_parser (2.2.0)
99
+ rexml (3.2.5)
100
+ rspec (3.10.0)
101
+ rspec-core (~> 3.10.0)
102
+ rspec-expectations (~> 3.10.0)
103
+ rspec-mocks (~> 3.10.0)
104
+ rspec-core (3.10.2)
105
+ rspec-support (~> 3.10.0)
106
+ rspec-expectations (3.10.2)
107
+ diff-lcs (>= 1.2.0, < 2.0)
108
+ rspec-support (~> 3.10.0)
109
+ rspec-mocks (3.10.3)
110
+ diff-lcs (>= 1.2.0, < 2.0)
111
+ rspec-support (~> 3.10.0)
112
+ rspec-support (3.10.3)
113
+ rubocop (1.25.1)
114
+ parallel (~> 1.10)
115
+ parser (>= 3.1.0.0)
116
+ rainbow (>= 2.2.2, < 4.0)
117
+ regexp_parser (>= 1.8, < 3.0)
118
+ rexml
119
+ rubocop-ast (>= 1.15.1, < 2.0)
120
+ ruby-progressbar (~> 1.7)
121
+ unicode-display_width (>= 1.4.0, < 3.0)
122
+ rubocop-ast (1.15.1)
123
+ parser (>= 3.0.1.1)
124
+ ruby-progressbar (1.11.0)
125
+ ruby2_keywords (0.0.5)
126
+ thor (1.2.1)
127
+ tzinfo (2.0.4)
128
+ concurrent-ruby (~> 1.0)
129
+ unicode-display_width (2.1.0)
130
+ zeitwerk (2.5.4)
131
+
132
+ PLATFORMS
133
+ x86_64-linux
134
+
135
+ DEPENDENCIES
136
+ bundler (>= 2.1.4)
137
+ dotenv-rails
138
+ faraday
139
+ faraday_middleware
140
+ ncba!
141
+ rake (~> 13.0)
142
+ rspec (~> 3.0)
143
+ rubocop (~> 1.21)
144
+
145
+ BUNDLED WITH
146
+ 2.2.30
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Prometheus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,182 @@
1
+ # Ncba API
2
+
3
+ The NCBA gem is a wrapper that helps developers interface with the official [NCBA OPEN BANKING API](http://developers.cbagroup.com:4040/home).
4
+
5
+ <!-- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ncba` . To experiment with that code, run `bin/console` for an interactive prompt. -->
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ncba'
13
+ ```
14
+ or install unstable version from git
15
+ ```ruby
16
+ gem 'ncba', git: 'git@github.com:BerjisTech/ncba.git', branch: 'main'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ ```
22
+ $ bundle install
23
+ ```
24
+
25
+ Or install it yourself as:
26
+
27
+ ```
28
+ $ gem install ncba
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ```ruby
34
+ ncba_client = client = Ncba::Client.new(
35
+ api_user: "your_user_name",
36
+ api_key: "your_api_key"
37
+ )
38
+ ```
39
+
40
+ NCBA accepts almost all variables as string except for `amount` which is float.
41
+
42
+ ## Ncba:: Client:: AccountOpening
43
+
44
+ ```ruby
45
+ ncba_client.account_opening(
46
+ uid: "",
47
+ customer_category: "",
48
+ business_name: "",
49
+ prefered_name: "",
50
+ street: "",
51
+ town_country: "",
52
+ country: "",
53
+ sector: "",
54
+ industry: "",
55
+ nationality: "",
56
+ email: "",
57
+ emergency_email: "",
58
+ phone_number: "",
59
+ building: "",
60
+ website: "",
61
+ bank_name: "",
62
+ branch: "",
63
+ account_number: "",
64
+ bank_account_name: "",
65
+ account_currency: "",
66
+ cba_account: "",
67
+ bank_code: "",
68
+ swift_code: "",
69
+ business_phone_number: "",
70
+ postal_code: "",
71
+ postal_address: "",
72
+ stakeholder_director_shareholder: "",
73
+ stakeholder_surname: "",
74
+ stakeholder_forename: "",
75
+ stakeholder_salutation: "",
76
+ stakeholder_gender: "",
77
+ stakeholder_email: "",
78
+ stakeholder_phone: "",
79
+ stakeholder_postal_address: "",
80
+ stakeholder_town: "",
81
+ stakeholder_postal_code: "",
82
+ stakeholder_country: "",
83
+ stakeholder_id_type: "",
84
+ stakeholder_id_number: "",
85
+ brn: ""
86
+ )
87
+ ```
88
+
89
+ ## Ncba:: Client:: CreditDetails
90
+
91
+ ```ruby
92
+ ncba_client.credit_details(
93
+ bizpawa_id: "",
94
+ turnover_ratio: "",
95
+ saas_payment_rate: "",
96
+ payment_mode_rate: "",
97
+ predictive_analysis: "",
98
+ prev_loan_repayment_rate: "",
99
+ pre_existing_cba_account: "",
100
+ customer_bizpawa_age: "",
101
+ inventory_turnover: "",
102
+ director_listed_crb: "",
103
+ business_listed_crb: "",
104
+ bank_code: ""
105
+ )
106
+ ```
107
+
108
+ ## Ncba:: Client:: CreditTransfer
109
+
110
+ ```ruby
111
+ ncba_client.credit_transfer(
112
+ bank_code: '', # Bank Code (For ALL MWallets use 99), (For MPesa use 16 if RTGS), (For Pesalink 404)
113
+ bank_swift_code: '',
114
+ branch_code: '', # Branch code ( For ALL Mwallets use 002 )
115
+ beneficiary_account_name: '',
116
+ country: 'Kenya', # Kenya, Uganda, Tanzania (Case Sensitive)
117
+ transaction_type: '', # Internal, Eft, RTGS, Pesalink, Mpesa, HalotelTz, AirtelTz, ZantelTz, TigoTz, VodacomTz
118
+ reference: '',
119
+ currency: '', # KES, TZS, UGX
120
+ account: '', # 254XXXXXX (or your country code) for mobile, account number if bank
121
+ amount: '',
122
+ narration: '',
123
+ transaction_date: '',
124
+ validation_id: '', # Validation from mpesa_verification
125
+ sender_name: '',
126
+ purpose_of_payment: '',
127
+ sender_principle_activity: '',
128
+ sender_address: '',
129
+ receiver_address: '',
130
+ receiver_id: '',
131
+ sender_id: '',
132
+ beneficiary_name: ''
133
+ )
134
+ ```
135
+
136
+ ## Ncba:: Client:: MpesaPhoneNumberValidation
137
+
138
+ ```ruby
139
+ ncba_client.mpesa_phone_number_validation(
140
+ mobile_number: "",
141
+ reference: ""
142
+ )
143
+ ```
144
+
145
+ ## Ncba:: Client:: TransactionQuery
146
+
147
+ ```ruby
148
+ ncba_client.transaction_query(
149
+ country: "",
150
+ reference_number: ""
151
+ )
152
+ ```
153
+
154
+ <!-- ## Development
155
+
156
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
157
+
158
+ To install this gem onto your local machine, run `bundle exec rake install` . To release a new version, update the version number in `version.rb` , and then run `bundle exec rake release` , which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). -->
159
+
160
+ ## Contributing
161
+
162
+ Bug reports and pull requests are welcome on GitHub at https://github.com/berjistech/ncba. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/berjistech/ncba/blob/main/CODE_OF_CONDUCT.md).
163
+
164
+ We follow the [GitHub Flow](https://guides.github.com/introduction/flow/index.html) model:
165
+
166
+ 1. Check out this repo
167
+ 1. Create your branch with a descriptive name, prefixed with the associated issue number (if any): `git checkout -b 10-branch-name`
168
+ 1. Push the branch: `git push origin 10-branch-name`
169
+ 1. Create a pull request. This will serve as the central location for implementation discussion and code reviews. Assign it to yourself and label as "In Progress".
170
+ 1. Commit and push your changes: `git commit -am '[#10] added a feature'`
171
+ + Please [write a good commit message](https://github.com/torvalds/subsurface/blob/f019f9453f93878f133cf9be1f480ce114ee2d1b/README#L87)
172
+ 1. Once satisfied, get another developer to review the changes by assigning the PR to them and changing the label to "Needs Review". Once changes are approved and all tests/cops pass, merge to `main` and [deploy to Heroku](https://github.com/skyverge/shopstorm-app/wiki/Deploying%20to%20Heroku).
173
+
174
+ We assume that `main` is always deploy-ready.
175
+
176
+ ## License
177
+
178
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
179
+
180
+ ## Code of Conduct
181
+
182
+ Everyone interacting in the Ncba project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/berjistech/ncba/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'ncba'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ client = Ncba::Client.new(
15
+ api_user: "username",
16
+ api_key: "ke123"
17
+ )
18
+
19
+ require 'irb'
20
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ # Ncba
7
+ module Ncba
8
+ # Client
9
+ class Client
10
+ attr_reader :api_user, :api_key, :adapter
11
+
12
+ def initialize(api_user:, api_key:, adapter: Faraday.default_adapter)
13
+ @api_key = api_key # ApiKey
14
+ @api_user = api_user # APIUser
15
+ @adapter = adapter
16
+ @header = {
17
+ 'ApiKey': @api_key,
18
+ 'APIUser': @api_user
19
+ }
20
+ end
21
+
22
+ def account_opening(**args)
23
+ AccountOpening.new(self, args).call
24
+ end
25
+
26
+ def credit_details(**args)
27
+ CreditDetails.new(self, args).call
28
+ end
29
+
30
+ def credit_transfer(**args)
31
+ CreditTransfer.new(self, args).call
32
+ end
33
+
34
+ def mpesa_phone_number_validation(**args)
35
+ MpesaPhoneNumberValidation.new(self, args).call
36
+ end
37
+
38
+ def transaction_query(**args)
39
+ TransactionQuery.new(self, args).call
40
+ end
41
+
42
+ def connection
43
+ @connection ||= Faraday.new do |conn|
44
+ conn.url_prefix = 'http://developers.cbagroup.com:4040'
45
+ conn.request :json
46
+ conn.response :json, content_type: 'application/json'
47
+ conn.adapter adapter
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ostruct'
4
+
5
+ module Ncba
6
+ # Object
7
+ class Object
8
+ def initialize(attributes)
9
+ @attributes = OpenStruct.new(attributes)
10
+ end
11
+
12
+ def method_missing(method, *args, &block)
13
+ attribute = @attributes.send(method, *args, &block)
14
+ attribute.is_a?(Hash) ? Object.new(attribute) : attribute
15
+ end
16
+
17
+ def respond_to_missing?(_method, _include_private = false)
18
+ true
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ncba
4
+ class Intance < Object
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ncba
4
+ # Resource
5
+ class Resource
6
+ attr_reader :client, :args
7
+
8
+ def initialize(client, args = {})
9
+ @client = client
10
+ @args = args
11
+ @headers = { 'ApiKey': client.api_key, 'APIUser': client.api_user }
12
+ end
13
+
14
+ def get_request(url:, params: {}, headers: {})
15
+ handle_response client.connection.get(url, params, @headers)
16
+ end
17
+
18
+ def post_request(url:, body: {}, headers: {})
19
+ handle_response client.connection.post(url, body, @headers)
20
+ end
21
+
22
+ def handle_response(response)
23
+ # case response.status
24
+ # when 400
25
+ # raise Error, "Your request was malformed. #{response.body["errorMessage"]}"
26
+ # when 401
27
+ # raise Error, "You did not supply valid authentication credentials. #{response.body["errorMessage"]}"
28
+ # when 403
29
+ # raise Error, "You are not allowed to perform that action. #{response.body["errorMessage"]}"
30
+ # when 404
31
+ # raise Error, "No results were found for your request. #{response.body["errorMessage"]}"
32
+ # when 500
33
+ # raise Error, "Something wrong happened. #{response.body["errorMessage"]}"
34
+ # end
35
+ response
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/MethodLength
4
+ module Ncba
5
+ # Account opening
6
+ class AccountOpening < Resource
7
+ PATH = '/api/AccountOpening'
8
+ def call
9
+ post_request(url: PATH, body: body).body
10
+ end
11
+
12
+ def body
13
+ {
14
+ "UniqueID": args[:uid],
15
+ "CustomerCategory": args[:customer_category],
16
+ "BusinessName": args[:business_name],
17
+ "PreferedName": args[:prefered_name],
18
+ "Street": args[:street],
19
+ "TownCountry": args[:town_country],
20
+ "Country": args[:country],
21
+ "Sector": args[:sector],
22
+ "Industry": args[:industry],
23
+ "Nationality": args[:nationality],
24
+ "CustEmailId": args[:email],
25
+ "CustEmailId2": args[:emergency_email],
26
+ "CustMobPhone": args[:phone_number],
27
+ "Building": args[:building],
28
+ "Website": args[:website],
29
+ "BankName": args[:bank_name],
30
+ "Branch": args[:branch],
31
+ "AcctNum": args[:account_number],
32
+ "BankAccountName": args[:bank_account_name],
33
+ "AccountCurrency": args[:account_currency],
34
+ "CbaAccount": args[:cba_account],
35
+ "BankCode": args[:bank_code],
36
+ "SwiftCode": args[:swift_code],
37
+ "BusinessPhoneNumber": args[:business_phone_number],
38
+ "PostalCode": args[:postal_code],
39
+ "PostalAddress": args[:postal_address],
40
+ "StakeHolder": {
41
+ "Stakeholder": [
42
+ {
43
+ "DirShareholder": args[:stakeholder_director_shareholder],
44
+ "StakeSurname": args[:stakeholder_surname],
45
+ "StakeForename": args[:stakeholder_forename],
46
+ "StakeSalutation": args[:stakeholder_salutation],
47
+ "StakeGender": args[:stakeholder_gender],
48
+ "StakeEmail1": args[:stakeholder_email],
49
+ "StakeTel1": args[:stakeholder_phone],
50
+ "StakePost": args[:stakeholder_postal_address],
51
+ "StakeTown": args[:stakeholder_town],
52
+ "StakePostCode": args[:stakeholder_postal_code],
53
+ "StakeCountry": args[:stakeholder_country],
54
+ "IDType": args[:stakeholder_id_type],
55
+ "IDNumber": args[:stakeholder_id_number]
56
+ }
57
+ ]
58
+ },
59
+ "BusinesRegistrationNo": args[:brn]
60
+ }
61
+ end
62
+ end
63
+ end
64
+ # rubocop:enable Metrics/MethodLength
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/AbcSize
4
+ # rubocop:disable Metrics/MethodLength
5
+ module Ncba
6
+ # CreditDetails
7
+ class CreditDetails < Resource
8
+ PATH = '/api/CreditDetails'
9
+
10
+ def call
11
+ post_request(url: PATH, body: body).body
12
+ end
13
+
14
+ def body
15
+ {
16
+ "BizpawaID": args[:bizpawa_id],
17
+ "TurnoverRatio": args[:turnover_ratio],
18
+ "SaasPaymentRate": args[:saas_payment_rate],
19
+ "PaymentModeRatio": args[:payment_mode_rate],
20
+ "PredictiveAnalysis": args[:predictive_analysis],
21
+ "PrevLoanRepaymentRate": args[:prev_loan_repayment_rate],
22
+ "PreExistingCBAAccount": args[:pre_existing_cba_account],
23
+ "CustomerBizpawaAge": args[:customer_bizpawa_age],
24
+ "InventoryTurnover": args[:inventory_turnover],
25
+ "DirectorListedCRB": args[:director_listed_crb],
26
+ "BusinessListedCRB": args[:business_listed_crb],
27
+ "Amount": args[:bank_code].to_f,
28
+ "CheckCRB": true
29
+ }
30
+ end
31
+ end
32
+ end
33
+ # rubocop:enable Metrics/MethodLength
34
+ # rubocop:enable Metrics/AbcSize
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/AbcSize
4
+ # rubocop:disable Metrics/MethodLength
5
+ module Ncba
6
+ # CreditTransfer
7
+ class CreditTransfer < Resource
8
+ PATH = '/api/CreditTransfer'
9
+
10
+ def call
11
+ post_request(url: PATH, body: body).body
12
+ end
13
+
14
+ def body
15
+ {
16
+ "BankCode": args[:bank_code],
17
+ "BankSwiftCode": args[:bank_swift_code],
18
+ "BranchCode": args[:branch_code],
19
+ "BeneficiaryAccountName": args[:beneficiary_account_name],
20
+ "Country": args[:country],
21
+ "TranType": args[:transaction_type],
22
+ "Reference": args[:reference],
23
+ "Currency": args[:currency],
24
+ "Account": args[:account],
25
+ "Amount": args[:amount].to_f,
26
+ "Narration": args[:narration],
27
+ "Transaction Date": args[:transaction_date],
28
+ "Validation ID": args[:validation_id],
29
+ "SenderName": args[:sender_name],
30
+ "Purpose of Payment": args[:purpose_of_payment],
31
+ "Sender Principle activity": args[:sender_principle_activity],
32
+ "Sender Address": args[:sender_address],
33
+ "Receiver Address": args[:receiver_address],
34
+ "Receiver ID": args[:receiver_id],
35
+ "Sender ID": args[:sender_id],
36
+ "BeneficiaryName": args[:beneficiary_name]
37
+ }
38
+ end
39
+ end
40
+ end
41
+ # rubocop:enable Metrics/MethodLength
42
+ # rubocop:enable Metrics/AbcSize
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ncba
4
+ # MpesaPhoneNumberValidation
5
+ class MpesaPhoneNumberValidation < Resource
6
+ PATH = '/api/MpesaPhoneNumberValidation'
7
+
8
+ def call
9
+ post_request(url: PATH, body: body).body
10
+ end
11
+
12
+ def body
13
+ {
14
+ "Mobile Number": args[:mobile_number],
15
+ "Reference": args[:reference]
16
+ }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ncba
4
+ # TransactionQuery
5
+ class TransactionQuery < Resource
6
+ PATH = '/api/TransactionQuery'
7
+
8
+ def call
9
+ post_request(url: PATH, body: body).body
10
+ end
11
+
12
+ def body
13
+ {
14
+ "Country": args[:country],
15
+ "ReferenceNumber": args[:reference_number]
16
+ }
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ncba
4
+ VERSION = '0.0.2'
5
+ end
data/lib/ncba.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'ncba/version'
4
+
5
+ # Ncba
6
+ module Ncba
7
+ class Error < StandardError; end
8
+
9
+ autoload :Error, 'ncba/error'
10
+ autoload :Client, 'ncba/client'
11
+ autoload :Object, 'ncba/object'
12
+ autoload :Resource, 'ncba/resource'
13
+
14
+ autoload :AccountOpening, 'ncba/resources/account_opening'
15
+ autoload :CreditDetails, 'ncba/resources/credit_details'
16
+ autoload :CreditTransfer, 'ncba/resources/credit_transfer'
17
+ autoload :MpesaPhoneNumberValidation, 'ncba/resources/mpesa_phone_number_validation'
18
+ autoload :TransactionQuery, 'ncba/resources/transaction_query'
19
+
20
+ autoload :Instance, 'ncba/objects/instace'
21
+ end
data/ncba-0.0.0.gem ADDED
Binary file
data/ncba-0.0.1.gem ADDED
Binary file
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ncba
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Prometheus
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-02-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.1'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.4
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.1'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.1.4
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '12.3'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '12.3'
47
+ - !ruby/object:Gem::Dependency
48
+ name: activesupport
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.0'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 5.0.0
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '5.0'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 5.0.0
67
+ - !ruby/object:Gem::Dependency
68
+ name: faraday
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.1'
74
+ type: :runtime
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.1'
81
+ - !ruby/object:Gem::Dependency
82
+ name: faraday_middleware
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.1'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '1.1'
95
+ - !ruby/object:Gem::Dependency
96
+ name: openssl
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '2.1'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '2.1'
109
+ description: The NCBA gem is a wrapper that helps developers interface with the official
110
+ NCBA OPEN BANKING API http://developers.cbagroup.com:4040/home.
111
+ email:
112
+ - info@berjis.tech
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - ".rspec"
118
+ - ".rubocop.yml"
119
+ - CHANGELOG.md
120
+ - CODE_OF_CONDUCT.md
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/ncba.rb
129
+ - lib/ncba/client.rb
130
+ - lib/ncba/object.rb
131
+ - lib/ncba/objects/instance.rb
132
+ - lib/ncba/resource.rb
133
+ - lib/ncba/resources/account_opening.rb
134
+ - lib/ncba/resources/credit_details.rb
135
+ - lib/ncba/resources/credit_transfer.rb
136
+ - lib/ncba/resources/mpesa_phone_number_validation.rb
137
+ - lib/ncba/resources/transaction_query.rb
138
+ - lib/ncba/version.rb
139
+ - ncba-0.0.0.gem
140
+ - ncba-0.0.1.gem
141
+ homepage: https://github.com/BerjisTech/ncba
142
+ licenses:
143
+ - MIT
144
+ metadata:
145
+ allowed_push_host: https://rubygems.org/
146
+ homepage_uri: https://github.com/BerjisTech/ncba
147
+ source_code_uri: https://github.com/BerjisTech/ncba
148
+ changelog_uri: https://github.com/BerjisTech/ncba/blob/main/CHANGELOG.md
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: 2.6.0
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubygems_version: 3.2.29
165
+ signing_key:
166
+ specification_version: 4
167
+ summary: NCBA OPEN BANKING API
168
+ test_files: []